Update README.md
Browse files
README.md
CHANGED
@@ -57,8 +57,9 @@ kao i korpus [PDRS 1.0](https://www.clarin.si/repository/xmlui/handle/11356/1752
|
|
57 |
|
58 |
```python
|
59 |
>>> from transformers import pipeline
|
60 |
-
>>>
|
61 |
>>> unmasker("Kada bi čovek znao gde će pasti on bi<mask>.")
|
|
|
62 |
```
|
63 |
|
64 |
```
|
@@ -73,8 +74,8 @@ kao i korpus [PDRS 1.0](https://www.clarin.si/repository/xmlui/handle/11356/1752
|
|
73 |
>>> from transformers import AutoTokenizer, AutoModelForMaskedLM
|
74 |
>>> from torch import LongTensor, no_grad
|
75 |
>>> from scipy import spatial
|
76 |
-
>>> tokenizer = AutoTokenizer.from_pretrained('jerteh/jerteh-
|
77 |
-
>>> model = AutoModelForMaskedLM.from_pretrained('jerteh/jerteh-
|
78 |
>>> x = " pas"
|
79 |
>>> y = " mačka"
|
80 |
>>> z = " svemir"
|
@@ -83,12 +84,12 @@ kao i korpus [PDRS 1.0](https://www.clarin.si/repository/xmlui/handle/11356/1752
|
|
83 |
>>> tensor_z = LongTensor(tokenizer.encode(z, add_special_tokens=False)).unsqueeze(0)
|
84 |
>>> model.eval()
|
85 |
>>> with no_grad():
|
86 |
-
|
87 |
>>> vektor_x = model(input_ids=tensor_x).hidden_states[-1].squeeze()
|
88 |
>>> vektor_y = model(input_ids=tensor_y).hidden_states[-1].squeeze()
|
89 |
>>> vektor_z = model(input_ids=tensor_z).hidden_states[-1].squeeze()
|
90 |
-
>>>
|
91 |
-
>>>
|
|
|
92 |
```
|
93 |
|
94 |
```
|
|
|
57 |
|
58 |
```python
|
59 |
>>> from transformers import pipeline
|
60 |
+
>>> unmasker = pipeline('fill-mask', model='jerteh/jerteh-81')
|
61 |
>>> unmasker("Kada bi čovek znao gde će pasti on bi<mask>.")
|
62 |
+
>>>
|
63 |
```
|
64 |
|
65 |
```
|
|
|
74 |
>>> from transformers import AutoTokenizer, AutoModelForMaskedLM
|
75 |
>>> from torch import LongTensor, no_grad
|
76 |
>>> from scipy import spatial
|
77 |
+
>>> tokenizer = AutoTokenizer.from_pretrained('jerteh/jerteh-81')
|
78 |
+
>>> model = AutoModelForMaskedLM.from_pretrained('jerteh/jerteh-81', output_hidden_states=True)
|
79 |
>>> x = " pas"
|
80 |
>>> y = " mačka"
|
81 |
>>> z = " svemir"
|
|
|
84 |
>>> tensor_z = LongTensor(tokenizer.encode(z, add_special_tokens=False)).unsqueeze(0)
|
85 |
>>> model.eval()
|
86 |
>>> with no_grad():
|
|
|
87 |
>>> vektor_x = model(input_ids=tensor_x).hidden_states[-1].squeeze()
|
88 |
>>> vektor_y = model(input_ids=tensor_y).hidden_states[-1].squeeze()
|
89 |
>>> vektor_z = model(input_ids=tensor_z).hidden_states[-1].squeeze()
|
90 |
+
>>> print(spatial.distance.cosine(vektor_x, vektor_y))
|
91 |
+
>>> print(spatial.distance.cosine(vektor_x, vektor_z))
|
92 |
+
>>>
|
93 |
```
|
94 |
|
95 |
```
|