Views
No views yet
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: MPNetModel
(1): Pooling({'word_embedding_dimension': 768, '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})
)pip install -U sentence-transformers1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("Omartificial-Intelligence-Space/mpnet-base-all-nli-triplet-Arabic-mpnet_base")
5# Run inference
6sentences = [
7 'يجلس شاب ذو شعر أشقر على الحائط يقرأ جريدة بينما تمر امرأة وفتاة شابة.',
8 'ذكر شاب ينظر إلى جريدة بينما تمر إمرأتان بجانبه',
9 'الشاب نائم بينما الأم تقود ابنتها إلى الحديقة',
10]
11embeddings = model.encode(sentences)
12print(embeddings.shape)
13# [3, 768]
14
15# Get the similarity scores for the embeddings
16similarities = model.similarity(embeddings, embeddings)
17print(similarities.shape)
18# [3, 3]sts-test-768EmbeddingSimilarityEvaluator| Metric | Value |
|---|---|
| pearson_cosine | 0.6699 |
| spearman_cosine | 0.6757 |
| pearson_manhattan | 0.6943 |
| spearman_manhattan | 0.684 |
| pearson_euclidean | 0.6973 |
| spearman_euclidean | 0.6873 |
| pearson_dot | 0.5534 |
| spearman_dot | 0.5422 |
| pearson_max | 0.6973 |
| spearman_max | 0.6873 |
sts-test-512EmbeddingSimilarityEvaluator| Metric | Value |
|---|---|
| pearson_cosine | 0.6628 |
| spearman_cosine | 0.6703 |
| pearson_manhattan | 0.6917 |
| spearman_manhattan | 0.6816 |
| pearson_euclidean | 0.6949 |
| spearman_euclidean | 0.6853 |
| pearson_dot | 0.5229 |
| spearman_dot | 0.5114 |
| pearson_max | 0.6949 |
| spearman_max | 0.6853 |
sts-test-256EmbeddingSimilarityEvaluator| Metric | Value |
|---|---|
| pearson_cosine | 0.6368 |
| spearman_cosine | 0.6513 |
| pearson_manhattan | 0.6832 |
| spearman_manhattan | 0.6746 |
| pearson_euclidean | 0.6844 |
| spearman_euclidean | 0.676 |
| pearson_dot | 0.4266 |
| spearman_dot | 0.4179 |
| pearson_max | 0.6844 |
| spearman_max | 0.676 |
sts-test-128EmbeddingSimilarityEvaluator| Metric | Value |
|---|---|
| pearson_cosine | 0.6148 |
| spearman_cosine | 0.6355 |
| pearson_manhattan | 0.6731 |
| spearman_manhattan | 0.6653 |
| pearson_euclidean | 0.6764 |
| spearman_euclidean | 0.6691 |
| pearson_dot | 0.3513 |
| spearman_dot | 0.3445 |
| pearson_max | 0.6764 |
| spearman_max | 0.6691 |
sts-test-64EmbeddingSimilarityEvaluator| Metric | Value |
|---|---|
| pearson_cosine | 0.5789 |
| spearman_cosine | 0.6081 |
| pearson_manhattan | 0.6579 |
| spearman_manhattan | 0.6519 |
| pearson_euclidean | 0.663 |
| spearman_euclidean | 0.6571 |
| pearson_dot | 0.2403 |
| spearman_dot | 0.2331 |
| pearson_max | 0.663 |
| spearman_max | 0.6571 |
anchor, positive, and negative| anchor | positive | negative | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| anchor | positive | negative |
|---|---|---|
شخص على حصان يقفز فوق طائرة معطلة | شخص في الهواء الطلق، على حصان. | شخص في مطعم، يطلب عجة. |
أطفال يبتسمون و يلوحون للكاميرا | هناك أطفال حاضرون | الاطفال يتجهمون |
صبي يقفز على لوح التزلج في منتصف الجسر الأحمر. | الفتى يقوم بخدعة التزلج | الصبي يتزلج على الرصيف |
MatryoshkaLoss with these parameters:
1{
2 "loss": "MultipleNegativesRankingLoss",
3 "matryoshka_dims": [
4 768,
5 512,
6 256,
7 128,
8 64
9 ],
10 "matryoshka_weights": [
11 1,
12 1,
13 1,
14 1,
15 1
16 ],
17 "n_dims_per_step": -1
18}anchor, positive, and negative| anchor | positive | negative | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| anchor | positive | negative |
|---|---|---|
امرأتان يتعانقان بينما يحملان حزمة | إمرأتان يحملان حزمة | الرجال يتشاجرون خارج مطعم |
طفلين صغيرين يرتديان قميصاً أزرق، أحدهما يرتدي الرقم 9 والآخر يرتدي الرقم 2 يقفان على خطوات خشبية في الحمام ويغسلان أيديهما في المغسلة. | طفلين يرتديان قميصاً مرقماً يغسلون أيديهم | طفلين يرتديان سترة يذهبان إلى المدرسة |
رجل يبيع الدونات لعميل خلال معرض عالمي أقيم في مدينة أنجليس | رجل يبيع الدونات لعميل | امرأة تشرب قهوتها في مقهى صغير |
MatryoshkaLoss with these parameters:
1{
2 "loss": "MultipleNegativesRankingLoss",
3 "matryoshka_dims": [
4 768,
5 512,
6 256,
7 128,
8 64
9 ],
10 "matryoshka_weights": [
11 1,
12 1,
13 1,
14 1,
15 1
16 ],
17 "n_dims_per_step": -1
18}per_device_train_batch_size: 64per_device_eval_batch_size: 64warmup_ratio: 0.1fp16: Truebatch_sampler: no_duplicatesoverwrite_output_dir: Falsedo_predict: Falseprediction_loss_only: Trueper_device_train_batch_size: 64per_device_eval_batch_size: 64per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonelearning_rate: 5e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 3max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.1warmup_steps: 0log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Truesave_safetensors: Truesave_on_each_node: Falsesave_only_model: Falseno_cuda: Falseuse_cpu: Falseuse_mps_device: Falseseed: 42data_seed: Nonejit_mode_eval: Falseuse_ipex: Falsebf16: Falsefp16: Truefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: 0ddp_backend: Nonetpu_num_cores: Nonetpu_metrics_debug: Falsedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonepast_index: -1disable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Falseignore_data_skip: Falsefsdp: []fsdp_min_num_params: 0fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}fsdp_transformer_layer_cls_to_wrap: Noneaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'gradient_accumulation_kwargs': None}deepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torchoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Trueuse_legacy_prediction_loop: Falsepush_to_hub: Falseresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Falsehub_always_push: Falsegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_inputs_for_metrics: Falseeval_do_concat_batches: Truefp16_backend: autopush_to_hub_model_id: Nonepush_to_hub_organization: Nonemp_parameters:auto_find_batch_size: Falsefull_determinism: Falsetorchdynamo: Noneray_scope: lastddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Nonedispatch_batches: Nonesplit_batches: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: Falseneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportional| Epoch | Step | Training Loss | sts-test-128_spearman_cosine | sts-test-256_spearman_cosine | sts-test-512_spearman_cosine | sts-test-64_spearman_cosine | sts-test-768_spearman_cosine |
|---|---|---|---|---|---|---|---|
| 0.0229 | 200 | 21.5318 | - | - | - | - | - |
| 0.0459 | 400 | 17.2344 | - | - | - | - | - |
| 0.0688 | 600 | 15.393 | - | - | - | - | - |
| 0.0918 | 800 | 13.7897 | - | - | - | - | - |
| 0.1147 | 1000 | 13.534 | - | - | - | - | - |
| 0.1377 | 1200 | 12.2683 | - | - | - | - | - |
| 0.1606 | 1400 | 10.9271 | - | - | - | - | - |
| 0.1835 | 1600 | 11.071 | - | - | - | - | - |
| 0.2065 | 1800 | 10.0153 | - | - | - | - | - |
| 0.2294 | 2000 | 9.8463 | - | - | - | - | - |
| 0.2524 | 2200 | 10.0194 | - | - | - | - | - |
| 0.2753 | 2400 | 9.8371 | - | - | - | - | - |
| 0.2983 | 2600 | 9.6315 | - | - | - | - | - |
| 0.3212 | 2800 | 8.9858 | - | - | - | - | - |
| 0.3442 | 3000 | 9.1876 | - | - | - | - | - |
| 0.3671 | 3200 | 8.8028 | - | - | - | - | - |
| 0.3900 | 3400 | 8.6075 | - | - | - | - | - |
| 0.4130 | 3600 | 8.4285 | - | - | - | - | - |
| 0.4359 | 3800 | 8.1258 | - | - | - | - | - |
| 0.4589 | 4000 | 8.2508 | - | - | - | - | - |
| 0.4818 | 4200 | 7.8037 | - | - | - | - | - |
| 0.5048 | 4400 | 7.7133 | - | - | - | - | - |
| 0.5277 | 4600 | 7.5006 | - | - | - | - | - |
| 0.5506 | 4800 | 7.7025 | - | - | - | - | - |
| 0.5736 | 5000 | 7.7593 | - | - | - | - | - |
| 0.5965 | 5200 | 7.6305 | - | - | - | - | - |
| 0.6195 | 5400 | 7.7502 | - | - | - | - | - |
| 0.6424 | 5600 | 7.5624 | - | - | - | - | - |
| 0.6654 | 5800 | 7.5287 | - | - | - | - | - |
| 0.6883 | 6000 | 7.4261 | - | - | - | - | - |
| 0.7113 | 6200 | 7.239 | - | - | - | - | - |
| 0.7342 | 6400 | 7.1631 | - | - | - | - | - |
| 0.7571 | 6600 | 7.6865 | - | - | - | - | - |
| 0.7801 | 6800 | 7.6124 | - | - | - | - | - |
| 0.8030 | 7000 | 6.9936 | - | - | - | - | - |
| 0.8260 | 7200 | 6.7331 | - | - | - | - | - |
| 0.8489 | 7400 | 6.4542 | - | - | - | - | - |
| 0.8719 | 7600 | 6.1994 | - | - | - | - | - |
| 0.8948 | 7800 | 5.9798 | - | - | - | - | - |
| 0.9177 | 8000 | 5.7808 | - | - | - | - | - |
| 0.9407 | 8200 | 5.6952 | - | - | - | - | - |
| 0.9636 | 8400 | 5.5082 | - | - | - | - | - |
| 0.9866 | 8600 | 5.4421 | - | - | - | - | - |
| 1.0095 | 8800 | 3.0309 | - | - | - | - | - |
| 1.0026 | 9000 | 1.1835 | - | - | - | - | - |
| 1.0256 | 9200 | 8.1196 | - | - | - | - | - |
| 1.0485 | 9400 | 8.0326 | - | - | - | - | - |
| 1.0715 | 9600 | 8.5028 | - | - | - | - | - |
| 1.0944 | 9800 | 7.6923 | - | - | - | - | - |
| 1.1174 | 10000 | 8.029 | - | - | - | - | - |
| 1.1403 | 10200 | 7.5052 | - | - | - | - | - |
| 1.1632 | 10400 | 7.1177 | - | - | - | - | - |
| 1.1862 | 10600 | 6.9594 | - | - | - | - | - |
| 1.2091 | 10800 | 6.6662 | - | - | - | - | - |
| 1.2321 | 11000 | 6.6903 | - | - | - | - | - |
| 1.2550 | 11200 | 6.9523 | - | - | - | - | - |
| 1.2780 | 11400 | 6.676 | - | - | - | - | - |
| 1.3009 | 11600 | 6.7141 | - | - | - | - | - |
| 1.3238 | 11800 | 6.568 | - | - | - | - | - |
| 1.3468 | 12000 | 6.8938 | - | - | - | - | - |
| 1.3697 | 12200 | 6.3745 | - | - | - | - | - |
| 1.3927 | 12400 | 6.2513 | - | - | - | - | - |
| 1.4156 | 12600 | 6.2589 | - | - | - | - | - |
| 1.4386 | 12800 | 6.1388 | - | - | - | - | - |
| 1.4615 | 13000 | 6.1835 | - | - | - | - | - |
| 1.4845 | 13200 | 5.9004 | - | - | - | - | - |
| 1.5074 | 13400 | 5.7891 | - | - | - | - | - |
| 1.5303 | 13600 | 5.6184 | - | - | - | - | - |
| 1.5533 | 13800 | 5.9762 | - | - | - | - | - |
| 1.5762 | 14000 | 5.9737 | - | - | - | - | - |
| 1.5992 | 14200 | 5.8563 | - | - | - | - | - |
| 1.6221 | 14400 | 5.8904 | - | - | - | - | - |
| 1.6451 | 14600 | 5.8484 | - | - | - | - | - |
| 1.6680 | 14800 | 5.8906 | - | - | - | - | - |
| 1.6909 | 15000 | 5.7613 | - | - | - | - | - |
| 1.7139 | 15200 | 5.5744 | - | - | - | - | - |
| 1.7368 | 15400 | 5.6569 | - | - | - | - | - |
| 1.7598 | 15600 | 5.7439 | - | - | - | - | - |
| 1.7827 | 15800 | 5.5593 | - | - | - | - | - |
| 1.8057 | 16000 | 5.2935 | - | - | - | - | - |
| 1.8286 | 16200 | 5.088 | - | - | - | - | - |
| 1.8516 | 16400 | 5.0167 | - | - | - | - | - |
| 1.8745 | 16600 | 4.84 | - | - | - | - | - |
| 1.8974 | 16800 | 4.6731 | - | - | - | - | - |
| 1.9204 | 17000 | 4.6404 | - | - | - | - | - |
| 1.9433 | 17200 | 4.6413 | - | - | - | - | - |
| 1.9663 | 17400 | 4.4495 | - | - | - | - | - |
| 1.9892 | 17600 | 4.4262 | - | - | - | - | - |
| 2.0122 | 17800 | 2.01 | - | - | - | - | - |
| 2.0053 | 18000 | 1.8418 | - | - | - | - | - |
| 2.0282 | 18200 | 6.2714 | - | - | - | - | - |
| 2.0512 | 18400 | 6.1742 | - | - | - | - | - |
| 2.0741 | 18600 | 6.5996 | - | - | - | - | - |
| 2.0971 | 18800 | 6.0907 | - | - | - | - | - |
| 2.1200 | 19000 | 6.2418 | - | - | - | - | - |
| 2.1429 | 19200 | 5.7817 | - | - | - | - | - |
| 2.1659 | 19400 | 5.7073 | - | - | - | - | - |
| 2.1888 | 19600 | 5.2645 | - | - | - | - | - |
| 2.2118 | 19800 | 5.3451 | - | - | - | - | - |
| 2.2347 | 20000 | 5.2453 | - | - | - | - | - |
| 2.2577 | 20200 | 5.6161 | - | - | - | - | - |
| 2.2806 | 20400 | 5.2289 | - | - | - | - | - |
| 2.3035 | 20600 | 5.3888 | - | - | - | - | - |
| 2.3265 | 20800 | 5.2483 | - | - | - | - | - |
| 2.3494 | 21000 | 5.5791 | - | - | - | - | - |
| 2.3724 | 21200 | 5.1643 | - | - | - | - | - |
| 2.3953 | 21400 | 5.1231 | - | - | - | - | - |
| 2.4183 | 21600 | 5.1055 | - | - | - | - | - |
| 2.4412 | 21800 | 5.1778 | - | - | - | - | - |
| 2.4642 | 22000 | 5.0466 | - | - | - | - | - |
| 2.4871 | 22200 | 4.8321 | - | - | - | - | - |
| 2.5100 | 22400 | 4.7056 | - | - | - | - | - |
| 2.5330 | 22600 | 4.6858 | - | - | - | - | - |
| 2.5559 | 22800 | 4.9189 | - | - | - | - | - |
| 2.5789 | 23000 | 4.912 | - | - | - | - | - |
| 2.6018 | 23200 | 4.8289 | - | - | - | - | - |
| 2.6248 | 23400 | 4.8959 | - | - | - | - | - |
| 2.6477 | 23600 | 4.9441 | - | - | - | - | - |
| 2.6706 | 23800 | 4.9334 | - | - | - | - | - |
| 2.6936 | 24000 | 4.8328 | - | - | - | - | - |
| 2.7165 | 24200 | 4.601 | - | - | - | - | - |
| 2.7395 | 24400 | 4.834 | - | - | - | - | - |
| 2.7624 | 24600 | 5.152 | - | - | - | - | - |
| 2.7854 | 24800 | 4.9232 | - | - | - | - | - |
| 2.8083 | 25000 | 4.6556 | - | - | - | - | - |
| 2.8312 | 25200 | 4.6229 | - | - | - | - | - |
| 2.8542 | 25400 | 4.5768 | - | - | - | - | - |
| 2.8771 | 25600 | 4.3619 | - | - | - | - | - |
| 2.9001 | 25800 | 4.3608 | - | - | - | - | - |
| 2.9230 | 26000 | 4.2834 | - | - | - | - | - |
| 2.9403 | 26151 | - | 0.6355 | 0.6513 | 0.6703 | 0.6081 | 0.6757 |
1@inproceedings{reimers-2019-sentence-bert,
2 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
3 author = "Reimers, Nils and Gurevych, Iryna",
4 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
5 month = "11",
6 year = "2019",
7 publisher = "Association for Computational Linguistics",
8 url = "https://arxiv.org/abs/1908.10084",
9}1@misc{kusupati2024matryoshka,
2 title={Matryoshka Representation Learning},
3 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},
4 year={2024},
5 eprint={2205.13147},
6 archivePrefix={arXiv},
7 primaryClass={cs.LG}
8}1@misc{henderson2017efficient,
2 title={Efficient Natural Language Response Suggestion for Smart Reply},
3 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},
4 year={2017},
5 eprint={1705.00652},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL}
8}1## Citation
2
3If you use the Arabic Matryoshka Embeddings Model, please cite it as follows:
4
5@misc{nacar2024enhancingsemanticsimilarityunderstanding,
6 title={Enhancing Semantic Similarity Understanding in Arabic NLP with Nested Embedding Learning},
7 author={Omer Nacar and Anis Koubaa},
8 year={2024},
9 eprint={2407.21139},
10 archivePrefix={arXiv},
11 primaryClass={cs.CL},
12 url={https://arxiv.org/abs/2407.21139},
13}