Update README.md
Browse files
README.md
CHANGED
@@ -15,28 +15,22 @@ widget:
|
|
15 |
- source_sentence: الرجل يركب حصاناً
|
16 |
sentences:
|
17 |
- رجل يُبث الجبن الممزق على البيتزا
|
18 |
-
- ar-ar
|
19 |
-
- رجل يركب حصاناً
|
20 |
- source_sentence: المرأة تقلي لحم خنزير مشوي
|
21 |
sentences:
|
22 |
-
- ar-ar
|
23 |
- امرأة تطبخ لحم خنزير مخبوز
|
24 |
- طائرة طيران تقلع
|
25 |
- source_sentence: امرأة تحمل في ذراعها طفل كنغر
|
26 |
sentences:
|
27 |
- امرأة تعزف على الغيتار
|
28 |
-
- ar-ar
|
29 |
- امرأة تحمل و تحمل طفل كنغر
|
30 |
- source_sentence: رجل يعزف على الناي
|
31 |
sentences:
|
32 |
- طائرة ستقلع
|
33 |
-
- ar-ar
|
34 |
- رجل يعزف على فرقة الخيزران
|
35 |
- source_sentence: ثلاثة رجال يلعبون الشطرنج.
|
36 |
sentences:
|
37 |
- رجلين يلعبان الشطرنج
|
38 |
- بعض الرجال يقاتلون
|
39 |
-
- ar-ar
|
40 |
datasets:
|
41 |
- silma-ai/silma-arabic-english-sts-dataset-v1.0
|
42 |
pipeline_tag: sentence-similarity
|
@@ -44,583 +38,260 @@ library_name: sentence-transformers
|
|
44 |
metrics:
|
45 |
- pearson_cosine
|
46 |
- spearman_cosine
|
47 |
-
model-index:
|
48 |
-
- name: SentenceTransformer based on AhmedZaky1/DIMI-embedding-v2
|
49 |
-
results:
|
50 |
-
- task:
|
51 |
-
type: semantic-similarity
|
52 |
-
name: Semantic Similarity
|
53 |
-
dataset:
|
54 |
-
name: silma sts dev 768
|
55 |
-
type: silma-sts-dev-768
|
56 |
-
metrics:
|
57 |
-
- type: pearson_cosine
|
58 |
-
value: 0.8894298077237747
|
59 |
-
name: Pearson Cosine
|
60 |
-
- type: spearman_cosine
|
61 |
-
value: 0.8357984695231979
|
62 |
-
name: Spearman Cosine
|
63 |
-
- task:
|
64 |
-
type: semantic-similarity
|
65 |
-
name: Semantic Similarity
|
66 |
-
dataset:
|
67 |
-
name: silma sts dev 512
|
68 |
-
type: silma-sts-dev-512
|
69 |
-
metrics:
|
70 |
-
- type: pearson_cosine
|
71 |
-
value: 0.8958835653694187
|
72 |
-
name: Pearson Cosine
|
73 |
-
- type: spearman_cosine
|
74 |
-
value: 0.8394578198917563
|
75 |
-
name: Spearman Cosine
|
76 |
-
- task:
|
77 |
-
type: semantic-similarity
|
78 |
-
name: Semantic Similarity
|
79 |
-
dataset:
|
80 |
-
name: silma sts dev 256
|
81 |
-
type: silma-sts-dev-256
|
82 |
-
metrics:
|
83 |
-
- type: pearson_cosine
|
84 |
-
value: 0.9078743376141943
|
85 |
-
name: Pearson Cosine
|
86 |
-
- type: spearman_cosine
|
87 |
-
value: 0.8470163055535588
|
88 |
-
name: Spearman Cosine
|
89 |
-
- task:
|
90 |
-
type: semantic-similarity
|
91 |
-
name: Semantic Similarity
|
92 |
-
dataset:
|
93 |
-
name: silma sts dev 128
|
94 |
-
type: silma-sts-dev-128
|
95 |
-
metrics:
|
96 |
-
- type: pearson_cosine
|
97 |
-
value: 0.9181556833949818
|
98 |
-
name: Pearson Cosine
|
99 |
-
- type: spearman_cosine
|
100 |
-
value: 0.856188415278301
|
101 |
-
name: Spearman Cosine
|
102 |
-
- task:
|
103 |
-
type: semantic-similarity
|
104 |
-
name: Semantic Similarity
|
105 |
-
dataset:
|
106 |
-
name: silma sts dev 64
|
107 |
-
type: silma-sts-dev-64
|
108 |
-
metrics:
|
109 |
-
- type: pearson_cosine
|
110 |
-
value: 0.9066219844975816
|
111 |
-
name: Pearson Cosine
|
112 |
-
- type: spearman_cosine
|
113 |
-
value: 0.8434430083292863
|
114 |
-
name: Spearman Cosine
|
115 |
-
- task:
|
116 |
-
type: semantic-similarity
|
117 |
-
name: Semantic Similarity
|
118 |
-
dataset:
|
119 |
-
name: sts17 ar test 768
|
120 |
-
type: sts17-ar-test-768
|
121 |
-
metrics:
|
122 |
-
- type: pearson_cosine
|
123 |
-
value: 0.8205269118955641
|
124 |
-
name: Pearson Cosine
|
125 |
-
- type: spearman_cosine
|
126 |
-
value: 0.8258003312254673
|
127 |
-
name: Spearman Cosine
|
128 |
-
- task:
|
129 |
-
type: semantic-similarity
|
130 |
-
name: Semantic Similarity
|
131 |
-
dataset:
|
132 |
-
name: sts17 ar test 512
|
133 |
-
type: sts17-ar-test-512
|
134 |
-
metrics:
|
135 |
-
- type: pearson_cosine
|
136 |
-
value: 0.8193403796404517
|
137 |
-
name: Pearson Cosine
|
138 |
-
- type: spearman_cosine
|
139 |
-
value: 0.8226611918447921
|
140 |
-
name: Spearman Cosine
|
141 |
-
- task:
|
142 |
-
type: semantic-similarity
|
143 |
-
name: Semantic Similarity
|
144 |
-
dataset:
|
145 |
-
name: sts17 ar test 256
|
146 |
-
type: sts17-ar-test-256
|
147 |
-
metrics:
|
148 |
-
- type: pearson_cosine
|
149 |
-
value: 0.8190666923783347
|
150 |
-
name: Pearson Cosine
|
151 |
-
- type: spearman_cosine
|
152 |
-
value: 0.8245760514866052
|
153 |
-
name: Spearman Cosine
|
154 |
-
- task:
|
155 |
-
type: semantic-similarity
|
156 |
-
name: Semantic Similarity
|
157 |
-
dataset:
|
158 |
-
name: sts17 ar test 128
|
159 |
-
type: sts17-ar-test-128
|
160 |
-
metrics:
|
161 |
-
- type: pearson_cosine
|
162 |
-
value: 0.8114629254813825
|
163 |
-
name: Pearson Cosine
|
164 |
-
- type: spearman_cosine
|
165 |
-
value: 0.8183273799928091
|
166 |
-
name: Spearman Cosine
|
167 |
-
- task:
|
168 |
-
type: semantic-similarity
|
169 |
-
name: Semantic Similarity
|
170 |
-
dataset:
|
171 |
-
name: sts17 ar test 64
|
172 |
-
type: sts17-ar-test-64
|
173 |
-
metrics:
|
174 |
-
- type: pearson_cosine
|
175 |
-
value: 0.796172574267003
|
176 |
-
name: Pearson Cosine
|
177 |
-
- type: spearman_cosine
|
178 |
-
value: 0.8077141358495715
|
179 |
-
name: Spearman Cosine
|
180 |
---
|
181 |
|
182 |
-
# SentenceTransformer based on AhmedZaky1/DIMI-embedding-v2
|
183 |
|
184 |
-
|
185 |
|
186 |
-
|
187 |
|
188 |
-
|
189 |
-
- **Model Type:** Sentence Transformer
|
190 |
-
- **Base model:** [AhmedZaky1/DIMI-embedding-v2](https://huggingface.co/AhmedZaky1/DIMI-embedding-v2) <!-- at revision d4a6e4faaea9d9a2ad374fea48b093946166e753 -->
|
191 |
-
- **Maximum Sequence Length:** 8192 tokens
|
192 |
-
- **Output Dimensionality:** 768 dimensions
|
193 |
-
- **Similarity Function:** Cosine Similarity
|
194 |
-
- **Training Dataset:**
|
195 |
-
- [silma-arabic-english-sts-dataset-v1.0](https://huggingface.co/datasets/silma-ai/silma-arabic-english-sts-dataset-v1.0)
|
196 |
-
- **Languages:** ar, en
|
197 |
-
<!-- - **License:** Unknown -->
|
198 |
|
199 |
-
|
200 |
|
201 |
-
-
|
202 |
-
- **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)
|
203 |
-
- **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
|
204 |
|
205 |
-
|
|
|
|
|
206 |
|
207 |
-
|
208 |
-
SentenceTransformer(
|
209 |
-
(0): Transformer({'max_seq_length': 8192, 'do_lower_case': False}) with Transformer model: NewModel
|
210 |
-
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
|
211 |
-
(2): Normalize()
|
212 |
-
)
|
213 |
-
```
|
214 |
|
215 |
-
##
|
216 |
|
217 |
-
|
218 |
|
219 |
-
|
220 |
|
221 |
-
|
222 |
-
|
223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
|
225 |
-
Then you can load this model and run inference.
|
226 |
```python
|
227 |
from sentence_transformers import SentenceTransformer
|
228 |
|
229 |
-
#
|
230 |
-
model = SentenceTransformer(
|
231 |
-
|
|
|
232 |
sentences = [
|
233 |
-
|
234 |
-
|
235 |
-
|
|
|
236 |
]
|
|
|
|
|
237 |
embeddings = model.encode(sentences)
|
238 |
-
print(embeddings.shape)
|
239 |
-
# [3, 768]
|
240 |
|
241 |
-
#
|
242 |
-
|
243 |
-
|
244 |
-
|
|
|
245 |
```
|
246 |
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
</details>
|
263 |
-
-->
|
264 |
-
|
265 |
-
<!--
|
266 |
-
### Out-of-Scope Use
|
267 |
-
|
268 |
-
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
|
269 |
-
-->
|
270 |
-
|
271 |
-
## Evaluation
|
272 |
-
|
273 |
-
### Metrics
|
274 |
-
|
275 |
-
#### Semantic Similarity
|
276 |
-
|
277 |
-
* Datasets: `silma-sts-dev-768`, `silma-sts-dev-512`, `silma-sts-dev-256`, `silma-sts-dev-128`, `silma-sts-dev-64`, `sts17-ar-test-768`, `sts17-ar-test-512`, `sts17-ar-test-256`, `sts17-ar-test-128` and `sts17-ar-test-64`
|
278 |
-
* Evaluated with [<code>EmbeddingSimilarityEvaluator</code>](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.EmbeddingSimilarityEvaluator)
|
279 |
-
|
280 |
-
| Metric | silma-sts-dev-768 | silma-sts-dev-512 | silma-sts-dev-256 | silma-sts-dev-128 | silma-sts-dev-64 | sts17-ar-test-768 | sts17-ar-test-512 | sts17-ar-test-256 | sts17-ar-test-128 | sts17-ar-test-64 |
|
281 |
-
|:--------------------|:------------------|:------------------|:------------------|:------------------|:-----------------|:------------------|:------------------|:------------------|:------------------|:-----------------|
|
282 |
-
| pearson_cosine | 0.8894 | 0.8959 | 0.9079 | 0.9182 | 0.9066 | 0.8205 | 0.8193 | 0.8191 | 0.8115 | 0.7962 |
|
283 |
-
| **spearman_cosine** | **0.8358** | **0.8395** | **0.847** | **0.8562** | **0.8434** | **0.8258** | **0.8227** | **0.8246** | **0.8183** | **0.8077** |
|
284 |
-
|
285 |
-
<!--
|
286 |
-
## Bias, Risks and Limitations
|
287 |
-
|
288 |
-
*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
|
289 |
-
-->
|
290 |
-
|
291 |
-
<!--
|
292 |
-
### Recommendations
|
293 |
-
|
294 |
-
*What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
|
295 |
-
-->
|
296 |
-
|
297 |
-
## Training Details
|
298 |
-
|
299 |
-
### Training Dataset
|
300 |
-
|
301 |
-
#### silma-arabic-english-sts-dataset-v1.0
|
302 |
-
|
303 |
-
* Dataset: [silma-arabic-english-sts-dataset-v1.0](https://huggingface.co/datasets/silma-ai/silma-arabic-english-sts-dataset-v1.0) at [1885690](https://huggingface.co/datasets/silma-ai/silma-arabic-english-sts-dataset-v1.0/tree/18856908c58bc3779ad089ec327093c8761d2523)
|
304 |
-
* Size: 34,436 training samples
|
305 |
-
* Columns: <code>sentence1</code>, <code>sentence2</code>, <code>score</code>, and <code>langs</code>
|
306 |
-
* Approximate statistics based on the first 1000 samples:
|
307 |
-
| | sentence1 | sentence2 | score | langs |
|
308 |
-
|:--------|:---------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:---------------------------------------------------------------|:-------------------------------------------------------------------------------|
|
309 |
-
| type | string | string | float | string |
|
310 |
-
| details | <ul><li>min: 4 tokens</li><li>mean: 9.68 tokens</li><li>max: 26 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 9.68 tokens</li><li>max: 26 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.47</li><li>max: 1.0</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 5.0 tokens</li><li>max: 5 tokens</li></ul> |
|
311 |
-
* Samples:
|
312 |
-
| sentence1 | sentence2 | score | langs |
|
313 |
-
|:-----------------------------------|:-----------------------------------|:-----------------|:-------------------|
|
314 |
-
| <code>رجل يعزف على البيانو</code> | <code>امرأة تعزف على الكمان</code> | <code>0.2</code> | <code>ar-ar</code> |
|
315 |
-
| <code>امرأة تعزف على الكمان</code> | <code>رجل يعزف على البيانو</code> | <code>0.2</code> | <code>ar-ar</code> |
|
316 |
-
| <code>امرأة تعزف على الناي.</code> | <code>رجل يعزف على الغيتار</code> | <code>0.2</code> | <code>ar-ar</code> |
|
317 |
-
* Loss: [<code>MatryoshkaLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#matryoshkaloss) with these parameters:
|
318 |
-
```json
|
319 |
-
{
|
320 |
-
"loss": "CoSENTLoss",
|
321 |
-
"matryoshka_dims": [
|
322 |
-
768,
|
323 |
-
512,
|
324 |
-
256,
|
325 |
-
128,
|
326 |
-
64
|
327 |
-
],
|
328 |
-
"matryoshka_weights": [
|
329 |
-
1,
|
330 |
-
1,
|
331 |
-
1,
|
332 |
-
1,
|
333 |
-
1
|
334 |
-
],
|
335 |
-
"n_dims_per_step": -1
|
336 |
-
}
|
337 |
-
```
|
338 |
-
|
339 |
-
### Evaluation Dataset
|
340 |
-
|
341 |
-
#### silma-arabic-english-sts-dataset-v1.0
|
342 |
-
|
343 |
-
* Dataset: [silma-arabic-english-sts-dataset-v1.0](https://huggingface.co/datasets/silma-ai/silma-arabic-english-sts-dataset-v1.0) at [1885690](https://huggingface.co/datasets/silma-ai/silma-arabic-english-sts-dataset-v1.0/tree/18856908c58bc3779ad089ec327093c8761d2523)
|
344 |
-
* Size: 100 evaluation samples
|
345 |
-
* Columns: <code>sentence1</code>, <code>sentence2</code>, <code>score</code>, and <code>langs</code>
|
346 |
-
* Approximate statistics based on the first 100 samples:
|
347 |
-
| | sentence1 | sentence2 | score | langs |
|
348 |
-
|:--------|:---------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:---------------------------------------------------------------|:-------------------------------------------------------------------------------|
|
349 |
-
| type | string | string | float | string |
|
350 |
-
| details | <ul><li>min: 5 tokens</li><li>mean: 9.49 tokens</li><li>max: 19 tokens</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 9.49 tokens</li><li>max: 19 tokens</li></ul> | <ul><li>min: 0.1</li><li>mean: 0.74</li><li>max: 1.0</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 5.0 tokens</li><li>max: 5 tokens</li></ul> |
|
351 |
-
* Samples:
|
352 |
-
| sentence1 | sentence2 | score | langs |
|
353 |
-
|:-----------------------------------|:--------------------------------|:------------------|:-------------------|
|
354 |
-
| <code>طائرة ستقلع</code> | <code>طائرة طيران تقلع</code> | <code>1.0</code> | <code>ar-ar</code> |
|
355 |
-
| <code>طائرة طيران تقلع</code> | <code>طائرة ستقلع</code> | <code>1.0</code> | <code>ar-ar</code> |
|
356 |
-
| <code>رجل يعزف على ناي كبير</code> | <code>رجل يعزف على الناي</code> | <code>0.76</code> | <code>ar-ar</code> |
|
357 |
-
* Loss: [<code>MatryoshkaLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#matryoshkaloss) with these parameters:
|
358 |
-
```json
|
359 |
-
{
|
360 |
-
"loss": "CoSENTLoss",
|
361 |
-
"matryoshka_dims": [
|
362 |
-
768,
|
363 |
-
512,
|
364 |
-
256,
|
365 |
-
128,
|
366 |
-
64
|
367 |
-
],
|
368 |
-
"matryoshka_weights": [
|
369 |
-
1,
|
370 |
-
1,
|
371 |
-
1,
|
372 |
-
1,
|
373 |
-
1
|
374 |
-
],
|
375 |
-
"n_dims_per_step": -1
|
376 |
-
}
|
377 |
-
```
|
378 |
-
|
379 |
-
### Training Hyperparameters
|
380 |
-
#### Non-Default Hyperparameters
|
381 |
-
|
382 |
-
- `eval_strategy`: steps
|
383 |
-
- `per_device_train_batch_size`: 16
|
384 |
-
- `per_device_eval_batch_size`: 16
|
385 |
-
- `num_train_epochs`: 4
|
386 |
-
- `warmup_ratio`: 0.1
|
387 |
-
- `save_only_model`: True
|
388 |
-
- `fp16`: True
|
389 |
-
- `load_best_model_at_end`: True
|
390 |
-
|
391 |
-
#### All Hyperparameters
|
392 |
-
<details><summary>Click to expand</summary>
|
393 |
-
|
394 |
-
- `overwrite_output_dir`: False
|
395 |
-
- `do_predict`: False
|
396 |
-
- `eval_strategy`: steps
|
397 |
-
- `prediction_loss_only`: True
|
398 |
-
- `per_device_train_batch_size`: 16
|
399 |
-
- `per_device_eval_batch_size`: 16
|
400 |
-
- `per_gpu_train_batch_size`: None
|
401 |
-
- `per_gpu_eval_batch_size`: None
|
402 |
-
- `gradient_accumulation_steps`: 1
|
403 |
-
- `eval_accumulation_steps`: None
|
404 |
-
- `torch_empty_cache_steps`: None
|
405 |
-
- `learning_rate`: 5e-05
|
406 |
-
- `weight_decay`: 0.0
|
407 |
-
- `adam_beta1`: 0.9
|
408 |
-
- `adam_beta2`: 0.999
|
409 |
-
- `adam_epsilon`: 1e-08
|
410 |
-
- `max_grad_norm`: 1.0
|
411 |
-
- `num_train_epochs`: 4
|
412 |
-
- `max_steps`: -1
|
413 |
-
- `lr_scheduler_type`: linear
|
414 |
-
- `lr_scheduler_kwargs`: {}
|
415 |
-
- `warmup_ratio`: 0.1
|
416 |
-
- `warmup_steps`: 0
|
417 |
-
- `log_level`: passive
|
418 |
-
- `log_level_replica`: warning
|
419 |
-
- `log_on_each_node`: True
|
420 |
-
- `logging_nan_inf_filter`: True
|
421 |
-
- `save_safetensors`: True
|
422 |
-
- `save_on_each_node`: False
|
423 |
-
- `save_only_model`: True
|
424 |
-
- `restore_callback_states_from_checkpoint`: False
|
425 |
-
- `no_cuda`: False
|
426 |
-
- `use_cpu`: False
|
427 |
-
- `use_mps_device`: False
|
428 |
-
- `seed`: 42
|
429 |
-
- `data_seed`: None
|
430 |
-
- `jit_mode_eval`: False
|
431 |
-
- `use_ipex`: False
|
432 |
-
- `bf16`: False
|
433 |
-
- `fp16`: True
|
434 |
-
- `fp16_opt_level`: O1
|
435 |
-
- `half_precision_backend`: auto
|
436 |
-
- `bf16_full_eval`: False
|
437 |
-
- `fp16_full_eval`: False
|
438 |
-
- `tf32`: None
|
439 |
-
- `local_rank`: 0
|
440 |
-
- `ddp_backend`: None
|
441 |
-
- `tpu_num_cores`: None
|
442 |
-
- `tpu_metrics_debug`: False
|
443 |
-
- `debug`: []
|
444 |
-
- `dataloader_drop_last`: False
|
445 |
-
- `dataloader_num_workers`: 0
|
446 |
-
- `dataloader_prefetch_factor`: None
|
447 |
-
- `past_index`: -1
|
448 |
-
- `disable_tqdm`: False
|
449 |
-
- `remove_unused_columns`: True
|
450 |
-
- `label_names`: None
|
451 |
-
- `load_best_model_at_end`: True
|
452 |
-
- `ignore_data_skip`: False
|
453 |
-
- `fsdp`: []
|
454 |
-
- `fsdp_min_num_params`: 0
|
455 |
-
- `fsdp_config`: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
|
456 |
-
- `tp_size`: 0
|
457 |
-
- `fsdp_transformer_layer_cls_to_wrap`: None
|
458 |
-
- `accelerator_config`: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
|
459 |
-
- `deepspeed`: None
|
460 |
-
- `label_smoothing_factor`: 0.0
|
461 |
-
- `optim`: adamw_torch
|
462 |
-
- `optim_args`: None
|
463 |
-
- `adafactor`: False
|
464 |
-
- `group_by_length`: False
|
465 |
-
- `length_column_name`: length
|
466 |
-
- `ddp_find_unused_parameters`: None
|
467 |
-
- `ddp_bucket_cap_mb`: None
|
468 |
-
- `ddp_broadcast_buffers`: False
|
469 |
-
- `dataloader_pin_memory`: True
|
470 |
-
- `dataloader_persistent_workers`: False
|
471 |
-
- `skip_memory_metrics`: True
|
472 |
-
- `use_legacy_prediction_loop`: False
|
473 |
-
- `push_to_hub`: False
|
474 |
-
- `resume_from_checkpoint`: None
|
475 |
-
- `hub_model_id`: None
|
476 |
-
- `hub_strategy`: every_save
|
477 |
-
- `hub_private_repo`: None
|
478 |
-
- `hub_always_push`: False
|
479 |
-
- `gradient_checkpointing`: False
|
480 |
-
- `gradient_checkpointing_kwargs`: None
|
481 |
-
- `include_inputs_for_metrics`: False
|
482 |
-
- `include_for_metrics`: []
|
483 |
-
- `eval_do_concat_batches`: True
|
484 |
-
- `fp16_backend`: auto
|
485 |
-
- `push_to_hub_model_id`: None
|
486 |
-
- `push_to_hub_organization`: None
|
487 |
-
- `mp_parameters`:
|
488 |
-
- `auto_find_batch_size`: False
|
489 |
-
- `full_determinism`: False
|
490 |
-
- `torchdynamo`: None
|
491 |
-
- `ray_scope`: last
|
492 |
-
- `ddp_timeout`: 1800
|
493 |
-
- `torch_compile`: False
|
494 |
-
- `torch_compile_backend`: None
|
495 |
-
- `torch_compile_mode`: None
|
496 |
-
- `include_tokens_per_second`: False
|
497 |
-
- `include_num_input_tokens_seen`: False
|
498 |
-
- `neftune_noise_alpha`: None
|
499 |
-
- `optim_target_modules`: None
|
500 |
-
- `batch_eval_metrics`: False
|
501 |
-
- `eval_on_start`: False
|
502 |
-
- `use_liger_kernel`: False
|
503 |
-
- `eval_use_gather_object`: False
|
504 |
-
- `average_tokens_across_devices`: False
|
505 |
-
- `prompts`: None
|
506 |
-
- `batch_sampler`: batch_sampler
|
507 |
-
- `multi_dataset_batch_sampler`: proportional
|
508 |
-
|
509 |
-
</details>
|
510 |
-
|
511 |
-
### Training Logs
|
512 |
-
| Epoch | Step | Training Loss | Validation Loss | silma-sts-dev-768_spearman_cosine | silma-sts-dev-512_spearman_cosine | silma-sts-dev-256_spearman_cosine | silma-sts-dev-128_spearman_cosine | silma-sts-dev-64_spearman_cosine | sts17-ar-test-768_spearman_cosine | sts17-ar-test-512_spearman_cosine | sts17-ar-test-256_spearman_cosine | sts17-ar-test-128_spearman_cosine | sts17-ar-test-64_spearman_cosine |
|
513 |
-
|:----------:|:--------:|:-------------:|:---------------:|:---------------------------------:|:---------------------------------:|:---------------------------------:|:---------------------------------:|:--------------------------------:|:---------------------------------:|:---------------------------------:|:---------------------------------:|:---------------------------------:|:--------------------------------:|
|
514 |
-
| 0.0929 | 100 | 39.5796 | 45.0982 | 0.7199 | 0.7173 | 0.7292 | 0.7433 | 0.7196 | - | - | - | - | - |
|
515 |
-
| 0.1857 | 200 | 31.3305 | 29.9877 | 0.7233 | 0.7248 | 0.7344 | 0.7337 | 0.7192 | - | - | - | - | - |
|
516 |
-
| 0.2786 | 300 | 27.7756 | 31.4644 | 0.7288 | 0.7268 | 0.7331 | 0.7388 | 0.7169 | - | - | - | - | - |
|
517 |
-
| 0.3714 | 400 | 27.7405 | 33.3315 | 0.7172 | 0.7168 | 0.7341 | 0.7349 | 0.7219 | - | - | - | - | - |
|
518 |
-
| 0.4643 | 500 | 27.1884 | 30.4957 | 0.7469 | 0.7428 | 0.7475 | 0.7547 | 0.7426 | - | - | - | - | - |
|
519 |
-
| 0.5571 | 600 | 27.0428 | 29.5877 | 0.7133 | 0.7138 | 0.7380 | 0.7549 | 0.7533 | - | - | - | - | - |
|
520 |
-
| 0.6500 | 700 | 26.7957 | 30.3813 | 0.7520 | 0.7430 | 0.7570 | 0.7604 | 0.7647 | - | - | - | - | - |
|
521 |
-
| 0.7428 | 800 | 26.2667 | 30.6293 | 0.7323 | 0.7333 | 0.7558 | 0.7609 | 0.7479 | - | - | - | - | - |
|
522 |
-
| 0.8357 | 900 | 25.9412 | 29.8621 | 0.7730 | 0.7732 | 0.7913 | 0.8117 | 0.7797 | - | - | - | - | - |
|
523 |
-
| 0.9285 | 1000 | 25.7816 | 31.7315 | 0.7856 | 0.7918 | 0.7916 | 0.8025 | 0.8048 | - | - | - | - | - |
|
524 |
-
| 1.0214 | 1100 | 25.1666 | 31.6311 | 0.7651 | 0.7668 | 0.7673 | 0.7826 | 0.7846 | - | - | - | - | - |
|
525 |
-
| 1.1142 | 1200 | 24.7681 | 32.3005 | 0.7719 | 0.7892 | 0.7941 | 0.8022 | 0.7939 | - | - | - | - | - |
|
526 |
-
| 1.2071 | 1300 | 24.8771 | 32.1761 | 0.7660 | 0.7744 | 0.7807 | 0.7884 | 0.7841 | - | - | - | - | - |
|
527 |
-
| 1.2999 | 1400 | 24.9063 | 33.2694 | 0.7646 | 0.7644 | 0.7884 | 0.7906 | 0.7886 | - | - | - | - | - |
|
528 |
-
| 1.3928 | 1500 | 24.7283 | 32.4350 | 0.7935 | 0.7974 | 0.8071 | 0.8112 | 0.8062 | - | - | - | - | - |
|
529 |
-
| 1.4856 | 1600 | 24.4217 | 34.1219 | 0.7781 | 0.7754 | 0.7739 | 0.7916 | 0.7889 | - | - | - | - | - |
|
530 |
-
| 1.5785 | 1700 | 24.4923 | 33.1239 | 0.7636 | 0.7709 | 0.7882 | 0.7991 | 0.7913 | - | - | - | - | - |
|
531 |
-
| 1.6713 | 1800 | 24.0844 | 33.5233 | 0.7785 | 0.7832 | 0.7880 | 0.7977 | 0.8014 | - | - | - | - | - |
|
532 |
-
| 1.7642 | 1900 | 24.1453 | 35.4602 | 0.7795 | 0.7816 | 0.8053 | 0.8115 | 0.7944 | - | - | - | - | - |
|
533 |
-
| 1.8570 | 2000 | 24.2271 | 36.2812 | 0.8003 | 0.8009 | 0.8008 | 0.8102 | 0.8009 | - | - | - | - | - |
|
534 |
-
| 1.9499 | 2100 | 23.7371 | 37.0276 | 0.7769 | 0.7866 | 0.7918 | 0.7926 | 0.7832 | - | - | - | - | - |
|
535 |
-
| 2.0427 | 2200 | 23.3566 | 34.5721 | 0.7931 | 0.8017 | 0.8020 | 0.8159 | 0.8027 | - | - | - | - | - |
|
536 |
-
| 2.1356 | 2300 | 23.2523 | 35.5316 | 0.7931 | 0.7981 | 0.7896 | 0.8157 | 0.8142 | - | - | - | - | - |
|
537 |
-
| 2.2284 | 2400 | 23.0447 | 36.6811 | 0.7973 | 0.7962 | 0.7935 | 0.8030 | 0.8037 | - | - | - | - | - |
|
538 |
-
| 2.3213 | 2500 | 22.9782 | 37.5482 | 0.8121 | 0.8185 | 0.8200 | 0.8293 | 0.8244 | - | - | - | - | - |
|
539 |
-
| 2.4141 | 2600 | 22.9119 | 37.2809 | 0.8077 | 0.8116 | 0.8113 | 0.8333 | 0.8151 | - | - | - | - | - |
|
540 |
-
| 2.5070 | 2700 | 23.1302 | 37.7993 | 0.8255 | 0.8304 | 0.8310 | 0.8376 | 0.8303 | - | - | - | - | - |
|
541 |
-
| 2.5998 | 2800 | 22.9941 | 38.8005 | 0.8182 | 0.8214 | 0.8143 | 0.8193 | 0.8155 | - | - | - | - | - |
|
542 |
-
| 2.6927 | 2900 | 22.8876 | 36.2524 | 0.8201 | 0.8222 | 0.8194 | 0.8347 | 0.8260 | - | - | - | - | - |
|
543 |
-
| 2.7855 | 3000 | 22.5304 | 38.1523 | 0.8195 | 0.8280 | 0.8356 | 0.8545 | 0.8394 | - | - | - | - | - |
|
544 |
-
| 2.8784 | 3100 | 22.446 | 39.4876 | 0.8242 | 0.8246 | 0.8319 | 0.8483 | 0.8397 | - | - | - | - | - |
|
545 |
-
| 2.9712 | 3200 | 22.5077 | 39.1910 | 0.8231 | 0.8249 | 0.8334 | 0.8475 | 0.8372 | - | - | - | - | - |
|
546 |
-
| **3.0641** | **3300** | **21.9675** | **36.4245** | **0.8408** | **0.8425** | **0.8456** | **0.8619** | **0.8577** | **-** | **-** | **-** | **-** | **-** |
|
547 |
-
| 3.1569 | 3400 | 21.9361 | 36.7119 | 0.8344 | 0.8405 | 0.8460 | 0.8656 | 0.8644 | - | - | - | - | - |
|
548 |
-
| 3.2498 | 3500 | 21.7747 | 37.7140 | 0.8279 | 0.8353 | 0.8414 | 0.8510 | 0.8446 | - | - | - | - | - |
|
549 |
-
| 3.3426 | 3600 | 21.8649 | 38.9102 | 0.8298 | 0.8331 | 0.8456 | 0.8494 | 0.8447 | - | - | - | - | - |
|
550 |
-
| 3.4355 | 3700 | 21.794 | 37.4385 | 0.8278 | 0.8328 | 0.8377 | 0.8442 | 0.8373 | - | - | - | - | - |
|
551 |
-
| 3.5283 | 3800 | 21.7968 | 37.0225 | 0.8352 | 0.8501 | 0.8540 | 0.8722 | 0.8553 | - | - | - | - | - |
|
552 |
-
| 3.6212 | 3900 | 21.5941 | 37.5736 | 0.8344 | 0.8515 | 0.8511 | 0.8643 | 0.8587 | - | - | - | - | - |
|
553 |
-
| 3.7140 | 4000 | 21.8181 | 37.4984 | 0.8340 | 0.8440 | 0.8470 | 0.8607 | 0.8484 | - | - | - | - | - |
|
554 |
-
| 3.8069 | 4100 | 21.7035 | 37.9701 | 0.8346 | 0.8394 | 0.8436 | 0.8615 | 0.8479 | - | - | - | - | - |
|
555 |
-
| 3.8997 | 4200 | 21.398 | 38.1567 | 0.8349 | 0.8365 | 0.8470 | 0.8572 | 0.8405 | - | - | - | - | - |
|
556 |
-
| 3.9926 | 4300 | 21.6518 | 38.3515 | 0.8358 | 0.8395 | 0.8470 | 0.8562 | 0.8434 | - | - | - | - | - |
|
557 |
-
| 4.0 | 4308 | - | - | - | - | - | - | - | 0.8258 | 0.8227 | 0.8246 | 0.8183 | 0.8077 |
|
558 |
-
|
559 |
-
* The bold row denotes the saved checkpoint.
|
560 |
-
|
561 |
-
### Framework Versions
|
562 |
-
- Python: 3.12.7
|
563 |
-
- Sentence Transformers: 3.3.1
|
564 |
-
- Transformers: 4.51.3
|
565 |
-
- PyTorch: 2.6.0+cu124
|
566 |
-
- Accelerate: 1.4.0
|
567 |
-
- Datasets: 3.3.2
|
568 |
-
- Tokenizers: 0.21.1
|
569 |
-
|
570 |
-
## Citation
|
571 |
-
|
572 |
-
### BibTeX
|
573 |
-
|
574 |
-
#### Sentence Transformers
|
575 |
-
```bibtex
|
576 |
-
@inproceedings{reimers-2019-sentence-bert,
|
577 |
-
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
|
578 |
-
author = "Reimers, Nils and Gurevych, Iryna",
|
579 |
-
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
|
580 |
-
month = "11",
|
581 |
-
year = "2019",
|
582 |
-
publisher = "Association for Computational Linguistics",
|
583 |
-
url = "https://arxiv.org/abs/1908.10084",
|
584 |
-
}
|
585 |
```
|
586 |
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
597 |
```
|
598 |
|
599 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
600 |
```bibtex
|
601 |
-
@
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
}
|
608 |
```
|
609 |
|
610 |
-
|
611 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
612 |
|
613 |
-
|
614 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
615 |
|
616 |
-
|
617 |
-
## Model Card Authors
|
618 |
|
619 |
-
|
620 |
-
-->
|
621 |
|
622 |
-
|
623 |
-
## Model Card Contact
|
624 |
|
625 |
-
|
626 |
-
-->
|
|
|
15 |
- source_sentence: الرجل يركب حصاناً
|
16 |
sentences:
|
17 |
- رجل يُبث الجبن الممزق على البيتزا
|
|
|
|
|
18 |
- source_sentence: المرأة تقلي لحم خنزير مشوي
|
19 |
sentences:
|
|
|
20 |
- امرأة تطبخ لحم خنزير مخبوز
|
21 |
- طائرة طيران تقلع
|
22 |
- source_sentence: امرأة تحمل في ذراعها طفل كنغر
|
23 |
sentences:
|
24 |
- امرأة تعزف على الغيتار
|
|
|
25 |
- امرأة تحمل و تحمل طفل كنغر
|
26 |
- source_sentence: رجل يعزف على الناي
|
27 |
sentences:
|
28 |
- طائرة ستقلع
|
|
|
29 |
- رجل يعزف على فرقة الخيزران
|
30 |
- source_sentence: ثلاثة رجال يلعبون الشطرنج.
|
31 |
sentences:
|
32 |
- رجلين يلعبان الشطرنج
|
33 |
- بعض الرجال يقاتلون
|
|
|
34 |
datasets:
|
35 |
- silma-ai/silma-arabic-english-sts-dataset-v1.0
|
36 |
pipeline_tag: sentence-similarity
|
|
|
38 |
metrics:
|
39 |
- pearson_cosine
|
40 |
- spearman_cosine
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
---
|
42 |
|
|
|
43 |
|
44 |
+
# DIMI Embedding model
|
45 |
|
46 |
+
<div align="center">
|
47 |
|
48 |
+
![DIMI Logo]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
+

|
51 |
|
52 |
+
*State-of-the-art Multilingual Sentence Embeddings for Arabic-English Semantic Similarity*
|
|
|
|
|
53 |
|
54 |
+
[](https://huggingface.co/AhmedZaky1/DIMI-embedding-v3-silma-sts-matryoshka)
|
55 |
+
[](https://opensource.org/licenses/MIT)
|
56 |
+
[](https://python.org)
|
57 |
|
58 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
+
## 🚀 Model Description
|
61 |
|
62 |
+
**DIMI-embedding-v3-silma-sts-matryoshka** is a cutting-edge multilingual sentence embedding model specifically fine-tuned for Arabic-English semantic textual similarity tasks. Built upon the robust DIMI-embedding-v2 architecture, this model leverages **Matryoshka Representation Learning** combined with **CoSENT Loss** to deliver exceptional performance across multiple embedding dimensions.
|
63 |
|
64 |
+
### ✨ Key Features
|
65 |
|
66 |
+
- **Multi-dimensional embeddings**: Supports output dimensions of 768, 512, 256, 128, and 64
|
67 |
+
- **Bilingual expertise**: Optimized for Arabic and English text processing
|
68 |
+
- **Matryoshka architecture**: Efficient embedding computation at multiple granularities
|
69 |
+
- **State-of-the-art performance**: Fine-tuned on the comprehensive Silma Arabic-English STS dataset
|
70 |
+
- **Cosine similarity optimized**: Perfect for semantic similarity and retrieval tasks
|
71 |
+
|
72 |
+
## 📊 Model Performance
|
73 |
+
|
74 |
+
The model demonstrates exceptional performance across different embedding dimensions:
|
75 |
+
|
76 |
+
### Training Techniques
|
77 |
+
|
78 |
+
This model was trained using advanced techniques for optimal performance:
|
79 |
+
|
80 |
+
- **Matryoshka Representation Learning**: Enables efficient embeddings at multiple dimensions [768, 512, 256, 128, 64] without retraining
|
81 |
+
- **CoSENT Loss Function**: Cosine-based sentence embedding loss for superior semantic similarity learning
|
82 |
+
- **Multi-dimensional Evaluation**: Simultaneous optimization across all target dimensions during training
|
83 |
+
- **Mixed Precision Training (FP16)**: Accelerated training with maintained numerical stability
|
84 |
+
- **Warmup Learning Rate Schedule**: Gradual learning rate increase for stable convergence
|
85 |
+
- **Best Model Selection**: Automatic selection based on highest Spearman correlation on 768d embeddings
|
86 |
+
|
87 |
+
### Final Model Performance
|
88 |
+
|
89 |
+
#### Development Set Results (Silma STS Dataset)
|
90 |
+
Final evaluation on the held-out development set:
|
91 |
+
|
92 |
+
| Dimension | Pearson Correlation | Spearman Correlation |
|
93 |
+
|-----------|-------------------|---------------------|
|
94 |
+
| 768d | 0.8894 | 0.8358 |
|
95 |
+
| 512d | 0.8959 | 0.8395 |
|
96 |
+
| 256d | 0.8979 | 0.8470 |
|
97 |
+
| 128d | 0.9182 | 0.8562 |
|
98 |
+
| 64d | 0.9066 | 0.8434 |
|
99 |
+
|
100 |
+
#### MTEB STS17 Arabic Test Results
|
101 |
+
Performance on the standard MTEB STS17 (ar-ar) benchmark:
|
102 |
+
|
103 |
+
| Dimension | Pearson Correlation | Spearman Correlation |
|
104 |
+
|-----------|-------------------|---------------------|
|
105 |
+
| **768d** | **0.8205** | **0.8258** |
|
106 |
+
| **512d** | **0.8193** | **0.8227** |
|
107 |
+
| **256d** | **0.8191** | **0.8246** |
|
108 |
+
| **128d** | **0.8115** | **0.8183** |
|
109 |
+
| **64d** | **0.7962** | **0.8077** |
|
110 |
+
|
111 |
+
**Sequential Score**: 0.8077 (based on 64d performance)
|
112 |
+
|
113 |
+
## 🔧 Usage
|
114 |
+
|
115 |
+
### Basic Usage
|
116 |
|
|
|
117 |
```python
|
118 |
from sentence_transformers import SentenceTransformer
|
119 |
|
120 |
+
# Load the model
|
121 |
+
model = SentenceTransformer('AhmedZaky1/DIMI-embedding-v3-silma-sts-matryoshka')
|
122 |
+
|
123 |
+
# Example sentences in Arabic and English
|
124 |
sentences = [
|
125 |
+
"هذا مثال جميل للذكاء الاصطناعي", # Arabic
|
126 |
+
"This is a beautiful example of artificial intelligence", # English
|
127 |
+
"التعلم الآلي يغير العالم", # Arabic
|
128 |
+
"Machine learning is changing the world" # English
|
129 |
]
|
130 |
+
|
131 |
+
# Generate embeddings
|
132 |
embeddings = model.encode(sentences)
|
133 |
+
print(f"Embedding shape: {embeddings.shape}")
|
|
|
134 |
|
135 |
+
# Calculate cosine similarity
|
136 |
+
from sklearn.metrics.pairwise import cosine_similarity
|
137 |
+
similarity_matrix = cosine_similarity(embeddings)
|
138 |
+
print("Similarity matrix:")
|
139 |
+
print(similarity_matrix)
|
140 |
```
|
141 |
|
142 |
+
### Matryoshka Embeddings Usage
|
143 |
+
|
144 |
+
```python
|
145 |
+
# Use different embedding dimensions
|
146 |
+
dimensions = [768, 512, 256, 128, 64]
|
147 |
+
|
148 |
+
for dim in dimensions:
|
149 |
+
# Truncate embeddings to specific dimension
|
150 |
+
truncated_embeddings = embeddings[:, :dim]
|
151 |
+
print(f"Dimension {dim}: {truncated_embeddings.shape}")
|
152 |
+
|
153 |
+
# Calculate similarity with truncated embeddings
|
154 |
+
similarity = cosine_similarity(truncated_embeddings)
|
155 |
+
print(f"Average similarity at {dim}d: {similarity.mean():.4f}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
```
|
157 |
|
158 |
+
### Semantic Search Example
|
159 |
+
|
160 |
+
```python
|
161 |
+
import numpy as np
|
162 |
+
|
163 |
+
# Query and corpus
|
164 |
+
query = "ما هو الذكاء الاصطناعي؟" # "What is artificial intelligence?"
|
165 |
+
corpus = [
|
166 |
+
"الذكاء الاصطناعي هو محاكاة الذكاء البشري",
|
167 |
+
"Machine learning is a subset of AI",
|
168 |
+
"Deep learning uses neural networks",
|
169 |
+
"التعلم العميق يستخدم الشبكات العصبية"
|
170 |
+
]
|
171 |
+
|
172 |
+
# Encode query and corpus
|
173 |
+
query_embedding = model.encode([query])
|
174 |
+
corpus_embeddings = model.encode(corpus)
|
175 |
+
|
176 |
+
# Find most similar documents
|
177 |
+
similarities = cosine_similarity(query_embedding, corpus_embeddings)[0]
|
178 |
+
top_indices = np.argsort(similarities)[::-1]
|
179 |
+
|
180 |
+
print(f"Query: {query}")
|
181 |
+
print("\nMost similar documents:")
|
182 |
+
for i, idx in enumerate(top_indices[:3]):
|
183 |
+
print(f"{i+1}. {corpus[idx]} (similarity: {similarities[idx]:.4f})")
|
184 |
```
|
185 |
|
186 |
+
## 🏗️ Model Architecture
|
187 |
+
|
188 |
+
- **Base Model**: DIMI-embedding-v2
|
189 |
+
- **Training Objective**: CoSENT Loss with Matryoshka Learning
|
190 |
+
- **Supported Dimensions**: [768, 512, 256, 128, 64]
|
191 |
+
- **Max Sequence Length**: 512 tokens
|
192 |
+
- **Pooling Method**: Mean pooling
|
193 |
+
- **Similarity Function**: Cosine similarity
|
194 |
+
|
195 |
+
## 📊 Training Details
|
196 |
+
|
197 |
+
### Dataset
|
198 |
+
- **Primary Dataset**: silma-ai/silma-arabic-english-sts-dataset-v1.0
|
199 |
+
- **Evaluation Dataset**: MTEB STS17 (ar-ar)
|
200 |
+
- **Training Samples**: ~24,000+ multilingual sentence pairs
|
201 |
+
- **Evaluation Samples**: 100 held-out pairs
|
202 |
+
|
203 |
+
### Training Configuration
|
204 |
+
- **Batch Size**: 16
|
205 |
+
- **Epochs**: 4
|
206 |
+
- **Learning Rate**: Warmup ratio 0.1
|
207 |
+
- **Precision**: FP16
|
208 |
+
- **Evaluation Strategy**: Every 100 steps
|
209 |
+
- **Best Model Selection**: Highest Spearman correlation on 768d embeddings
|
210 |
+
|
211 |
+
### Hardware Requirements
|
212 |
+
- **GPU**: CUDA-compatible GPU recommended
|
213 |
+
- **Memory**: 16GB+ RAM for training
|
214 |
+
- **Storage**: 2GB+ for model weights
|
215 |
+
|
216 |
+
## 🎯 Applications
|
217 |
+
|
218 |
+
This model excels in various NLP tasks:
|
219 |
+
|
220 |
+
- **Semantic Textual Similarity**: Measure similarity between Arabic-English text pairs
|
221 |
+
- **Information Retrieval**: Find relevant documents in multilingual corpora
|
222 |
+
- **Paraphrase Detection**: Identify semantically equivalent sentences
|
223 |
+
- **Cross-lingual Search**: Search Arabic content with English queries and vice versa
|
224 |
+
- **Clustering**: Group similar multilingual documents
|
225 |
+
- **Recommendation Systems**: Content-based recommendations across languages
|
226 |
+
|
227 |
+
## ⚖️ Limitations and Bias
|
228 |
+
|
229 |
+
- Primarily optimized for Arabic and English; performance on other languages may vary
|
230 |
+
- Performance may degrade on domain-specific technical terminology
|
231 |
+
- Potential cultural and linguistic biases inherited from training data
|
232 |
+
- Best performance achieved with sentence-level inputs rather than single words
|
233 |
+
|
234 |
+
## 📝 Citation
|
235 |
+
|
236 |
+
If you use this model in your research, please cite:
|
237 |
+
|
238 |
```bibtex
|
239 |
+
@misc{dimi-embedding-v3-2024,
|
240 |
+
title={DIMI-embedding-v3-silma-sts-matryoshka: Multilingual Sentence Embeddings for Arabic-English Semantic Similarity},
|
241 |
+
author={Ahmed Zaky},
|
242 |
+
year={2024},
|
243 |
+
publisher={Hugging Face},
|
244 |
+
url={https://huggingface.co/AhmedZaky1/DIMI-embedding-v3-silma-sts-matryoshka}
|
245 |
}
|
246 |
```
|
247 |
|
248 |
+
## 📧 Contact
|
249 |
+
|
250 |
+
**Author**: Ahmed Zaky
|
251 |
+
**Email**: [email protected]
|
252 |
+
**GitHub**: [@AhmedZaky1](https://github.com/AhmedZaky1)
|
253 |
+
|
254 |
+
## 📄 License
|
255 |
+
|
256 |
+
This model is released under the **MIT License**.
|
257 |
|
258 |
+
```
|
259 |
+
MIT License
|
260 |
+
|
261 |
+
Copyright (c) 2024 Ahmed Zaky
|
262 |
+
|
263 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
264 |
+
of this software and associated documentation files (the "Software"), to deal
|
265 |
+
in the Software without restriction, including without limitation the rights
|
266 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
267 |
+
copies of the Software, and to permit persons to whom the Software is
|
268 |
+
furnished to do so, subject to the following conditions:
|
269 |
+
|
270 |
+
The above copyright notice and this permission notice shall be included in all
|
271 |
+
copies or substantial portions of the Software.
|
272 |
+
|
273 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
274 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
275 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
276 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
277 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
278 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
279 |
+
SOFTWARE.
|
280 |
+
```
|
281 |
+
|
282 |
+
## 🙏 Acknowledgments
|
283 |
+
|
284 |
+
- **Silma AI** for providing the high-quality Arabic-English STS dataset
|
285 |
+
- **Sentence Transformers** library for the excellent framework
|
286 |
+
- **Hugging Face** for model hosting and distribution
|
287 |
+
- The **MTEB** benchmark for evaluation standards
|
288 |
+
|
289 |
+
---
|
290 |
|
291 |
+
<div align="center">
|
|
|
292 |
|
293 |
+
**Built with ❤️ by Ahmed Zaky**
|
|
|
294 |
|
295 |
+
*Advancing Arabic NLP through state-of-the-art embedding models*
|
|
|
296 |
|
297 |
+
</div>
|
|