Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,59 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
+
language:
|
4 |
+
- it
|
5 |
---
|
6 |
+
--------------------------------------------------------------------------------------------------
|
7 |
+
|
8 |
+
<body>
|
9 |
+
<span class="vertical-text" style="background-color:lightgreen;border-radius: 3px;padding: 3px;"> </span>
|
10 |
+
<br>
|
11 |
+
<span class="vertical-text" style="background-color:orange;border-radius: 3px;padding: 3px;"> </span>
|
12 |
+
<br>
|
13 |
+
<span class="vertical-text" style="background-color:lightblue;border-radius: 3px;padding: 3px;"> Model: Distilled Universal Sentence Encoder</span>
|
14 |
+
<br>
|
15 |
+
<span class="vertical-text" style="background-color:tomato;border-radius: 3px;padding: 3px;"> Lang: IT</span>
|
16 |
+
<br>
|
17 |
+
<span class="vertical-text" style="background-color:lightgrey;border-radius: 3px;padding: 3px;"> </span>
|
18 |
+
<br>
|
19 |
+
<span class="vertical-text" style="background-color:#CF9FFF;border-radius: 3px;padding: 3px;"> </span>
|
20 |
+
</body>
|
21 |
+
|
22 |
+
--------------------------------------------------------------------------------------------------
|
23 |
+
|
24 |
+
<h3>Model description</h3>
|
25 |
+
|
26 |
+
This is a <b>Universal Sentence Encoder</b> <b>[1]</b> model for the <b>Italian</b> language, obtained using <b>mDistilUSE</b> ([distiluse-base-multilingual-cased-v1](https://huggingface.co/sentence-transformers/distiluse-base-multilingual-cased-v1)) as a starting point and focusing it on the Italian language by modifying the embedding layer
|
27 |
+
(as in <b>[2]</b>, computing document-level frequencies over the <b>Wikipedia</b> dataset)
|
28 |
+
|
29 |
+
The resulting model has 67M parameters, a vocabulary of 30.785 tokens, and a size of ~270 MB.
|
30 |
+
|
31 |
+
It can be used to encode Italian texts and compute similarities between them.
|
32 |
+
|
33 |
+
<h3>Quick usage</h3>
|
34 |
+
|
35 |
+
```python
|
36 |
+
from transformers import AutoTokenizer, AutoModel
|
37 |
+
import numpy as np
|
38 |
+
|
39 |
+
tokenizer = AutoTokenizer.from_pretrained("../osiria/distiluse-base-italian/")
|
40 |
+
model = AutoModel.from_pretrained("../osiria/distiluse-base-italian/")
|
41 |
+
text1 = "Alessandro Manzoni è stato uno scrittore italiano"
|
42 |
+
text2 = "Giacomo Leopardi è stato un poeta italiano"
|
43 |
+
vec1 = model(tokenizer.encode(text1, return_tensors = "pt")).last_hidden_state[0,0,:].cpu().detach().numpy()
|
44 |
+
vec2 = model(tokenizer.encode(text2, return_tensors = "pt")).last_hidden_state[0,0,:].cpu().detach().numpy()
|
45 |
+
cosine_similarity = np.dot(vec1, vec2)/(np.linalg.norm(vec1)*np.linalg.norm(vec2))
|
46 |
+
print("COSINE SIMILARITY:", cosine_similarity)
|
47 |
+
|
48 |
+
# COSINE SIMILARITY: 0.734292
|
49 |
+
```
|
50 |
+
|
51 |
+
<h3>References</h3>
|
52 |
+
|
53 |
+
[1] https://arxiv.org/abs/1907.04307
|
54 |
+
|
55 |
+
[2] https://arxiv.org/abs/2010.05609
|
56 |
+
|
57 |
+
<h3>License</h3>
|
58 |
+
|
59 |
+
The model is released under <b>Apache-2.0</b> license
|