danyaljj commited on
Commit
13b7875
1 Parent(s): 6c225d6

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +60 -0
README.md ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - fa
4
+ - multilingual
5
+ thumbnail: "https://upload.wikimedia.org/wikipedia/commons/a/a2/Farsi.svg"
6
+ tags:
7
+ - entailment
8
+ - parsbert
9
+ - persian
10
+ - farsi
11
+ license: "CC BY-NC-SA 4.0"
12
+ datasets:
13
+ - parsinlu
14
+ metrics:
15
+ - accuracy
16
+ ---
17
+
18
+ # Textual Entailment (مدل برای پاسخ به استلزام منطقی)
19
+
20
+ This is a model for textual entailment problems.
21
+ Here is an example of how you can run this model:
22
+
23
+ ```python
24
+ import torch
25
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
26
+ import numpy as np
27
+
28
+ labels = ["entails", "contradicts", "neutral"]
29
+ model_name_or_path = "persiannlp/parsbert-base-parsinlu-entailment"
30
+ model = AutoModelForSequenceClassification.from_pretrained(model_name_or_path)
31
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path,)
32
+
33
+
34
+ def model_predict(text_a, text_b):
35
+ features = tokenizer( [(text_a, text_b)], padding="max_length", truncation=True, return_tensors='pt')
36
+ output = model(**features)
37
+ logits = output[0]
38
+ probs = torch.nn.functional.softmax(logits, dim=1).tolist()
39
+ idx = np.argmax(np.array(probs))
40
+ print(labels[idx], probs)
41
+
42
+
43
+ model_predict(
44
+ "این مسابقات بین آوریل و دسامبر در هیپودروم ولیفندی در نزدیکی باکرکی ، ۱۵ کیلومتری (۹ مایل) غرب استانبول برگزار می شود.",
45
+ "در ولیفندی هیپودروم، مسابقاتی از آوریل تا دسامبر وجود دارد."
46
+ )
47
+
48
+ model_predict(
49
+ "آیا کودکانی وجود دارند که نیاز به سرگرمی دارند؟",
50
+ "هیچ کودکی هرگز نمی خواهد سرگرم شود.",
51
+ )
52
+
53
+ model_predict(
54
+ "ما به سفرهایی رفته ایم که در نهرهایی شنا کرده ایم",
55
+ "علاوه بر استحمام در نهرها ، ما به اسپا ها و سونا ها نیز رفته ایم."
56
+ )
57
+ ```
58
+
59
+
60
+ For more details, visit this page: https://github.com/persiannlp/parsinlu/