Add new SentenceTransformer model
Browse files- .gitattributes +1 -0
- 1_Pooling/config.json +10 -0
- README.md +1014 -0
- config.json +66 -0
- config_sentence_transformers.json +16 -0
- custom_st.py +229 -0
- model.safetensors +3 -0
- modules.json +23 -0
- sentence_bert_config.json +4 -0
- special_tokens_map.json +51 -0
- tokenizer.json +3 -0
- tokenizer_config.json +55 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
1_Pooling/config.json
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"word_embedding_dimension": 1024,
|
3 |
+
"pooling_mode_cls_token": false,
|
4 |
+
"pooling_mode_mean_tokens": true,
|
5 |
+
"pooling_mode_max_tokens": false,
|
6 |
+
"pooling_mode_mean_sqrt_len_tokens": false,
|
7 |
+
"pooling_mode_weightedmean_tokens": false,
|
8 |
+
"pooling_mode_lasttoken": false,
|
9 |
+
"include_prompt": true
|
10 |
+
}
|
README.md
ADDED
@@ -0,0 +1,1014 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- es
|
4 |
+
license: apache-2.0
|
5 |
+
tags:
|
6 |
+
- sentence-transformers
|
7 |
+
- sentence-similarity
|
8 |
+
- feature-extraction
|
9 |
+
- generated_from_trainer
|
10 |
+
- dataset_size:14907
|
11 |
+
- loss:MatryoshkaLoss
|
12 |
+
- loss:MultipleNegativesRankingLoss
|
13 |
+
base_model: jinaai/jina-embeddings-v3
|
14 |
+
widget:
|
15 |
+
- source_sentence: ¿Qué característica especial tenía la escultura del 'Torico' creada
|
16 |
+
por Pedro Blesa?
|
17 |
+
sentences:
|
18 |
+
- 'Después de dorar el conejo en la receta de Conejo escabechado, en la misma sartén
|
19 |
+
se rehogan los ajos, con el laurel y la pimienta.
|
20 |
+
|
21 |
+
'
|
22 |
+
- Rafael Barcelón se encargaba del servicio de electricidad en Valdeconejos en 1951.
|
23 |
+
- La escultura del 'Torico' creada por Pedro Blesa era un anaglifo, visible en 3D
|
24 |
+
con gafas especiales.
|
25 |
+
- source_sentence: ¿Por qué cantidad adquirió Francisco Santacruz la mina Escuadra
|
26 |
+
en la subasta pública?
|
27 |
+
sentences:
|
28 |
+
- Después de la temporada 1986-87, el equipo descendió, lo que provocó su desaparición
|
29 |
+
del campeonato en la temporada 1987-88.
|
30 |
+
- '''Al bies'' significa en diagonal.'
|
31 |
+
- Francisco Santacruz adquirió la mina Escuadra por la cantidad de 931 pesetas.
|
32 |
+
- source_sentence: ¿Quién se desempeñaba como fiscal en el ayuntamiento de Escucha
|
33 |
+
en el año 1916?
|
34 |
+
sentences:
|
35 |
+
- El autor mencionado para la receta Sopas de ajo es Teo Martin Lafuente.
|
36 |
+
- En Escucha en 1916, D. Joaquín Latorre del Río se desempeñaba como fiscal.
|
37 |
+
- Felipe Mallén era el farmacéutico en Valdeconejos en 1928.
|
38 |
+
- source_sentence: ¿Qué información transmiten los 'toques' en la caña de un pozo
|
39 |
+
durante las operaciones mineras?
|
40 |
+
sentences:
|
41 |
+
- Juan Pedro Martín encontró fragmentos de carbón de piedra en el paraje de El Horcajo.
|
42 |
+
- Se publicó en 1970 por Ediciones Cultura y Acción. CNT.
|
43 |
+
- 'Los ''toques'' son señales que se hacen en la caña del pozo para las distintas
|
44 |
+
operaciones 1: alto 2: arriba 3: abajo 1+2: despacio arriba 1+3: despacio abajo
|
45 |
+
4+2: personal arriba 4+3: personal abajo 4+1+2: señalista en jaula arriba 4+1+3:
|
46 |
+
señalista en jaula abajo 5: jaula libre 6: maniobra'
|
47 |
+
- source_sentence: ¿En qué año se demarcó y reconoció la mina 'El Pilar'?
|
48 |
+
sentences:
|
49 |
+
- Según la quinta demanda del SOMM, todas compañías mineras debían entregar a todos
|
50 |
+
sus obreros un libramiento de liquidación mensual
|
51 |
+
- '''Tontiar'' significa cuando dos jóvenes empiezan con un noviazgo.'
|
52 |
+
- La mina 'El Pilar' se demarcó y reconoció en 1857.
|
53 |
+
pipeline_tag: sentence-similarity
|
54 |
+
library_name: sentence-transformers
|
55 |
+
metrics:
|
56 |
+
- cosine_accuracy@1
|
57 |
+
- cosine_accuracy@3
|
58 |
+
- cosine_accuracy@5
|
59 |
+
- cosine_accuracy@10
|
60 |
+
- cosine_precision@1
|
61 |
+
- cosine_precision@3
|
62 |
+
- cosine_precision@5
|
63 |
+
- cosine_precision@10
|
64 |
+
- cosine_recall@1
|
65 |
+
- cosine_recall@3
|
66 |
+
- cosine_recall@5
|
67 |
+
- cosine_recall@10
|
68 |
+
- cosine_ndcg@10
|
69 |
+
- cosine_mrr@10
|
70 |
+
- cosine_map@100
|
71 |
+
model-index:
|
72 |
+
- name: Lampistero
|
73 |
+
results:
|
74 |
+
- task:
|
75 |
+
type: information-retrieval
|
76 |
+
name: Information Retrieval
|
77 |
+
dataset:
|
78 |
+
name: dim 1024
|
79 |
+
type: dim_1024
|
80 |
+
metrics:
|
81 |
+
- type: cosine_accuracy@1
|
82 |
+
value: 0.7700663850331925
|
83 |
+
name: Cosine Accuracy@1
|
84 |
+
- type: cosine_accuracy@3
|
85 |
+
value: 0.8925769462884732
|
86 |
+
name: Cosine Accuracy@3
|
87 |
+
- type: cosine_accuracy@5
|
88 |
+
value: 0.9155099577549789
|
89 |
+
name: Cosine Accuracy@5
|
90 |
+
- type: cosine_accuracy@10
|
91 |
+
value: 0.9330114665057333
|
92 |
+
name: Cosine Accuracy@10
|
93 |
+
- type: cosine_precision@1
|
94 |
+
value: 0.7700663850331925
|
95 |
+
name: Cosine Precision@1
|
96 |
+
- type: cosine_precision@3
|
97 |
+
value: 0.2975256487628244
|
98 |
+
name: Cosine Precision@3
|
99 |
+
- type: cosine_precision@5
|
100 |
+
value: 0.18310199155099577
|
101 |
+
name: Cosine Precision@5
|
102 |
+
- type: cosine_precision@10
|
103 |
+
value: 0.09330114665057333
|
104 |
+
name: Cosine Precision@10
|
105 |
+
- type: cosine_recall@1
|
106 |
+
value: 0.7700663850331925
|
107 |
+
name: Cosine Recall@1
|
108 |
+
- type: cosine_recall@3
|
109 |
+
value: 0.8925769462884732
|
110 |
+
name: Cosine Recall@3
|
111 |
+
- type: cosine_recall@5
|
112 |
+
value: 0.9155099577549789
|
113 |
+
name: Cosine Recall@5
|
114 |
+
- type: cosine_recall@10
|
115 |
+
value: 0.9330114665057333
|
116 |
+
name: Cosine Recall@10
|
117 |
+
- type: cosine_ndcg@10
|
118 |
+
value: 0.8578914781807897
|
119 |
+
name: Cosine Ndcg@10
|
120 |
+
- type: cosine_mrr@10
|
121 |
+
value: 0.8330619976817926
|
122 |
+
name: Cosine Mrr@10
|
123 |
+
- type: cosine_map@100
|
124 |
+
value: 0.8343424106284848
|
125 |
+
name: Cosine Map@100
|
126 |
+
- task:
|
127 |
+
type: information-retrieval
|
128 |
+
name: Information Retrieval
|
129 |
+
dataset:
|
130 |
+
name: dim 768
|
131 |
+
type: dim_768
|
132 |
+
metrics:
|
133 |
+
- type: cosine_accuracy@1
|
134 |
+
value: 0.7694628847314424
|
135 |
+
name: Cosine Accuracy@1
|
136 |
+
- type: cosine_accuracy@3
|
137 |
+
value: 0.8889559444779722
|
138 |
+
name: Cosine Accuracy@3
|
139 |
+
- type: cosine_accuracy@5
|
140 |
+
value: 0.9124924562462281
|
141 |
+
name: Cosine Accuracy@5
|
142 |
+
- type: cosine_accuracy@10
|
143 |
+
value: 0.9330114665057333
|
144 |
+
name: Cosine Accuracy@10
|
145 |
+
- type: cosine_precision@1
|
146 |
+
value: 0.7694628847314424
|
147 |
+
name: Cosine Precision@1
|
148 |
+
- type: cosine_precision@3
|
149 |
+
value: 0.29631864815932407
|
150 |
+
name: Cosine Precision@3
|
151 |
+
- type: cosine_precision@5
|
152 |
+
value: 0.1824984912492456
|
153 |
+
name: Cosine Precision@5
|
154 |
+
- type: cosine_precision@10
|
155 |
+
value: 0.09330114665057332
|
156 |
+
name: Cosine Precision@10
|
157 |
+
- type: cosine_recall@1
|
158 |
+
value: 0.7694628847314424
|
159 |
+
name: Cosine Recall@1
|
160 |
+
- type: cosine_recall@3
|
161 |
+
value: 0.8889559444779722
|
162 |
+
name: Cosine Recall@3
|
163 |
+
- type: cosine_recall@5
|
164 |
+
value: 0.9124924562462281
|
165 |
+
name: Cosine Recall@5
|
166 |
+
- type: cosine_recall@10
|
167 |
+
value: 0.9330114665057333
|
168 |
+
name: Cosine Recall@10
|
169 |
+
- type: cosine_ndcg@10
|
170 |
+
value: 0.8571049923900239
|
171 |
+
name: Cosine Ndcg@10
|
172 |
+
- type: cosine_mrr@10
|
173 |
+
value: 0.8320899311243306
|
174 |
+
name: Cosine Mrr@10
|
175 |
+
- type: cosine_map@100
|
176 |
+
value: 0.8333457816447034
|
177 |
+
name: Cosine Map@100
|
178 |
+
- task:
|
179 |
+
type: information-retrieval
|
180 |
+
name: Information Retrieval
|
181 |
+
dataset:
|
182 |
+
name: dim 512
|
183 |
+
type: dim_512
|
184 |
+
metrics:
|
185 |
+
- type: cosine_accuracy@1
|
186 |
+
value: 0.7682558841279421
|
187 |
+
name: Cosine Accuracy@1
|
188 |
+
- type: cosine_accuracy@3
|
189 |
+
value: 0.8865419432709717
|
190 |
+
name: Cosine Accuracy@3
|
191 |
+
- type: cosine_accuracy@5
|
192 |
+
value: 0.9112854556427278
|
193 |
+
name: Cosine Accuracy@5
|
194 |
+
- type: cosine_accuracy@10
|
195 |
+
value: 0.9305974652987327
|
196 |
+
name: Cosine Accuracy@10
|
197 |
+
- type: cosine_precision@1
|
198 |
+
value: 0.7682558841279421
|
199 |
+
name: Cosine Precision@1
|
200 |
+
- type: cosine_precision@3
|
201 |
+
value: 0.2955139810903239
|
202 |
+
name: Cosine Precision@3
|
203 |
+
- type: cosine_precision@5
|
204 |
+
value: 0.18225709112854557
|
205 |
+
name: Cosine Precision@5
|
206 |
+
- type: cosine_precision@10
|
207 |
+
value: 0.09305974652987326
|
208 |
+
name: Cosine Precision@10
|
209 |
+
- type: cosine_recall@1
|
210 |
+
value: 0.7682558841279421
|
211 |
+
name: Cosine Recall@1
|
212 |
+
- type: cosine_recall@3
|
213 |
+
value: 0.8865419432709717
|
214 |
+
name: Cosine Recall@3
|
215 |
+
- type: cosine_recall@5
|
216 |
+
value: 0.9112854556427278
|
217 |
+
name: Cosine Recall@5
|
218 |
+
- type: cosine_recall@10
|
219 |
+
value: 0.9305974652987327
|
220 |
+
name: Cosine Recall@10
|
221 |
+
- type: cosine_ndcg@10
|
222 |
+
value: 0.8555277012951626
|
223 |
+
name: Cosine Ndcg@10
|
224 |
+
- type: cosine_mrr@10
|
225 |
+
value: 0.8307227155597702
|
226 |
+
name: Cosine Mrr@10
|
227 |
+
- type: cosine_map@100
|
228 |
+
value: 0.8321030396467847
|
229 |
+
name: Cosine Map@100
|
230 |
+
- task:
|
231 |
+
type: information-retrieval
|
232 |
+
name: Information Retrieval
|
233 |
+
dataset:
|
234 |
+
name: dim 256
|
235 |
+
type: dim_256
|
236 |
+
metrics:
|
237 |
+
- type: cosine_accuracy@1
|
238 |
+
value: 0.764031382015691
|
239 |
+
name: Cosine Accuracy@1
|
240 |
+
- type: cosine_accuracy@3
|
241 |
+
value: 0.8901629450814725
|
242 |
+
name: Cosine Accuracy@3
|
243 |
+
- type: cosine_accuracy@5
|
244 |
+
value: 0.9082679541339771
|
245 |
+
name: Cosine Accuracy@5
|
246 |
+
- type: cosine_accuracy@10
|
247 |
+
value: 0.9299939649969825
|
248 |
+
name: Cosine Accuracy@10
|
249 |
+
- type: cosine_precision@1
|
250 |
+
value: 0.764031382015691
|
251 |
+
name: Cosine Precision@1
|
252 |
+
- type: cosine_precision@3
|
253 |
+
value: 0.2967209816938242
|
254 |
+
name: Cosine Precision@3
|
255 |
+
- type: cosine_precision@5
|
256 |
+
value: 0.1816535908267954
|
257 |
+
name: Cosine Precision@5
|
258 |
+
- type: cosine_precision@10
|
259 |
+
value: 0.09299939649969825
|
260 |
+
name: Cosine Precision@10
|
261 |
+
- type: cosine_recall@1
|
262 |
+
value: 0.764031382015691
|
263 |
+
name: Cosine Recall@1
|
264 |
+
- type: cosine_recall@3
|
265 |
+
value: 0.8901629450814725
|
266 |
+
name: Cosine Recall@3
|
267 |
+
- type: cosine_recall@5
|
268 |
+
value: 0.9082679541339771
|
269 |
+
name: Cosine Recall@5
|
270 |
+
- type: cosine_recall@10
|
271 |
+
value: 0.9299939649969825
|
272 |
+
name: Cosine Recall@10
|
273 |
+
- type: cosine_ndcg@10
|
274 |
+
value: 0.8535167149096011
|
275 |
+
name: Cosine Ndcg@10
|
276 |
+
- type: cosine_mrr@10
|
277 |
+
value: 0.8282907530342651
|
278 |
+
name: Cosine Mrr@10
|
279 |
+
- type: cosine_map@100
|
280 |
+
value: 0.8296119986031772
|
281 |
+
name: Cosine Map@100
|
282 |
+
- task:
|
283 |
+
type: information-retrieval
|
284 |
+
name: Information Retrieval
|
285 |
+
dataset:
|
286 |
+
name: dim 128
|
287 |
+
type: dim_128
|
288 |
+
metrics:
|
289 |
+
- type: cosine_accuracy@1
|
290 |
+
value: 0.7447193723596862
|
291 |
+
name: Cosine Accuracy@1
|
292 |
+
- type: cosine_accuracy@3
|
293 |
+
value: 0.8768859384429692
|
294 |
+
name: Cosine Accuracy@3
|
295 |
+
- type: cosine_accuracy@5
|
296 |
+
value: 0.9028364514182257
|
297 |
+
name: Cosine Accuracy@5
|
298 |
+
- type: cosine_accuracy@10
|
299 |
+
value: 0.9215449607724804
|
300 |
+
name: Cosine Accuracy@10
|
301 |
+
- type: cosine_precision@1
|
302 |
+
value: 0.7447193723596862
|
303 |
+
name: Cosine Precision@1
|
304 |
+
- type: cosine_precision@3
|
305 |
+
value: 0.2922953128143231
|
306 |
+
name: Cosine Precision@3
|
307 |
+
- type: cosine_precision@5
|
308 |
+
value: 0.1805672902836451
|
309 |
+
name: Cosine Precision@5
|
310 |
+
- type: cosine_precision@10
|
311 |
+
value: 0.09215449607724803
|
312 |
+
name: Cosine Precision@10
|
313 |
+
- type: cosine_recall@1
|
314 |
+
value: 0.7447193723596862
|
315 |
+
name: Cosine Recall@1
|
316 |
+
- type: cosine_recall@3
|
317 |
+
value: 0.8768859384429692
|
318 |
+
name: Cosine Recall@3
|
319 |
+
- type: cosine_recall@5
|
320 |
+
value: 0.9028364514182257
|
321 |
+
name: Cosine Recall@5
|
322 |
+
- type: cosine_recall@10
|
323 |
+
value: 0.9215449607724804
|
324 |
+
name: Cosine Recall@10
|
325 |
+
- type: cosine_ndcg@10
|
326 |
+
value: 0.8402664516336745
|
327 |
+
name: Cosine Ndcg@10
|
328 |
+
- type: cosine_mrr@10
|
329 |
+
value: 0.8133905221714518
|
330 |
+
name: Cosine Mrr@10
|
331 |
+
- type: cosine_map@100
|
332 |
+
value: 0.8148588407289652
|
333 |
+
name: Cosine Map@100
|
334 |
+
- task:
|
335 |
+
type: information-retrieval
|
336 |
+
name: Information Retrieval
|
337 |
+
dataset:
|
338 |
+
name: dim 64
|
339 |
+
type: dim_64
|
340 |
+
metrics:
|
341 |
+
- type: cosine_accuracy@1
|
342 |
+
value: 0.7103198551599276
|
343 |
+
name: Cosine Accuracy@1
|
344 |
+
- type: cosine_accuracy@3
|
345 |
+
value: 0.8491249245624622
|
346 |
+
name: Cosine Accuracy@3
|
347 |
+
- type: cosine_accuracy@5
|
348 |
+
value: 0.8780929390464696
|
349 |
+
name: Cosine Accuracy@5
|
350 |
+
- type: cosine_accuracy@10
|
351 |
+
value: 0.899818949909475
|
352 |
+
name: Cosine Accuracy@10
|
353 |
+
- type: cosine_precision@1
|
354 |
+
value: 0.7103198551599276
|
355 |
+
name: Cosine Precision@1
|
356 |
+
- type: cosine_precision@3
|
357 |
+
value: 0.2830416415208208
|
358 |
+
name: Cosine Precision@3
|
359 |
+
- type: cosine_precision@5
|
360 |
+
value: 0.1756185878092939
|
361 |
+
name: Cosine Precision@5
|
362 |
+
- type: cosine_precision@10
|
363 |
+
value: 0.08998189499094747
|
364 |
+
name: Cosine Precision@10
|
365 |
+
- type: cosine_recall@1
|
366 |
+
value: 0.7103198551599276
|
367 |
+
name: Cosine Recall@1
|
368 |
+
- type: cosine_recall@3
|
369 |
+
value: 0.8491249245624622
|
370 |
+
name: Cosine Recall@3
|
371 |
+
- type: cosine_recall@5
|
372 |
+
value: 0.8780929390464696
|
373 |
+
name: Cosine Recall@5
|
374 |
+
- type: cosine_recall@10
|
375 |
+
value: 0.899818949909475
|
376 |
+
name: Cosine Recall@10
|
377 |
+
- type: cosine_ndcg@10
|
378 |
+
value: 0.8119294706592789
|
379 |
+
name: Cosine Ndcg@10
|
380 |
+
- type: cosine_mrr@10
|
381 |
+
value: 0.7829293234091058
|
382 |
+
name: Cosine Mrr@10
|
383 |
+
- type: cosine_map@100
|
384 |
+
value: 0.7850878407159746
|
385 |
+
name: Cosine Map@100
|
386 |
+
---
|
387 |
+
|
388 |
+
# Lampistero
|
389 |
+
|
390 |
+
This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [jinaai/jina-embeddings-v3](https://huggingface.co/jinaai/jina-embeddings-v3) on the json dataset. It maps sentences & paragraphs to a 1024-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
|
391 |
+
|
392 |
+
## Model Details
|
393 |
+
|
394 |
+
### Model Description
|
395 |
+
- **Model Type:** Sentence Transformer
|
396 |
+
- **Base model:** [jinaai/jina-embeddings-v3](https://huggingface.co/jinaai/jina-embeddings-v3) <!-- at revision f1944de8402dcd5f2b03f822a4bc22a7f2de2eb9 -->
|
397 |
+
- **Maximum Sequence Length:** 8194 tokens
|
398 |
+
- **Output Dimensionality:** 1024 dimensions
|
399 |
+
- **Similarity Function:** Cosine Similarity
|
400 |
+
- **Training Dataset:**
|
401 |
+
- json
|
402 |
+
- **Language:** es
|
403 |
+
- **License:** apache-2.0
|
404 |
+
|
405 |
+
### Model Sources
|
406 |
+
|
407 |
+
- **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
|
408 |
+
- **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)
|
409 |
+
- **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
|
410 |
+
|
411 |
+
### Full Model Architecture
|
412 |
+
|
413 |
+
```
|
414 |
+
SentenceTransformer(
|
415 |
+
(transformer): Transformer(
|
416 |
+
(auto_model): XLMRobertaLoRA(
|
417 |
+
(roberta): XLMRobertaModel(
|
418 |
+
(embeddings): XLMRobertaEmbeddings(
|
419 |
+
(word_embeddings): ParametrizedEmbedding(
|
420 |
+
250002, 1024, padding_idx=1
|
421 |
+
(parametrizations): ModuleDict(
|
422 |
+
(weight): ParametrizationList(
|
423 |
+
(0): LoRAParametrization()
|
424 |
+
)
|
425 |
+
)
|
426 |
+
)
|
427 |
+
(token_type_embeddings): ParametrizedEmbedding(
|
428 |
+
1, 1024
|
429 |
+
(parametrizations): ModuleDict(
|
430 |
+
(weight): ParametrizationList(
|
431 |
+
(0): LoRAParametrization()
|
432 |
+
)
|
433 |
+
)
|
434 |
+
)
|
435 |
+
)
|
436 |
+
(emb_drop): Dropout(p=0.1, inplace=False)
|
437 |
+
(emb_ln): LayerNorm((1024,), eps=1e-05, elementwise_affine=True)
|
438 |
+
(encoder): XLMRobertaEncoder(
|
439 |
+
(layers): ModuleList(
|
440 |
+
(0-23): 24 x Block(
|
441 |
+
(mixer): MHA(
|
442 |
+
(rotary_emb): RotaryEmbedding()
|
443 |
+
(Wqkv): ParametrizedLinearResidual(
|
444 |
+
in_features=1024, out_features=3072, bias=True
|
445 |
+
(parametrizations): ModuleDict(
|
446 |
+
(weight): ParametrizationList(
|
447 |
+
(0): LoRAParametrization()
|
448 |
+
)
|
449 |
+
)
|
450 |
+
)
|
451 |
+
(inner_attn): FlashSelfAttention(
|
452 |
+
(drop): Dropout(p=0.1, inplace=False)
|
453 |
+
)
|
454 |
+
(inner_cross_attn): FlashCrossAttention(
|
455 |
+
(drop): Dropout(p=0.1, inplace=False)
|
456 |
+
)
|
457 |
+
(out_proj): ParametrizedLinear(
|
458 |
+
in_features=1024, out_features=1024, bias=True
|
459 |
+
(parametrizations): ModuleDict(
|
460 |
+
(weight): ParametrizationList(
|
461 |
+
(0): LoRAParametrization()
|
462 |
+
)
|
463 |
+
)
|
464 |
+
)
|
465 |
+
)
|
466 |
+
(dropout1): Dropout(p=0.1, inplace=False)
|
467 |
+
(drop_path1): StochasticDepth(p=0.0, mode=row)
|
468 |
+
(norm1): LayerNorm((1024,), eps=1e-05, elementwise_affine=True)
|
469 |
+
(mlp): Mlp(
|
470 |
+
(fc1): ParametrizedLinear(
|
471 |
+
in_features=1024, out_features=4096, bias=True
|
472 |
+
(parametrizations): ModuleDict(
|
473 |
+
(weight): ParametrizationList(
|
474 |
+
(0): LoRAParametrization()
|
475 |
+
)
|
476 |
+
)
|
477 |
+
)
|
478 |
+
(fc2): ParametrizedLinear(
|
479 |
+
in_features=4096, out_features=1024, bias=True
|
480 |
+
(parametrizations): ModuleDict(
|
481 |
+
(weight): ParametrizationList(
|
482 |
+
(0): LoRAParametrization()
|
483 |
+
)
|
484 |
+
)
|
485 |
+
)
|
486 |
+
)
|
487 |
+
(dropout2): Dropout(p=0.1, inplace=False)
|
488 |
+
(drop_path2): StochasticDepth(p=0.0, mode=row)
|
489 |
+
(norm2): LayerNorm((1024,), eps=1e-05, elementwise_affine=True)
|
490 |
+
)
|
491 |
+
)
|
492 |
+
)
|
493 |
+
(pooler): XLMRobertaPooler(
|
494 |
+
(dense): ParametrizedLinear(
|
495 |
+
in_features=1024, out_features=1024, bias=True
|
496 |
+
(parametrizations): ModuleDict(
|
497 |
+
(weight): ParametrizationList(
|
498 |
+
(0): LoRAParametrization()
|
499 |
+
)
|
500 |
+
)
|
501 |
+
)
|
502 |
+
(activation): Tanh()
|
503 |
+
)
|
504 |
+
)
|
505 |
+
)
|
506 |
+
)
|
507 |
+
(pooler): Pooling({'word_embedding_dimension': 1024, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
|
508 |
+
(normalizer): Normalize()
|
509 |
+
)
|
510 |
+
```
|
511 |
+
|
512 |
+
## Usage
|
513 |
+
|
514 |
+
### Direct Usage (Sentence Transformers)
|
515 |
+
|
516 |
+
First install the Sentence Transformers library:
|
517 |
+
|
518 |
+
```bash
|
519 |
+
pip install -U sentence-transformers
|
520 |
+
```
|
521 |
+
|
522 |
+
Then you can load this model and run inference.
|
523 |
+
```python
|
524 |
+
from sentence_transformers import SentenceTransformer
|
525 |
+
|
526 |
+
# Download from the 🤗 Hub
|
527 |
+
model = SentenceTransformer("csanz91/lampistero_rag_embeddings_2")
|
528 |
+
# Run inference
|
529 |
+
sentences = [
|
530 |
+
"¿En qué año se demarcó y reconoció la mina 'El Pilar'?",
|
531 |
+
"La mina 'El Pilar' se demarcó y reconoció en 1857.",
|
532 |
+
'Según la quinta demanda del SOMM, todas compañías mineras debían entregar a todos sus obreros un libramiento de liquidación mensual',
|
533 |
+
]
|
534 |
+
embeddings = model.encode(sentences)
|
535 |
+
print(embeddings.shape)
|
536 |
+
# [3, 1024]
|
537 |
+
|
538 |
+
# Get the similarity scores for the embeddings
|
539 |
+
similarities = model.similarity(embeddings, embeddings)
|
540 |
+
print(similarities.shape)
|
541 |
+
# [3, 3]
|
542 |
+
```
|
543 |
+
|
544 |
+
<!--
|
545 |
+
### Direct Usage (Transformers)
|
546 |
+
|
547 |
+
<details><summary>Click to see the direct usage in Transformers</summary>
|
548 |
+
|
549 |
+
</details>
|
550 |
+
-->
|
551 |
+
|
552 |
+
<!--
|
553 |
+
### Downstream Usage (Sentence Transformers)
|
554 |
+
|
555 |
+
You can finetune this model on your own dataset.
|
556 |
+
|
557 |
+
<details><summary>Click to expand</summary>
|
558 |
+
|
559 |
+
</details>
|
560 |
+
-->
|
561 |
+
|
562 |
+
<!--
|
563 |
+
### Out-of-Scope Use
|
564 |
+
|
565 |
+
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
|
566 |
+
-->
|
567 |
+
|
568 |
+
## Evaluation
|
569 |
+
|
570 |
+
### Metrics
|
571 |
+
|
572 |
+
#### Information Retrieval
|
573 |
+
|
574 |
+
* Dataset: `dim_1024`
|
575 |
+
* Evaluated with [<code>InformationRetrievalEvaluator</code>](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.InformationRetrievalEvaluator) with these parameters:
|
576 |
+
```json
|
577 |
+
{
|
578 |
+
"truncate_dim": 1024
|
579 |
+
}
|
580 |
+
```
|
581 |
+
|
582 |
+
| Metric | Value |
|
583 |
+
|:--------------------|:-----------|
|
584 |
+
| cosine_accuracy@1 | 0.7701 |
|
585 |
+
| cosine_accuracy@3 | 0.8926 |
|
586 |
+
| cosine_accuracy@5 | 0.9155 |
|
587 |
+
| cosine_accuracy@10 | 0.933 |
|
588 |
+
| cosine_precision@1 | 0.7701 |
|
589 |
+
| cosine_precision@3 | 0.2975 |
|
590 |
+
| cosine_precision@5 | 0.1831 |
|
591 |
+
| cosine_precision@10 | 0.0933 |
|
592 |
+
| cosine_recall@1 | 0.7701 |
|
593 |
+
| cosine_recall@3 | 0.8926 |
|
594 |
+
| cosine_recall@5 | 0.9155 |
|
595 |
+
| cosine_recall@10 | 0.933 |
|
596 |
+
| **cosine_ndcg@10** | **0.8579** |
|
597 |
+
| cosine_mrr@10 | 0.8331 |
|
598 |
+
| cosine_map@100 | 0.8343 |
|
599 |
+
|
600 |
+
#### Information Retrieval
|
601 |
+
|
602 |
+
* Dataset: `dim_768`
|
603 |
+
* Evaluated with [<code>InformationRetrievalEvaluator</code>](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.InformationRetrievalEvaluator) with these parameters:
|
604 |
+
```json
|
605 |
+
{
|
606 |
+
"truncate_dim": 768
|
607 |
+
}
|
608 |
+
```
|
609 |
+
|
610 |
+
| Metric | Value |
|
611 |
+
|:--------------------|:-----------|
|
612 |
+
| cosine_accuracy@1 | 0.7695 |
|
613 |
+
| cosine_accuracy@3 | 0.889 |
|
614 |
+
| cosine_accuracy@5 | 0.9125 |
|
615 |
+
| cosine_accuracy@10 | 0.933 |
|
616 |
+
| cosine_precision@1 | 0.7695 |
|
617 |
+
| cosine_precision@3 | 0.2963 |
|
618 |
+
| cosine_precision@5 | 0.1825 |
|
619 |
+
| cosine_precision@10 | 0.0933 |
|
620 |
+
| cosine_recall@1 | 0.7695 |
|
621 |
+
| cosine_recall@3 | 0.889 |
|
622 |
+
| cosine_recall@5 | 0.9125 |
|
623 |
+
| cosine_recall@10 | 0.933 |
|
624 |
+
| **cosine_ndcg@10** | **0.8571** |
|
625 |
+
| cosine_mrr@10 | 0.8321 |
|
626 |
+
| cosine_map@100 | 0.8333 |
|
627 |
+
|
628 |
+
#### Information Retrieval
|
629 |
+
|
630 |
+
* Dataset: `dim_512`
|
631 |
+
* Evaluated with [<code>InformationRetrievalEvaluator</code>](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.InformationRetrievalEvaluator) with these parameters:
|
632 |
+
```json
|
633 |
+
{
|
634 |
+
"truncate_dim": 512
|
635 |
+
}
|
636 |
+
```
|
637 |
+
|
638 |
+
| Metric | Value |
|
639 |
+
|:--------------------|:-----------|
|
640 |
+
| cosine_accuracy@1 | 0.7683 |
|
641 |
+
| cosine_accuracy@3 | 0.8865 |
|
642 |
+
| cosine_accuracy@5 | 0.9113 |
|
643 |
+
| cosine_accuracy@10 | 0.9306 |
|
644 |
+
| cosine_precision@1 | 0.7683 |
|
645 |
+
| cosine_precision@3 | 0.2955 |
|
646 |
+
| cosine_precision@5 | 0.1823 |
|
647 |
+
| cosine_precision@10 | 0.0931 |
|
648 |
+
| cosine_recall@1 | 0.7683 |
|
649 |
+
| cosine_recall@3 | 0.8865 |
|
650 |
+
| cosine_recall@5 | 0.9113 |
|
651 |
+
| cosine_recall@10 | 0.9306 |
|
652 |
+
| **cosine_ndcg@10** | **0.8555** |
|
653 |
+
| cosine_mrr@10 | 0.8307 |
|
654 |
+
| cosine_map@100 | 0.8321 |
|
655 |
+
|
656 |
+
#### Information Retrieval
|
657 |
+
|
658 |
+
* Dataset: `dim_256`
|
659 |
+
* Evaluated with [<code>InformationRetrievalEvaluator</code>](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.InformationRetrievalEvaluator) with these parameters:
|
660 |
+
```json
|
661 |
+
{
|
662 |
+
"truncate_dim": 256
|
663 |
+
}
|
664 |
+
```
|
665 |
+
|
666 |
+
| Metric | Value |
|
667 |
+
|:--------------------|:-----------|
|
668 |
+
| cosine_accuracy@1 | 0.764 |
|
669 |
+
| cosine_accuracy@3 | 0.8902 |
|
670 |
+
| cosine_accuracy@5 | 0.9083 |
|
671 |
+
| cosine_accuracy@10 | 0.93 |
|
672 |
+
| cosine_precision@1 | 0.764 |
|
673 |
+
| cosine_precision@3 | 0.2967 |
|
674 |
+
| cosine_precision@5 | 0.1817 |
|
675 |
+
| cosine_precision@10 | 0.093 |
|
676 |
+
| cosine_recall@1 | 0.764 |
|
677 |
+
| cosine_recall@3 | 0.8902 |
|
678 |
+
| cosine_recall@5 | 0.9083 |
|
679 |
+
| cosine_recall@10 | 0.93 |
|
680 |
+
| **cosine_ndcg@10** | **0.8535** |
|
681 |
+
| cosine_mrr@10 | 0.8283 |
|
682 |
+
| cosine_map@100 | 0.8296 |
|
683 |
+
|
684 |
+
#### Information Retrieval
|
685 |
+
|
686 |
+
* Dataset: `dim_128`
|
687 |
+
* Evaluated with [<code>InformationRetrievalEvaluator</code>](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.InformationRetrievalEvaluator) with these parameters:
|
688 |
+
```json
|
689 |
+
{
|
690 |
+
"truncate_dim": 128
|
691 |
+
}
|
692 |
+
```
|
693 |
+
|
694 |
+
| Metric | Value |
|
695 |
+
|:--------------------|:-----------|
|
696 |
+
| cosine_accuracy@1 | 0.7447 |
|
697 |
+
| cosine_accuracy@3 | 0.8769 |
|
698 |
+
| cosine_accuracy@5 | 0.9028 |
|
699 |
+
| cosine_accuracy@10 | 0.9215 |
|
700 |
+
| cosine_precision@1 | 0.7447 |
|
701 |
+
| cosine_precision@3 | 0.2923 |
|
702 |
+
| cosine_precision@5 | 0.1806 |
|
703 |
+
| cosine_precision@10 | 0.0922 |
|
704 |
+
| cosine_recall@1 | 0.7447 |
|
705 |
+
| cosine_recall@3 | 0.8769 |
|
706 |
+
| cosine_recall@5 | 0.9028 |
|
707 |
+
| cosine_recall@10 | 0.9215 |
|
708 |
+
| **cosine_ndcg@10** | **0.8403** |
|
709 |
+
| cosine_mrr@10 | 0.8134 |
|
710 |
+
| cosine_map@100 | 0.8149 |
|
711 |
+
|
712 |
+
#### Information Retrieval
|
713 |
+
|
714 |
+
* Dataset: `dim_64`
|
715 |
+
* Evaluated with [<code>InformationRetrievalEvaluator</code>](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.InformationRetrievalEvaluator) with these parameters:
|
716 |
+
```json
|
717 |
+
{
|
718 |
+
"truncate_dim": 64
|
719 |
+
}
|
720 |
+
```
|
721 |
+
|
722 |
+
| Metric | Value |
|
723 |
+
|:--------------------|:-----------|
|
724 |
+
| cosine_accuracy@1 | 0.7103 |
|
725 |
+
| cosine_accuracy@3 | 0.8491 |
|
726 |
+
| cosine_accuracy@5 | 0.8781 |
|
727 |
+
| cosine_accuracy@10 | 0.8998 |
|
728 |
+
| cosine_precision@1 | 0.7103 |
|
729 |
+
| cosine_precision@3 | 0.283 |
|
730 |
+
| cosine_precision@5 | 0.1756 |
|
731 |
+
| cosine_precision@10 | 0.09 |
|
732 |
+
| cosine_recall@1 | 0.7103 |
|
733 |
+
| cosine_recall@3 | 0.8491 |
|
734 |
+
| cosine_recall@5 | 0.8781 |
|
735 |
+
| cosine_recall@10 | 0.8998 |
|
736 |
+
| **cosine_ndcg@10** | **0.8119** |
|
737 |
+
| cosine_mrr@10 | 0.7829 |
|
738 |
+
| cosine_map@100 | 0.7851 |
|
739 |
+
|
740 |
+
<!--
|
741 |
+
## Bias, Risks and Limitations
|
742 |
+
|
743 |
+
*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
|
744 |
+
-->
|
745 |
+
|
746 |
+
<!--
|
747 |
+
### Recommendations
|
748 |
+
|
749 |
+
*What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
|
750 |
+
-->
|
751 |
+
|
752 |
+
## Training Details
|
753 |
+
|
754 |
+
### Training Dataset
|
755 |
+
|
756 |
+
#### json
|
757 |
+
|
758 |
+
* Dataset: json
|
759 |
+
* Size: 14,907 training samples
|
760 |
+
* Columns: <code>query</code> and <code>answer</code>
|
761 |
+
* Approximate statistics based on the first 1000 samples:
|
762 |
+
| | query | answer |
|
763 |
+
|:--------|:----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|
|
764 |
+
| type | string | string |
|
765 |
+
| details | <ul><li>min: 9 tokens</li><li>mean: 26.09 tokens</li><li>max: 66 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 34.02 tokens</li><li>max: 405 tokens</li></ul> |
|
766 |
+
* Samples:
|
767 |
+
| query | answer |
|
768 |
+
|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
769 |
+
| <code>¿Qué tipos de palas se utilizan para cargar el carbón y el mineral?</code> | <code>Se utiliza una pala convencional y una pala hidráulica, esta última descarga sobre un páncer, puede hacerlo lateralmente y se desplaza sobre ruedas u oruga.</code> |
|
770 |
+
| <code>Tras el cierre de la tejería de Florencio Salvador, ¿de dónde procedieron finalmente los ladrillos para las doscientas diez viviendas construidas en Utrillas?</code> | <code>Los ladrillos y material para las doscientas diez viviendas construidas en Utrillas procedieron finalmente de Letux, Zaragoza .</code> |
|
771 |
+
| <code>¿Cuál es el formato de los juegos infantiles que se están preparando para el verano en Escucha en 2021?</code> | <code>Los juegos infantiles que se están preparando para el verano en Escucha en 2021 están en formato revista.</code> |
|
772 |
+
* Loss: [<code>MatryoshkaLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#matryoshkaloss) with these parameters:
|
773 |
+
```json
|
774 |
+
{
|
775 |
+
"loss": "MultipleNegativesRankingLoss",
|
776 |
+
"matryoshka_dims": [
|
777 |
+
1024,
|
778 |
+
768,
|
779 |
+
512,
|
780 |
+
256,
|
781 |
+
128,
|
782 |
+
64
|
783 |
+
],
|
784 |
+
"matryoshka_weights": [
|
785 |
+
1,
|
786 |
+
1,
|
787 |
+
1,
|
788 |
+
1,
|
789 |
+
1,
|
790 |
+
1
|
791 |
+
],
|
792 |
+
"n_dims_per_step": -1
|
793 |
+
}
|
794 |
+
```
|
795 |
+
|
796 |
+
### Training Hyperparameters
|
797 |
+
#### Non-Default Hyperparameters
|
798 |
+
|
799 |
+
- `eval_strategy`: epoch
|
800 |
+
- `per_device_train_batch_size`: 64
|
801 |
+
- `per_device_eval_batch_size`: 16
|
802 |
+
- `gradient_accumulation_steps`: 32
|
803 |
+
- `learning_rate`: 2e-05
|
804 |
+
- `num_train_epochs`: 8
|
805 |
+
- `lr_scheduler_type`: cosine
|
806 |
+
- `warmup_ratio`: 0.1
|
807 |
+
- `tf32`: True
|
808 |
+
- `load_best_model_at_end`: True
|
809 |
+
- `optim`: adamw_torch_fused
|
810 |
+
- `batch_sampler`: no_duplicates
|
811 |
+
|
812 |
+
#### All Hyperparameters
|
813 |
+
<details><summary>Click to expand</summary>
|
814 |
+
|
815 |
+
- `overwrite_output_dir`: False
|
816 |
+
- `do_predict`: False
|
817 |
+
- `eval_strategy`: epoch
|
818 |
+
- `prediction_loss_only`: True
|
819 |
+
- `per_device_train_batch_size`: 64
|
820 |
+
- `per_device_eval_batch_size`: 16
|
821 |
+
- `per_gpu_train_batch_size`: None
|
822 |
+
- `per_gpu_eval_batch_size`: None
|
823 |
+
- `gradient_accumulation_steps`: 32
|
824 |
+
- `eval_accumulation_steps`: None
|
825 |
+
- `torch_empty_cache_steps`: None
|
826 |
+
- `learning_rate`: 2e-05
|
827 |
+
- `weight_decay`: 0.0
|
828 |
+
- `adam_beta1`: 0.9
|
829 |
+
- `adam_beta2`: 0.999
|
830 |
+
- `adam_epsilon`: 1e-08
|
831 |
+
- `max_grad_norm`: 1.0
|
832 |
+
- `num_train_epochs`: 8
|
833 |
+
- `max_steps`: -1
|
834 |
+
- `lr_scheduler_type`: cosine
|
835 |
+
- `lr_scheduler_kwargs`: {}
|
836 |
+
- `warmup_ratio`: 0.1
|
837 |
+
- `warmup_steps`: 0
|
838 |
+
- `log_level`: passive
|
839 |
+
- `log_level_replica`: warning
|
840 |
+
- `log_on_each_node`: True
|
841 |
+
- `logging_nan_inf_filter`: True
|
842 |
+
- `save_safetensors`: True
|
843 |
+
- `save_on_each_node`: False
|
844 |
+
- `save_only_model`: False
|
845 |
+
- `restore_callback_states_from_checkpoint`: False
|
846 |
+
- `no_cuda`: False
|
847 |
+
- `use_cpu`: False
|
848 |
+
- `use_mps_device`: False
|
849 |
+
- `seed`: 42
|
850 |
+
- `data_seed`: None
|
851 |
+
- `jit_mode_eval`: False
|
852 |
+
- `use_ipex`: False
|
853 |
+
- `bf16`: False
|
854 |
+
- `fp16`: False
|
855 |
+
- `fp16_opt_level`: O1
|
856 |
+
- `half_precision_backend`: auto
|
857 |
+
- `bf16_full_eval`: False
|
858 |
+
- `fp16_full_eval`: False
|
859 |
+
- `tf32`: True
|
860 |
+
- `local_rank`: 0
|
861 |
+
- `ddp_backend`: None
|
862 |
+
- `tpu_num_cores`: None
|
863 |
+
- `tpu_metrics_debug`: False
|
864 |
+
- `debug`: []
|
865 |
+
- `dataloader_drop_last`: False
|
866 |
+
- `dataloader_num_workers`: 0
|
867 |
+
- `dataloader_prefetch_factor`: None
|
868 |
+
- `past_index`: -1
|
869 |
+
- `disable_tqdm`: False
|
870 |
+
- `remove_unused_columns`: True
|
871 |
+
- `label_names`: None
|
872 |
+
- `load_best_model_at_end`: True
|
873 |
+
- `ignore_data_skip`: False
|
874 |
+
- `fsdp`: []
|
875 |
+
- `fsdp_min_num_params`: 0
|
876 |
+
- `fsdp_config`: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
|
877 |
+
- `tp_size`: 0
|
878 |
+
- `fsdp_transformer_layer_cls_to_wrap`: None
|
879 |
+
- `accelerator_config`: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
|
880 |
+
- `deepspeed`: None
|
881 |
+
- `label_smoothing_factor`: 0.0
|
882 |
+
- `optim`: adamw_torch_fused
|
883 |
+
- `optim_args`: None
|
884 |
+
- `adafactor`: False
|
885 |
+
- `group_by_length`: False
|
886 |
+
- `length_column_name`: length
|
887 |
+
- `ddp_find_unused_parameters`: None
|
888 |
+
- `ddp_bucket_cap_mb`: None
|
889 |
+
- `ddp_broadcast_buffers`: False
|
890 |
+
- `dataloader_pin_memory`: True
|
891 |
+
- `dataloader_persistent_workers`: False
|
892 |
+
- `skip_memory_metrics`: True
|
893 |
+
- `use_legacy_prediction_loop`: False
|
894 |
+
- `push_to_hub`: False
|
895 |
+
- `resume_from_checkpoint`: None
|
896 |
+
- `hub_model_id`: None
|
897 |
+
- `hub_strategy`: every_save
|
898 |
+
- `hub_private_repo`: None
|
899 |
+
- `hub_always_push`: False
|
900 |
+
- `gradient_checkpointing`: False
|
901 |
+
- `gradient_checkpointing_kwargs`: None
|
902 |
+
- `include_inputs_for_metrics`: False
|
903 |
+
- `include_for_metrics`: []
|
904 |
+
- `eval_do_concat_batches`: True
|
905 |
+
- `fp16_backend`: auto
|
906 |
+
- `push_to_hub_model_id`: None
|
907 |
+
- `push_to_hub_organization`: None
|
908 |
+
- `mp_parameters`:
|
909 |
+
- `auto_find_batch_size`: False
|
910 |
+
- `full_determinism`: False
|
911 |
+
- `torchdynamo`: None
|
912 |
+
- `ray_scope`: last
|
913 |
+
- `ddp_timeout`: 1800
|
914 |
+
- `torch_compile`: False
|
915 |
+
- `torch_compile_backend`: None
|
916 |
+
- `torch_compile_mode`: None
|
917 |
+
- `include_tokens_per_second`: False
|
918 |
+
- `include_num_input_tokens_seen`: False
|
919 |
+
- `neftune_noise_alpha`: None
|
920 |
+
- `optim_target_modules`: None
|
921 |
+
- `batch_eval_metrics`: False
|
922 |
+
- `eval_on_start`: False
|
923 |
+
- `use_liger_kernel`: False
|
924 |
+
- `eval_use_gather_object`: False
|
925 |
+
- `average_tokens_across_devices`: False
|
926 |
+
- `prompts`: None
|
927 |
+
- `batch_sampler`: no_duplicates
|
928 |
+
- `multi_dataset_batch_sampler`: proportional
|
929 |
+
|
930 |
+
</details>
|
931 |
+
|
932 |
+
### Training Logs
|
933 |
+
| Epoch | Step | Training Loss | dim_1024_cosine_ndcg@10 | dim_768_cosine_ndcg@10 | dim_512_cosine_ndcg@10 | dim_256_cosine_ndcg@10 | dim_128_cosine_ndcg@10 | dim_64_cosine_ndcg@10 |
|
934 |
+
|:------:|:----:|:-------------:|:-----------------------:|:----------------------:|:----------------------:|:----------------------:|:----------------------:|:---------------------:|
|
935 |
+
| 1.0 | 8 | - | 0.7841 | 0.7835 | 0.7836 | 0.7791 | 0.7665 | 0.7226 |
|
936 |
+
| 1.2747 | 10 | 58.1187 | - | - | - | - | - | - |
|
937 |
+
| 2.0 | 16 | - | 0.8348 | 0.8366 | 0.8345 | 0.8301 | 0.8184 | 0.7861 |
|
938 |
+
| 2.5494 | 20 | 24.4181 | - | - | - | - | - | - |
|
939 |
+
| 3.0 | 24 | - | 0.8521 | 0.8504 | 0.8503 | 0.8457 | 0.8319 | 0.8007 |
|
940 |
+
| 3.8240 | 30 | 16.1488 | - | - | - | - | - | - |
|
941 |
+
| 4.0 | 32 | - | 0.8561 | 0.8548 | 0.8555 | 0.8509 | 0.8387 | 0.8073 |
|
942 |
+
| 5.0 | 40 | 13.4897 | 0.8585 | 0.8556 | 0.8545 | 0.8528 | 0.8397 | 0.8111 |
|
943 |
+
| 6.0 | 48 | - | 0.8578 | 0.8563 | 0.8550 | 0.8535 | 0.8410 | 0.8110 |
|
944 |
+
| 6.2747 | 50 | 13.7469 | - | - | - | - | - | - |
|
945 |
+
| 7.0 | 56 | - | 0.8579 | 0.8571 | 0.8555 | 0.8535 | 0.8403 | 0.8119 |
|
946 |
+
|
947 |
+
|
948 |
+
### Framework Versions
|
949 |
+
- Python: 3.12.10
|
950 |
+
- Sentence Transformers: 4.1.0
|
951 |
+
- Transformers: 4.51.3
|
952 |
+
- PyTorch: 2.7.0+cu126
|
953 |
+
- Accelerate: 1.7.0
|
954 |
+
- Datasets: 3.6.0
|
955 |
+
- Tokenizers: 0.21.1
|
956 |
+
|
957 |
+
## Citation
|
958 |
+
|
959 |
+
### BibTeX
|
960 |
+
|
961 |
+
#### Sentence Transformers
|
962 |
+
```bibtex
|
963 |
+
@inproceedings{reimers-2019-sentence-bert,
|
964 |
+
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
|
965 |
+
author = "Reimers, Nils and Gurevych, Iryna",
|
966 |
+
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
|
967 |
+
month = "11",
|
968 |
+
year = "2019",
|
969 |
+
publisher = "Association for Computational Linguistics",
|
970 |
+
url = "https://arxiv.org/abs/1908.10084",
|
971 |
+
}
|
972 |
+
```
|
973 |
+
|
974 |
+
#### MatryoshkaLoss
|
975 |
+
```bibtex
|
976 |
+
@misc{kusupati2024matryoshka,
|
977 |
+
title={Matryoshka Representation Learning},
|
978 |
+
author={Aditya Kusupati and Gantavya Bhatt and Aniket Rege and Matthew Wallingford and Aditya Sinha and Vivek Ramanujan and William Howard-Snyder and Kaifeng Chen and Sham Kakade and Prateek Jain and Ali Farhadi},
|
979 |
+
year={2024},
|
980 |
+
eprint={2205.13147},
|
981 |
+
archivePrefix={arXiv},
|
982 |
+
primaryClass={cs.LG}
|
983 |
+
}
|
984 |
+
```
|
985 |
+
|
986 |
+
#### MultipleNegativesRankingLoss
|
987 |
+
```bibtex
|
988 |
+
@misc{henderson2017efficient,
|
989 |
+
title={Efficient Natural Language Response Suggestion for Smart Reply},
|
990 |
+
author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
|
991 |
+
year={2017},
|
992 |
+
eprint={1705.00652},
|
993 |
+
archivePrefix={arXiv},
|
994 |
+
primaryClass={cs.CL}
|
995 |
+
}
|
996 |
+
```
|
997 |
+
|
998 |
+
<!--
|
999 |
+
## Glossary
|
1000 |
+
|
1001 |
+
*Clearly define terms in order to be accessible across audiences.*
|
1002 |
+
-->
|
1003 |
+
|
1004 |
+
<!--
|
1005 |
+
## Model Card Authors
|
1006 |
+
|
1007 |
+
*Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
|
1008 |
+
-->
|
1009 |
+
|
1010 |
+
<!--
|
1011 |
+
## Model Card Contact
|
1012 |
+
|
1013 |
+
*Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
|
1014 |
+
-->
|
config.json
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"XLMRobertaLoRA"
|
4 |
+
],
|
5 |
+
"attention_probs_dropout_prob": 0.1,
|
6 |
+
"auto_map": {
|
7 |
+
"AutoConfig": "jinaai/xlm-roberta-flash-implementation--configuration_xlm_roberta.XLMRobertaFlashConfig",
|
8 |
+
"AutoModel": "jinaai/xlm-roberta-flash-implementation--modeling_lora.XLMRobertaLoRA",
|
9 |
+
"AutoModelForMaskedLM": "jinaai/xlm-roberta-flash-implementation--modeling_xlm_roberta.XLMRobertaForMaskedLM",
|
10 |
+
"AutoModelForPreTraining": "jinaai/xlm-roberta-flash-implementation--modeling_xlm_roberta.XLMRobertaForPreTraining"
|
11 |
+
},
|
12 |
+
"bos_token_id": 0,
|
13 |
+
"classifier_dropout": null,
|
14 |
+
"emb_pooler": null,
|
15 |
+
"eos_token_id": 2,
|
16 |
+
"hidden_act": "gelu",
|
17 |
+
"hidden_dropout_prob": 0.1,
|
18 |
+
"hidden_size": 1024,
|
19 |
+
"initializer_range": 0.02,
|
20 |
+
"intermediate_size": 4096,
|
21 |
+
"layer_norm_eps": 1e-05,
|
22 |
+
"load_trained_adapters": true,
|
23 |
+
"lora_adaptations": [
|
24 |
+
"retrieval.query",
|
25 |
+
"retrieval.passage",
|
26 |
+
"separation",
|
27 |
+
"classification",
|
28 |
+
"text-matching"
|
29 |
+
],
|
30 |
+
"lora_alpha": 1,
|
31 |
+
"lora_dropout_p": 0.0,
|
32 |
+
"lora_main_params_trainable": true,
|
33 |
+
"lora_rank": 4,
|
34 |
+
"matryoshka_dimensions": [
|
35 |
+
32,
|
36 |
+
64,
|
37 |
+
128,
|
38 |
+
256,
|
39 |
+
512,
|
40 |
+
768,
|
41 |
+
1024
|
42 |
+
],
|
43 |
+
"max_position_embeddings": 8194,
|
44 |
+
"model_type": "xlm-roberta",
|
45 |
+
"num_attention_heads": 16,
|
46 |
+
"num_hidden_layers": 24,
|
47 |
+
"output_past": true,
|
48 |
+
"pad_token_id": 1,
|
49 |
+
"position_embedding_type": "rotary",
|
50 |
+
"rotary_emb_base": 20000.0,
|
51 |
+
"task_instructions": {
|
52 |
+
"classification": "",
|
53 |
+
"retrieval.passage": "Represent the document for retrieval: ",
|
54 |
+
"retrieval.query": "Represent the query for retrieving evidence documents: ",
|
55 |
+
"separation": "",
|
56 |
+
"text-matching": ""
|
57 |
+
},
|
58 |
+
"torch_dtype": "bfloat16",
|
59 |
+
"transformers_version": "4.51.3",
|
60 |
+
"truncate_dim": null,
|
61 |
+
"type_vocab_size": 1,
|
62 |
+
"use_cache": true,
|
63 |
+
"use_flash_attn": true,
|
64 |
+
"use_reentrant": false,
|
65 |
+
"vocab_size": 250002
|
66 |
+
}
|
config_sentence_transformers.json
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"__version__": {
|
3 |
+
"sentence_transformers": "4.1.0",
|
4 |
+
"transformers": "4.51.3",
|
5 |
+
"pytorch": "2.7.0+cu126"
|
6 |
+
},
|
7 |
+
"prompts": {
|
8 |
+
"retrieval.query": "Represent the query for retrieving evidence documents: ",
|
9 |
+
"retrieval.passage": "Represent the document for retrieval: ",
|
10 |
+
"separation": "",
|
11 |
+
"classification": "",
|
12 |
+
"text-matching": ""
|
13 |
+
},
|
14 |
+
"default_prompt_name": null,
|
15 |
+
"similarity_fn_name": "cosine"
|
16 |
+
}
|
custom_st.py
ADDED
@@ -0,0 +1,229 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import logging
|
3 |
+
import os
|
4 |
+
from io import BytesIO
|
5 |
+
from typing import Any, Dict, List, Optional, Tuple, Union
|
6 |
+
|
7 |
+
import torch
|
8 |
+
from torch import nn
|
9 |
+
from transformers import AutoConfig, AutoModel, AutoTokenizer
|
10 |
+
|
11 |
+
logger = logging.getLogger(__name__)
|
12 |
+
|
13 |
+
|
14 |
+
class Transformer(nn.Module):
|
15 |
+
"""Huggingface AutoModel to generate token embeddings.
|
16 |
+
Loads the correct class, e.g. BERT / RoBERTa etc.
|
17 |
+
|
18 |
+
Args:
|
19 |
+
model_name_or_path: Huggingface models name
|
20 |
+
(https://huggingface.co/models)
|
21 |
+
max_seq_length: Truncate any inputs longer than max_seq_length
|
22 |
+
model_args: Keyword arguments passed to the Huggingface
|
23 |
+
Transformers model
|
24 |
+
tokenizer_args: Keyword arguments passed to the Huggingface
|
25 |
+
Transformers tokenizer
|
26 |
+
config_args: Keyword arguments passed to the Huggingface
|
27 |
+
Transformers config
|
28 |
+
cache_dir: Cache dir for Huggingface Transformers to store/load
|
29 |
+
models
|
30 |
+
do_lower_case: If true, lowercases the input (independent if the
|
31 |
+
model is cased or not)
|
32 |
+
tokenizer_name_or_path: Name or path of the tokenizer. When
|
33 |
+
None, then model_name_or_path is used
|
34 |
+
"""
|
35 |
+
|
36 |
+
save_in_root: bool = True
|
37 |
+
|
38 |
+
def __init__(
|
39 |
+
self,
|
40 |
+
model_name_or_path: str,
|
41 |
+
max_seq_length: int = None,
|
42 |
+
model_args: Dict[str, Any] = None,
|
43 |
+
tokenizer_args: Dict[str, Any] = None,
|
44 |
+
config_args: Dict[str, Any] = None,
|
45 |
+
cache_dir: str = None,
|
46 |
+
do_lower_case: bool = False,
|
47 |
+
tokenizer_name_or_path: str = None,
|
48 |
+
**kwargs,
|
49 |
+
) -> None:
|
50 |
+
super().__init__()
|
51 |
+
self.config_keys = ["max_seq_length", "do_lower_case"]
|
52 |
+
self.do_lower_case = do_lower_case
|
53 |
+
if model_args is None:
|
54 |
+
model_args = {}
|
55 |
+
if tokenizer_args is None:
|
56 |
+
tokenizer_args = {}
|
57 |
+
if config_args is None:
|
58 |
+
config_args = {}
|
59 |
+
|
60 |
+
if kwargs.get("backend", "torch") != "torch":
|
61 |
+
logger.warning(
|
62 |
+
f'"jinaai/jina-embeddings-v3" is currently not compatible with the {kwargs["backend"]} backend. '
|
63 |
+
'Continuing with the "torch" backend.'
|
64 |
+
)
|
65 |
+
|
66 |
+
self.config = AutoConfig.from_pretrained(model_name_or_path, **config_args, cache_dir=cache_dir)
|
67 |
+
|
68 |
+
self._lora_adaptations = self.config.lora_adaptations
|
69 |
+
if (
|
70 |
+
not isinstance(self._lora_adaptations, list)
|
71 |
+
or len(self._lora_adaptations) < 1
|
72 |
+
):
|
73 |
+
raise ValueError(
|
74 |
+
f"`lora_adaptations` must be a list and contain at least one element"
|
75 |
+
)
|
76 |
+
self._adaptation_map = {
|
77 |
+
name: idx for idx, name in enumerate(self._lora_adaptations)
|
78 |
+
}
|
79 |
+
|
80 |
+
self.default_task = model_args.pop('default_task', None)
|
81 |
+
|
82 |
+
self.auto_model = AutoModel.from_pretrained(model_name_or_path, config=self.config, cache_dir=cache_dir, **model_args)
|
83 |
+
|
84 |
+
if max_seq_length is not None and "model_max_length" not in tokenizer_args:
|
85 |
+
tokenizer_args["model_max_length"] = max_seq_length
|
86 |
+
self.tokenizer = AutoTokenizer.from_pretrained(
|
87 |
+
tokenizer_name_or_path if tokenizer_name_or_path is not None else model_name_or_path,
|
88 |
+
cache_dir=cache_dir,
|
89 |
+
**tokenizer_args,
|
90 |
+
)
|
91 |
+
|
92 |
+
# No max_seq_length set. Try to infer from model
|
93 |
+
if max_seq_length is None:
|
94 |
+
if (
|
95 |
+
hasattr(self.auto_model, "config")
|
96 |
+
and hasattr(self.auto_model.config, "max_position_embeddings")
|
97 |
+
and hasattr(self.tokenizer, "model_max_length")
|
98 |
+
):
|
99 |
+
max_seq_length = min(self.auto_model.config.max_position_embeddings, self.tokenizer.model_max_length)
|
100 |
+
|
101 |
+
self.max_seq_length = max_seq_length
|
102 |
+
|
103 |
+
if tokenizer_name_or_path is not None:
|
104 |
+
self.auto_model.config.tokenizer_class = self.tokenizer.__class__.__name__
|
105 |
+
|
106 |
+
|
107 |
+
@property
|
108 |
+
def default_task(self):
|
109 |
+
return self._default_task
|
110 |
+
|
111 |
+
@default_task.setter
|
112 |
+
def default_task(self, task: Union[None, str]):
|
113 |
+
self._validate_task(task)
|
114 |
+
self._default_task = task
|
115 |
+
|
116 |
+
|
117 |
+
def _validate_task(self, task: str):
|
118 |
+
if task and task not in self._lora_adaptations:
|
119 |
+
raise ValueError(
|
120 |
+
f"Unsupported task '{task}'. "
|
121 |
+
f"Supported tasks are: {', '.join(self.config.lora_adaptations)}. "
|
122 |
+
f"Alternatively, don't pass the `task` argument to disable LoRA."
|
123 |
+
)
|
124 |
+
|
125 |
+
def forward(
|
126 |
+
self, features: Dict[str, torch.Tensor], task: Optional[str] = None
|
127 |
+
) -> Dict[str, torch.Tensor]:
|
128 |
+
"""Returns token_embeddings, cls_token"""
|
129 |
+
self._validate_task(task)
|
130 |
+
task = task or self.default_task
|
131 |
+
adapter_mask = None
|
132 |
+
if task:
|
133 |
+
task_id = self._adaptation_map[task]
|
134 |
+
num_examples = features['input_ids'].size(0)
|
135 |
+
adapter_mask = torch.full(
|
136 |
+
(num_examples,), task_id, dtype=torch.int32, device=features['input_ids'].device
|
137 |
+
)
|
138 |
+
|
139 |
+
lora_arguments = (
|
140 |
+
{"adapter_mask": adapter_mask} if adapter_mask is not None else {}
|
141 |
+
)
|
142 |
+
features.pop('prompt_length', None)
|
143 |
+
output_states = self.auto_model.forward(**features, **lora_arguments, return_dict=False)
|
144 |
+
output_tokens = output_states[0]
|
145 |
+
features.update({"token_embeddings": output_tokens, "attention_mask": features["attention_mask"]})
|
146 |
+
return features
|
147 |
+
|
148 |
+
def get_word_embedding_dimension(self) -> int:
|
149 |
+
return self.auto_model.config.hidden_size
|
150 |
+
|
151 |
+
def tokenize(
|
152 |
+
self,
|
153 |
+
texts: Union[List[str], List[dict], List[Tuple[str, str]]],
|
154 |
+
padding: Union[str, bool] = True
|
155 |
+
) -> Dict[str, torch.Tensor]:
|
156 |
+
"""Tokenizes a text and maps tokens to token-ids"""
|
157 |
+
output = {}
|
158 |
+
if isinstance(texts[0], str):
|
159 |
+
to_tokenize = [texts]
|
160 |
+
elif isinstance(texts[0], dict):
|
161 |
+
to_tokenize = []
|
162 |
+
output["text_keys"] = []
|
163 |
+
for lookup in texts:
|
164 |
+
text_key, text = next(iter(lookup.items()))
|
165 |
+
to_tokenize.append(text)
|
166 |
+
output["text_keys"].append(text_key)
|
167 |
+
to_tokenize = [to_tokenize]
|
168 |
+
else:
|
169 |
+
batch1, batch2 = [], []
|
170 |
+
for text_tuple in texts:
|
171 |
+
batch1.append(text_tuple[0])
|
172 |
+
batch2.append(text_tuple[1])
|
173 |
+
to_tokenize = [batch1, batch2]
|
174 |
+
|
175 |
+
# strip
|
176 |
+
to_tokenize = [[str(s).strip() for s in col] for col in to_tokenize]
|
177 |
+
|
178 |
+
# Lowercase
|
179 |
+
if self.do_lower_case:
|
180 |
+
to_tokenize = [[s.lower() for s in col] for col in to_tokenize]
|
181 |
+
|
182 |
+
output.update(
|
183 |
+
self.tokenizer(
|
184 |
+
*to_tokenize,
|
185 |
+
padding=padding,
|
186 |
+
truncation="longest_first",
|
187 |
+
return_tensors="pt",
|
188 |
+
max_length=self.max_seq_length,
|
189 |
+
)
|
190 |
+
)
|
191 |
+
return output
|
192 |
+
|
193 |
+
def get_config_dict(self) -> Dict[str, Any]:
|
194 |
+
return {key: self.__dict__[key] for key in self.config_keys}
|
195 |
+
|
196 |
+
def save(self, output_path: str, safe_serialization: bool = True) -> None:
|
197 |
+
self.auto_model.save_pretrained(output_path, safe_serialization=safe_serialization)
|
198 |
+
self.tokenizer.save_pretrained(output_path)
|
199 |
+
|
200 |
+
with open(os.path.join(output_path, "sentence_bert_config.json"), "w") as fOut:
|
201 |
+
json.dump(self.get_config_dict(), fOut, indent=2)
|
202 |
+
|
203 |
+
|
204 |
+
@classmethod
|
205 |
+
def load(cls, input_path: str) -> "Transformer":
|
206 |
+
# Old classes used other config names than 'sentence_bert_config.json'
|
207 |
+
for config_name in [
|
208 |
+
"sentence_bert_config.json",
|
209 |
+
"sentence_roberta_config.json",
|
210 |
+
"sentence_distilbert_config.json",
|
211 |
+
"sentence_camembert_config.json",
|
212 |
+
"sentence_albert_config.json",
|
213 |
+
"sentence_xlm-roberta_config.json",
|
214 |
+
"sentence_xlnet_config.json",
|
215 |
+
]:
|
216 |
+
sbert_config_path = os.path.join(input_path, config_name)
|
217 |
+
if os.path.exists(sbert_config_path):
|
218 |
+
break
|
219 |
+
|
220 |
+
with open(sbert_config_path) as fIn:
|
221 |
+
config = json.load(fIn)
|
222 |
+
# Don't allow configs to set trust_remote_code
|
223 |
+
if "model_args" in config and "trust_remote_code" in config["model_args"]:
|
224 |
+
config["model_args"].pop("trust_remote_code")
|
225 |
+
if "tokenizer_args" in config and "trust_remote_code" in config["tokenizer_args"]:
|
226 |
+
config["tokenizer_args"].pop("trust_remote_code")
|
227 |
+
if "config_args" in config and "trust_remote_code" in config["config_args"]:
|
228 |
+
config["config_args"].pop("trust_remote_code")
|
229 |
+
return cls(model_name_or_path=input_path, **config)
|
model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8c4fbad75813236b810c797155a99953e13fc2afc30e1172f0983da5cf1167dc
|
3 |
+
size 1144685320
|
modules.json
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[
|
2 |
+
{
|
3 |
+
"idx": 0,
|
4 |
+
"name": "transformer",
|
5 |
+
"path": "",
|
6 |
+
"type": "custom_st.Transformer",
|
7 |
+
"kwargs": [
|
8 |
+
"task"
|
9 |
+
]
|
10 |
+
},
|
11 |
+
{
|
12 |
+
"idx": 1,
|
13 |
+
"name": "pooler",
|
14 |
+
"path": "1_Pooling",
|
15 |
+
"type": "sentence_transformers.models.Pooling"
|
16 |
+
},
|
17 |
+
{
|
18 |
+
"idx": 2,
|
19 |
+
"name": "normalizer",
|
20 |
+
"path": "2_Normalize",
|
21 |
+
"type": "sentence_transformers.models.Normalize"
|
22 |
+
}
|
23 |
+
]
|
sentence_bert_config.json
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"max_seq_length": 8194,
|
3 |
+
"do_lower_case": false
|
4 |
+
}
|
special_tokens_map.json
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": {
|
3 |
+
"content": "<s>",
|
4 |
+
"lstrip": false,
|
5 |
+
"normalized": false,
|
6 |
+
"rstrip": false,
|
7 |
+
"single_word": false
|
8 |
+
},
|
9 |
+
"cls_token": {
|
10 |
+
"content": "<s>",
|
11 |
+
"lstrip": false,
|
12 |
+
"normalized": false,
|
13 |
+
"rstrip": false,
|
14 |
+
"single_word": false
|
15 |
+
},
|
16 |
+
"eos_token": {
|
17 |
+
"content": "</s>",
|
18 |
+
"lstrip": false,
|
19 |
+
"normalized": false,
|
20 |
+
"rstrip": false,
|
21 |
+
"single_word": false
|
22 |
+
},
|
23 |
+
"mask_token": {
|
24 |
+
"content": "<mask>",
|
25 |
+
"lstrip": true,
|
26 |
+
"normalized": false,
|
27 |
+
"rstrip": false,
|
28 |
+
"single_word": false
|
29 |
+
},
|
30 |
+
"pad_token": {
|
31 |
+
"content": "<pad>",
|
32 |
+
"lstrip": false,
|
33 |
+
"normalized": false,
|
34 |
+
"rstrip": false,
|
35 |
+
"single_word": false
|
36 |
+
},
|
37 |
+
"sep_token": {
|
38 |
+
"content": "</s>",
|
39 |
+
"lstrip": false,
|
40 |
+
"normalized": false,
|
41 |
+
"rstrip": false,
|
42 |
+
"single_word": false
|
43 |
+
},
|
44 |
+
"unk_token": {
|
45 |
+
"content": "<unk>",
|
46 |
+
"lstrip": false,
|
47 |
+
"normalized": false,
|
48 |
+
"rstrip": false,
|
49 |
+
"single_word": false
|
50 |
+
}
|
51 |
+
}
|
tokenizer.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3e19cd8c08f528b481e909f73dbd1fd62b1e8b1117579ba205e477801237f9e0
|
3 |
+
size 17082988
|
tokenizer_config.json
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"added_tokens_decoder": {
|
3 |
+
"0": {
|
4 |
+
"content": "<s>",
|
5 |
+
"lstrip": false,
|
6 |
+
"normalized": false,
|
7 |
+
"rstrip": false,
|
8 |
+
"single_word": false,
|
9 |
+
"special": true
|
10 |
+
},
|
11 |
+
"1": {
|
12 |
+
"content": "<pad>",
|
13 |
+
"lstrip": false,
|
14 |
+
"normalized": false,
|
15 |
+
"rstrip": false,
|
16 |
+
"single_word": false,
|
17 |
+
"special": true
|
18 |
+
},
|
19 |
+
"2": {
|
20 |
+
"content": "</s>",
|
21 |
+
"lstrip": false,
|
22 |
+
"normalized": false,
|
23 |
+
"rstrip": false,
|
24 |
+
"single_word": false,
|
25 |
+
"special": true
|
26 |
+
},
|
27 |
+
"3": {
|
28 |
+
"content": "<unk>",
|
29 |
+
"lstrip": false,
|
30 |
+
"normalized": false,
|
31 |
+
"rstrip": false,
|
32 |
+
"single_word": false,
|
33 |
+
"special": true
|
34 |
+
},
|
35 |
+
"250001": {
|
36 |
+
"content": "<mask>",
|
37 |
+
"lstrip": true,
|
38 |
+
"normalized": false,
|
39 |
+
"rstrip": false,
|
40 |
+
"single_word": false,
|
41 |
+
"special": true
|
42 |
+
}
|
43 |
+
},
|
44 |
+
"bos_token": "<s>",
|
45 |
+
"clean_up_tokenization_spaces": true,
|
46 |
+
"cls_token": "<s>",
|
47 |
+
"eos_token": "</s>",
|
48 |
+
"extra_special_tokens": {},
|
49 |
+
"mask_token": "<mask>",
|
50 |
+
"model_max_length": 8194,
|
51 |
+
"pad_token": "<pad>",
|
52 |
+
"sep_token": "</s>",
|
53 |
+
"tokenizer_class": "XLMRobertaTokenizerFast",
|
54 |
+
"unk_token": "<unk>"
|
55 |
+
}
|