Update README.md
Browse files
README.md
CHANGED
|
@@ -14,3 +14,64 @@ datasets:
|
|
| 14 |
models:
|
| 15 |
- sdadas/polish-roberta-large-v2
|
| 16 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
models:
|
| 15 |
- sdadas/polish-roberta-large-v2
|
| 16 |
---
|
| 17 |
+
|
| 18 |
+
## Sample model usage
|
| 19 |
+
|
| 20 |
+
Below is an example of using the model:
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
```python
|
| 24 |
+
from sentence_transformers.cross_encoder import CrossEncoder
|
| 25 |
+
|
| 26 |
+
model_path = "radlab/polish-cross-encoder"
|
| 27 |
+
model = CrossEncoder(model_path)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
questions = [
|
| 31 |
+
"Jak膮 mamy dzi艣 pogod臋? bo Andrzej nic nie m贸wi艂.",
|
| 32 |
+
"Gdzie jedzie Andrzej? Bo wczoraj by艂 w Warszawie.",
|
| 33 |
+
"Czy oskar偶ony si臋 zgadza z przedstawionym wyrokiem?",
|
| 34 |
+
]
|
| 35 |
+
answers = [
|
| 36 |
+
"Pan Andrzej siedzi w poci膮gu i jedzie do Wiednia. Ogl膮da na telefonie zabawne filmiki.",
|
| 37 |
+
"Poada deszcz i jest wilgotno, jednak wczoraj by艂o s艂onecznie.",
|
| 38 |
+
"Wyrok jest prawomocny i nie podlega dalszym rozwa偶aniom.",
|
| 39 |
+
]
|
| 40 |
+
for question in questions:
|
| 41 |
+
context_with_question = [(s, question) for s in answers]
|
| 42 |
+
results = sorted(
|
| 43 |
+
{
|
| 44 |
+
idx: r for idx, r in enumerate(model.predict(context_with_question))
|
| 45 |
+
}.items(),
|
| 46 |
+
key=lambda x: x[1],
|
| 47 |
+
reverse=True,
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
print(f"QUESTION: {question}")
|
| 51 |
+
print("ANSWERS (sorted):")
|
| 52 |
+
for idx, score in results:
|
| 53 |
+
print(f"\t[{score}]\t{answers[idx]}")
|
| 54 |
+
print("")
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
and output to the standard output:
|
| 58 |
+
|
| 59 |
+
```
|
| 60 |
+
QUESTION: Jak膮 mamy dzi艣 pogod臋? bo Andrzej nic nie m贸wi艂.
|
| 61 |
+
ANSWERS (sorted):
|
| 62 |
+
[0.016749681904911995] Poada deszcz i jest wilgotno, jednak wczoraj by艂o s艂onecznie.
|
| 63 |
+
[0.01602918468415737] Pan Andrzej siedzi w poci膮gu i jedzie do Wiednia. Ogl膮da na telefonie zabawne filmiki.
|
| 64 |
+
[0.016013670712709427] Wyrok jest prawomocny i nie podlega dalszym rozwa偶aniom.
|
| 65 |
+
|
| 66 |
+
QUESTION: Gdzie jedzie Andrzej? Bo wczoraj by艂 w Warszawie.
|
| 67 |
+
ANSWERS (sorted):
|
| 68 |
+
[0.5997582674026489] Pan Andrzej siedzi w poci膮gu i jedzie do Wiednia. Ogl膮da na telefonie zabawne filmiki.
|
| 69 |
+
[0.4528200924396515] Wyrok jest prawomocny i nie podlega dalszym rozwa偶aniom.
|
| 70 |
+
[0.17350871860980988] Poada deszcz i jest wilgotno, jednak wczoraj by艂o s艂onecznie.
|
| 71 |
+
|
| 72 |
+
QUESTION: Czy oskar偶ony si臋 zgadza z przedstawionym wyrokiem?
|
| 73 |
+
ANSWERS (sorted):
|
| 74 |
+
[0.8431766629219055] Wyrok jest prawomocny i nie podlega dalszym rozwa偶aniom.
|
| 75 |
+
[0.6823258996009827] Poada deszcz i jest wilgotno, jednak wczoraj by艂o s艂onecznie.
|
| 76 |
+
[0.558414101600647] Pan Andrzej siedzi w poci膮gu i jedzie do Wiednia. Ogl膮da na telefonie zabawne filmiki.
|
| 77 |
+
```
|