Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- fa
|
| 4 |
+
- multilingual
|
| 5 |
+
thumbnail: "https://upload.wikimedia.org/wikipedia/commons/a/a2/Farsi.svg"
|
| 6 |
+
tags:
|
| 7 |
+
- query-paraphrasing
|
| 8 |
+
- mt5
|
| 9 |
+
- persian
|
| 10 |
+
- farsi
|
| 11 |
+
license: "CC BY-NC-SA 4.0"
|
| 12 |
+
datasets:
|
| 13 |
+
- parsinlu
|
| 14 |
+
- qqp
|
| 15 |
+
metrics:
|
| 16 |
+
- accuracy
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# Detection of Paraphrased Queries (تشخصیص سوالات هممعنی)
|
| 20 |
+
|
| 21 |
+
This is a model for detection of paraphrased queries.
|
| 22 |
+
Here is an example of how you can run this model:
|
| 23 |
+
|
| 24 |
+
```python
|
| 25 |
+
from transformers import MT5Config, MT5ForConditionalGeneration, MT5Tokenizer
|
| 26 |
+
|
| 27 |
+
model_name = "persiannlp/mt5-base-parsinlu-qqp-query-paraphrasing"
|
| 28 |
+
tokenizer = MT5Tokenizer.from_pretrained(model_name)
|
| 29 |
+
model = MT5ForConditionalGeneration.from_pretrained(model_name)
|
| 30 |
+
|
| 31 |
+
def run_model(q1, q2, **generator_args):
|
| 32 |
+
input_ids = tokenizer.encode(f"{q1}<sep>{q2}", return_tensors="pt")
|
| 33 |
+
res = model.generate(input_ids, **generator_args)
|
| 34 |
+
output = tokenizer.batch_decode(res, skip_special_tokens=True)
|
| 35 |
+
print(output)
|
| 36 |
+
return output
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
run_model("چه چیزی باعث پوکی استخوان می شود؟", "چه چیزی باعث مقاومت استخوان در برابر ضربه می شود؟")
|
| 40 |
+
run_model("من دارم به این فکر میکنم چرا ساعت هفت نمیشه؟", "چرا من ساده فکر میکردم به عشقت پابندی؟")
|
| 41 |
+
run_model("دعای کمیل در چه روزهایی خوانده می شود؟", "دعای جوشن کبیر در چه شبی خوانده می شود؟")
|
| 42 |
+
run_model("دعای کمیل در چه روزهایی خوانده می شود؟", "دعای جوشن کبیر در چه شبی خوانده می شود؟")
|
| 43 |
+
run_model("شناسنامه در چه سالی وارد ایران شد؟", "سیب زمینی در چه سالی وارد ایران شد؟")
|
| 44 |
+
run_model("سیب زمینی چه زمانی وارد ایران شد؟", "سیب زمینی در چه سالی وارد ایران شد؟")
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
For more details, visit this page: https://github.com/persiannlp/parsinlu/
|