CoolFace
Modelpublic

Mollel/swahili-serengeti-E250-nli-matryoshka

sourceHugging Faceupdated 2y agoView on Hugging Face
1likes23downloads
Model Card

SentenceTransformer based on UBC-NLP/serengeti-E250

This is a sentence-transformers model finetuned from UBC-NLP/serengeti-E250. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.

Model Details

Model Description

  • —Model Type: Sentence Transformer
  • —Base model: UBC-NLP/serengeti-E250 <!-- at revision 41b5b8b6179c4af2859768cbf4f0f03e928d651d -->
  • —Maximum Sequence Length: 512 tokens
  • —Output Dimensionality: 768 tokens
  • —Similarity Function: Cosine Similarity <!-- - Training Dataset: Unknown --> <!-- - Language: Unknown --> <!-- - License: Unknown -->

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: ElectraModel 
  (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})
)

Usage

Direct Usage (Sentence Transformers)

First install the Sentence Transformers library:

bash
pip install -U sentence-transformers

Then you can load this model and run inference.

python
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("Mollel/swahili-serengeti-E250-nli-matryoshka")
# Run inference
sentences = [
    'Mwanamume aliyevalia koti la bluu la kuzuia upepo, amelala uso chini kwenye benchi ya bustani, akiwa na chupa ya pombe iliyofungwa kwenye mojawapo ya miguu ya benchi.',
    'Mwanamume amelala uso chini kwenye benchi ya bustani.',
    'Mwanamume fulani anacheza dansi kwenye klabu hiyo akifungua chupa.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]

<!--

Direct Usage (Transformers)

<details><summary>Click to see the direct usage in Transformers</summary>

</details> -->

<!--

Downstream Usage (Sentence Transformers)

You can finetune this model on your own dataset.

<details><summary>Click to expand</summary>

</details> -->

<!--

Out-of-Scope Use

List how the model may foreseeably be misused and address what users ought not to do with the model. -->

Evaluation

Metrics

Semantic Similarity
MetricValue
pearson_cosine0.7113
spearman_cosine0.7065
pearson_manhattan0.7134
spearman_manhattan0.7023
pearson_euclidean0.7138
spearman_euclidean0.7021
pearson_dot0.3921
spearman_dot0.3601
pearson_max0.7138
spearman_max0.7065
Semantic Similarity
MetricValue
pearson_cosine0.7091
spearman_cosine0.7046
pearson_manhattan0.713
spearman_manhattan0.7022
pearson_euclidean0.7139
spearman_euclidean0.7032
pearson_dot0.3935
spearman_dot0.3628
pearson_max0.7139
spearman_max0.7046
Semantic Similarity
MetricValue
pearson_cosine0.7068
spearman_cosine0.7044
pearson_manhattan0.7137
spearman_manhattan0.7032
pearson_euclidean0.7147
spearman_euclidean0.7039
pearson_dot0.3746
spearman_dot0.3444
pearson_max0.7147
spearman_max0.7044
Semantic Similarity
MetricValue
pearson_cosine0.7047
spearman_cosine0.7051
pearson_manhattan0.712
spearman_manhattan0.701
pearson_euclidean0.7132
spearman_euclidean0.7016
pearson_dot0.3546
spearman_dot0.3229
pearson_max0.7132
spearman_max0.7051
Semantic Similarity
MetricValue
pearson_cosine0.7012
spearman_cosine0.7044
pearson_manhattan0.7091
spearman_manhattan0.6973
pearson_euclidean0.7103
spearman_euclidean0.6986
pearson_dot0.338
spearman_dot0.3051
pearson_max0.7103
spearman_max0.7044

<!--

Bias, Risks and Limitations

What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model. -->

<!--

Recommendations

What are recommendations with respect to the foreseeable issues? For example, filtering explicit content. -->

Training Details

Training Hyperparameters

Non-Default Hyperparameters
  • —per_device_train_batch_size: 16
  • —per_device_eval_batch_size: 16
  • —learning_rate: 2e-05
  • —num_train_epochs: 1
  • —warmup_ratio: 0.1
  • —bf16: True
  • —batch_sampler: no_duplicates
All Hyperparameters

<details><summary>Click to expand</summary>

  • —overwrite_output_dir: False
  • —do_predict: False
  • —prediction_loss_only: True
  • —per_device_train_batch_size: 16
  • —per_device_eval_batch_size: 16
  • —per_gpu_train_batch_size: None
  • —per_gpu_eval_batch_size: None
  • —gradient_accumulation_steps: 1
  • —eval_accumulation_steps: None
  • —learning_rate: 2e-05
  • —weight_decay: 0.0
  • —adam_beta1: 0.9
  • —adam_beta2: 0.999
  • —adam_epsilon: 1e-08
  • —max_grad_norm: 1.0
  • —num_train_epochs: 1
  • —max_steps: -1
  • —lr_scheduler_type: linear
  • —lr_scheduler_kwargs: {}
  • —warmup_ratio: 0.1
  • —warmup_steps: 0
  • —log_level: passive
  • —log_level_replica: warning
  • —log_on_each_node: True
  • —logging_nan_inf_filter: True
  • —save_safetensors: True
  • —save_on_each_node: False
  • —save_only_model: False
  • —no_cuda: False
  • —use_cpu: False
  • —use_mps_device: False
  • —seed: 42
  • —data_seed: None
  • —jit_mode_eval: False
  • —use_ipex: False
  • —bf16: True
  • —fp16: False
  • —fp16_opt_level: O1
  • —half_precision_backend: auto
  • —bf16_full_eval: False
  • —fp16_full_eval: False
  • —tf32: None
  • —local_rank: 0
  • —ddp_backend: None
  • —tpu_num_cores: None
  • —tpu_metrics_debug: False
  • —debug: []
  • —dataloader_drop_last: False
  • —dataloader_num_workers: 0
  • —dataloader_prefetch_factor: None
  • —past_index: -1
  • —disable_tqdm: False
  • —remove_unused_columns: True
  • —label_names: None
  • —load_best_model_at_end: False
  • —ignore_data_skip: False
  • —fsdp: []
  • —fsdp_min_num_params: 0
  • —fsdp_config: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • —fsdp_transformer_layer_cls_to_wrap: None
  • —accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'gradientaccumulation_kwargs': None}
  • —deepspeed: None
  • —label_smoothing_factor: 0.0
  • —optim: adamw_torch
  • —optim_args: None
  • —adafactor: False
  • —group_by_length: False
  • —length_column_name: length
  • —ddp_find_unused_parameters: None
  • —ddp_bucket_cap_mb: None
  • —ddp_broadcast_buffers: False
  • —dataloader_pin_memory: True
  • —dataloader_persistent_workers: False
  • —skip_memory_metrics: True
  • —use_legacy_prediction_loop: False
  • —push_to_hub: False
  • —resume_from_checkpoint: None
  • —hub_model_id: None
  • —hub_strategy: every_save
  • —hub_private_repo: False
  • —hub_always_push: False
  • —gradient_checkpointing: False
  • —gradient_checkpointing_kwargs: None
  • —include_inputs_for_metrics: False
  • —eval_do_concat_batches: True
  • —fp16_backend: auto
  • —push_to_hub_model_id: None
  • —push_to_hub_organization: None
  • —mp_parameters:
  • —auto_find_batch_size: False
  • —full_determinism: False
  • —torchdynamo: None
  • —ray_scope: last
  • —ddp_timeout: 1800
  • —torch_compile: False
  • —torch_compile_backend: None
  • —torch_compile_mode: None
  • —dispatch_batches: None
  • —split_batches: None
  • —include_tokens_per_second: False
  • —include_num_input_tokens_seen: False
  • —neftune_noise_alpha: None
  • —optim_target_modules: None
  • —batch_sampler: no_duplicates
  • —multi_dataset_batch_sampler: proportional

</details>

Training Logs

<details><summary>Click to expand</summary>

EpochStepTraining Losssts-test-128_spearman_cosinests-test-256_spearman_cosinests-test-512_spearman_cosinests-test-64_spearman_cosinests-test-768_spearman_cosine
0.005710025.7713-----
0.011520020.7886-----
0.017230017.0398-----
0.022940015.3913-----
0.028750014.0214-----
0.034460012.2125-----
0.040270010.3033-----
0.04598009.3822-----
0.05169008.9276-----
0.057410008.552-----
0.063111008.6293-----
0.068812008.5353-----
0.074613008.6431-----
0.080314008.3192-----
0.086015007.1834-----
0.091816006.7834-----
0.097517006.4758-----
0.103318006.756-----
0.109019007.807-----
0.114720006.8836-----
0.120521006.9948-----
0.126222006.5031-----
0.131923006.3596-----
0.137724006.0257-----
0.143425005.9757-----
0.149126005.464-----
0.154927005.6518-----
0.160628006.2899-----
0.166429006.4876-----
0.172130006.9466-----
0.177831006.8439-----
0.183632006.2545-----
0.189333005.9795-----
0.195034005.3904-----
0.200835006.2798-----
0.206536005.6882-----
0.212237006.195-----
0.218038005.8728-----
0.223739006.2428-----
0.229440005.801-----
0.235241005.6918-----
0.240942005.3977-----
0.246743005.8792-----
0.252444005.9297-----
0.258145006.161-----
0.263946005.6571-----
0.269647005.5849-----
0.275348005.6382-----
0.281149005.2978-----
0.286850005.108-----
0.292551005.1158-----
0.298352005.6218-----
0.304053005.643-----
0.309854005.6894-----
0.315555005.373-----
0.321256005.0673-----
0.327057005.1915-----
0.332758005.3705-----
0.338459005.6432-----
0.344260005.2567-----
0.349961005.4516-----
0.355662005.4844-----
0.361463004.8238-----
0.367164004.8271-----
0.372965004.9863-----
0.378666005.4894-----
0.384367004.95-----
0.390168005.0881-----
0.395869005.249-----
0.401570005.0082-----
0.407371005.5064-----
0.413072005.0885-----
0.418773005.0321-----
0.424574004.8212-----
0.430275005.4231-----
0.436076004.7687-----
0.441777004.5707-----
0.447478005.2229-----
0.453279005.2446-----
0.458980004.682-----
0.464681004.888-----
0.470482005.0496-----
0.476183004.7089-----
0.481884004.9567-----
0.487685004.7913-----
0.493386004.8904-----
0.499187005.247-----
0.504888004.8254-----
0.510589004.973-----
0.516390004.6657-----
0.522091004.9224-----
0.527792004.8163-----
0.533593004.3673-----
0.539294004.6509-----
0.544995005.0667-----
0.550796004.8771-----
0.556497005.1056-----
0.562298004.8297-----
0.567999005.0156-----
0.5736100005.0758-----
0.5794101004.9551-----
0.5851102004.9594-----
0.5908103005.136-----
0.5966104004.7873-----
0.6023105004.5154-----
0.6080106004.928-----
0.6138107005.1825-----
0.6195108005.046-----
0.6253109005.0111-----
0.6310110004.9458-----
0.6367111005.188-----
0.6425112004.6219-----
0.6482113005.3367-----
0.6539114004.9851-----
0.6597115005.2068-----
0.6654116004.3789-----
0.6711117005.3533-----
0.6769118005.3983-----
0.6826119004.6-----
0.6883120004.6668-----
0.6941121005.0814-----
0.6998122005.0787-----
0.7056123004.6325-----
0.7113124004.9415-----
0.7170125004.7053-----
0.7228126004.3212-----
0.7285127004.8205-----
0.7342128004.8602-----
0.7400129004.6944-----
0.7457130004.7785-----
0.7514131004.3515-----
0.7572132005.7561-----
0.7629133005.3526-----
0.7687134005.187-----
0.7744135005.0143-----
0.7801136004.515-----
0.7859137004.639-----
0.7916138004.5556-----
0.7973139004.3526-----
0.8031140004.3091-----
0.8088141004.1761-----
0.8145142004.0484-----
0.8203143004.1886-----
0.8260144004.237-----
0.8318145004.2167-----
0.8375146004.0329-----
0.8432147003.9902-----
0.8490148003.8211-----
0.8547149004.0048-----
0.8604150003.7979-----
0.8662151003.8117-----
0.8719152003.909-----
0.8776153003.8526-----
0.8834154003.79-----
0.8891155003.7792-----
0.8949156003.7469-----
0.9006157003.8387-----
0.9063158003.6418-----
0.9121159003.645-----
0.9178160003.4861-----
0.9235161003.6416-----
0.9293162003.6665-----
0.9350163003.6809-----
0.9407164003.7944-----
0.9465165003.6585-----
0.9522166003.5398-----
0.9580167003.7036-----
0.9637168003.6386-----
0.9694169003.5501-----
0.9752170003.7957-----
0.9809171003.6076-----
0.9866172003.4653-----
0.9924173003.6768-----
0.9981174003.49-----
1.017433-0.70510.70440.70460.70440.7065

</details>

Framework Versions

  • —Python: 3.11.9
  • —Sentence Transformers: 3.0.1
  • —Transformers: 4.40.1
  • —PyTorch: 2.3.0+cu121
  • —Accelerate: 0.29.3
  • —Datasets: 2.19.0
  • —Tokenizers: 0.19.1

Citation

BibTeX

Sentence Transformers
bibtex
@inproceedings{reimers-2019-sentence-bert,
    title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
    author = "Reimers, Nils and Gurevych, Iryna",
    booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
    month = "11",
    year = "2019",
    publisher = "Association for Computational Linguistics",
    url = "https://arxiv.org/abs/1908.10084",
}
MatryoshkaLoss
bibtex
@misc{kusupati2024matryoshka,
    title={Matryoshka Representation Learning}, 
    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},
    year={2024},
    eprint={2205.13147},
    archivePrefix={arXiv},
    primaryClass={cs.LG}
}
MultipleNegativesRankingLoss
bibtex
@misc{henderson2017efficient,
    title={Efficient Natural Language Response Suggestion for Smart Reply}, 
    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},
    year={2017},
    eprint={1705.00652},
    archivePrefix={arXiv},
    primaryClass={cs.CL}
}

<!--

Glossary

Clearly define terms in order to be accessible across audiences. -->

<!--

Model Card Authors

Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction. -->

<!--

Model Card Contact

Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors. -->