CoolFace
Modelpublic

codersan/FaLaBSE-v6

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes71downloads
Model Card

SentenceTransformer based on sentence-transformers/LaBSE

This is a sentence-transformers model finetuned from sentence-transformers/LaBSE. 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: sentence-transformers/LaBSE <!-- at revision b7f947194ceae0ddf90bafe213722569e274ad28 -->
  • Maximum Sequence Length: 256 tokens
  • Output Dimensionality: 768 dimensions
  • Similarity Function: Cosine Similarity <!-- - Training Dataset: Unknown --> <!-- - Language: Unknown --> <!-- - License: Unknown -->

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 256, 'do_lower_case': False}) with Transformer model: BertModel 
  (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})
  (2): Dense({'in_features': 768, 'out_features': 768, 'bias': True, 'activation_function': 'torch.nn.modules.activation.Tanh'})
  (3): Normalize()
)

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("codersan/FaLaBSE-v6")
# Run inference
sentences = [
    'آیا با دختری که باکره نیست ازدواج خواهید کرد؟',
    'آیا با کسی که باکره نیست ازدواج می کنید؟',
    'زنی با شلوار جین کنار اسبی با زین ایستاده است',
]
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. -->

<!--

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 Dataset

Unnamed Dataset
  • Size: 149,098 training samples
  • Columns: <code>anchor</code> and <code>positive</code>
  • Approximate statistics based on the first 1000 samples: | | anchor | positive | |:--------|:---------------------------------------------------------------------------------|:----------------------------------------------------------------------------------| | type | string | string | | details | <ul><li>min: 5 tokens</li><li>mean: 15.1 tokens</li><li>max: 76 tokens</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 14.54 tokens</li><li>max: 57 tokens</li></ul> |
  • Samples: | anchor | positive | |:---------------------------------------------------------------------|:-------------------------------------------------------------------| | <code>اگر هند تقسیم نشده بود ، هند امروز چگونه به نظر می رسد؟</code> | <code>اگر پارتیشن اتفاق نیفتاد ، هند امروز چگونه خواهد بود؟</code> | | <code>چگونه می توانم وارد امنیت اینترنت شوم؟</code> | <code>چگونه می توانم شروع به یادگیری امنیت اطلاعات کنم؟</code> | | <code>برخی از بهترین مؤسسات مربیگری GMAT در دهلی/NCR چیست؟</code> | <code>بهترین مؤسسات مربیگری برای GMAT در NCR چیست؟</code> |
  • Loss: <code>MultipleNegativesRankingLoss</code> with these parameters:
json
  {
      "scale": 20.0,
      "similarity_fct": "cos_sim"
  }

Training Hyperparameters

Non-Default Hyperparameters
  • per_device_train_batch_size: 32
  • learning_rate: 3e-05
  • weight_decay: 0.15
  • num_train_epochs: 10
  • warmup_ratio: 0.15
  • batch_sampler: no_duplicates
All Hyperparameters

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

  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: no
  • prediction_loss_only: True
  • per_device_train_batch_size: 32
  • per_device_eval_batch_size: 8
  • per_gpu_train_batch_size: None
  • per_gpu_eval_batch_size: None
  • gradient_accumulation_steps: 1
  • eval_accumulation_steps: None
  • torch_empty_cache_steps: None
  • learning_rate: 3e-05
  • weight_decay: 0.15
  • adam_beta1: 0.9
  • adam_beta2: 0.999
  • adam_epsilon: 1e-08
  • max_grad_norm: 1.0
  • num_train_epochs: 10
  • max_steps: -1
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: {}
  • warmup_ratio: 0.15
  • 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
  • restore_callback_states_from_checkpoint: False
  • no_cuda: False
  • use_cpu: False
  • use_mps_device: False
  • seed: 42
  • data_seed: None
  • jit_mode_eval: False
  • use_ipex: False
  • bf16: False
  • 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, 'nonblocking': False, 'gradientaccumulationkwargs': 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: None
  • hub_always_push: False
  • gradient_checkpointing: False
  • gradient_checkpointing_kwargs: None
  • include_inputs_for_metrics: False
  • include_for_metrics: []
  • 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_eval_metrics: False
  • eval_on_start: False
  • use_liger_kernel: False
  • eval_use_gather_object: False
  • average_tokens_across_devices: False
  • prompts: None
  • batch_sampler: no_duplicates
  • multi_dataset_batch_sampler: proportional

</details>

Training Logs

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

EpochStepTraining Loss
0.04291000.1219
0.08582000.0626
0.12883000.0489
0.17174000.0414
0.21465000.0432
0.25756000.0419
0.30047000.0313
0.34338000.0339
0.38639000.0317
0.429210000.035
0.472111000.0378
0.515012000.0308
0.557913000.0305
0.600914000.0312
0.643815000.0304
0.686716000.0295
0.729617000.0301
0.772518000.033
0.815519000.0263
0.858420000.0276
0.901321000.0236
0.944222000.0276
0.987123000.0278
1.030024000.0309
1.073025000.0269
1.115926000.0299
1.158827000.0272
1.201728000.029
1.244629000.0309
1.287630000.0247
1.330531000.0244
1.373432000.0261
1.416333000.0254
1.459234000.0273
1.502135000.0298
1.545136000.0225
1.588037000.0278
1.630938000.027
1.673839000.0218
1.716740000.0247
1.759741000.023
1.802642000.0225
1.845543000.0191
1.888444000.0174
1.931345000.0214
1.974246000.018
2.017247000.0227
2.060148000.0222
2.103049000.0211
2.145950000.0204
2.188851000.0215
2.231852000.0206
2.274753000.0213
2.317654000.0168
2.360555000.0189
2.403456000.0206
2.446457000.0194
2.489358000.0182
2.532259000.017
2.575160000.0186
2.618061000.017
2.660962000.0152
2.703963000.0164
2.746864000.0142
2.789765000.0162
2.832666000.0123
2.875567000.0162
2.918568000.0138
2.961469000.0163
3.004370000.0138
3.047271000.0164
3.090172000.016
3.133073000.0175
3.176074000.0143
3.218975000.0142
3.261876000.0176
3.304777000.0147
3.347678000.0164
3.390679000.0133
3.433580000.0168
3.476481000.0166
3.519382000.0138
3.562283000.0126
3.605284000.0145
3.648185000.0114
3.691086000.0137
3.733987000.014
3.776888000.0134
3.819789000.0108
3.862790000.012
3.905691000.0102
3.948592000.0119
3.991493000.0122
4.034394000.0116
4.077395000.0136
4.120296000.0135
4.163197000.0108
4.206098000.0119
4.248999000.0142
4.2918100000.0111
4.3348101000.0131
4.3777102000.0103
4.4206103000.0124
4.4635104000.0163
4.5064105000.0123
4.5494106000.0112
4.5923107000.01
4.6352108000.0096
4.6781109000.0103
4.7210110000.0102
4.7639111000.0092
4.8069112000.0107
4.8498113000.0114
4.8927114000.0091
4.9356115000.0108
4.9785116000.0092
5.0215117000.0086
5.0644118000.0104
5.1073119000.0123
5.1502120000.009
5.1931121000.0106
5.2361122000.0114
5.2790123000.0098
5.3219124000.0093
5.3648125000.0092
5.4077126000.011
5.4506127000.0113
5.4936128000.0091
5.5365129000.0079
5.5794130000.01
5.6223131000.0067
5.6652132000.0081
5.7082133000.0097
5.7511134000.0081
5.7940135000.0094
5.8369136000.0074
5.8798137000.0071
5.9227138000.0074
5.9657139000.0076
6.0086140000.0063
6.0515141000.0083
6.0944142000.0101
6.1373143000.0084
6.1803144000.0074
6.2232145000.007
6.2661146000.0078
6.3090147000.0074
6.3519148000.0086
6.3948149000.0069
6.4378150000.0083
6.4807151000.0082
6.5236152000.0066
6.5665153000.0086
6.6094154000.0059
6.6524155000.0052
6.6953156000.0081
6.7382157000.0054
6.7811158000.0063
6.8240159000.0065
6.8670160000.0068
6.9099161000.0047
6.9528162000.0065
6.9957163000.0064
7.0386164000.0051
7.0815165000.0066
7.1245166000.0069
7.1674167000.0074
7.2103168000.0062
7.2532169000.0071
7.2961170000.005
7.3391171000.008
7.3820172000.0047
7.4249173000.0073
7.4678174000.0078
7.5107175000.0058
7.5536176000.0055
7.5966177000.0049
7.6395178000.0046
7.6824179000.0051
7.7253180000.005
7.7682181000.0059
7.8112182000.0056
7.8541183000.0049
7.8970184000.0038
7.9399185000.005
7.9828186000.005
8.0258187000.0036
8.0687188000.0049
8.1116189000.0067
8.1545190000.0056
8.1974191000.0061
8.2403192000.0054
8.2833193000.0046
8.3262194000.0048
8.3691195000.0052
8.4120196000.0059
8.4549197000.0053
8.4979198000.0049
8.5408199000.0036
8.5837200000.0049
8.6266201000.0033
8.6695202000.0049
8.7124203000.0043
8.7554204000.0039
8.7983205000.0038
8.8412206000.0035
8.8841207000.0041
8.9270208000.0042
8.9700209000.0056
9.0129210000.0031
9.0558211000.004
9.0987212000.0043
9.1416213000.0047
9.1845214000.0051
9.2275215000.0032
9.2704216000.0045
9.3133217000.0038
9.3562218000.0045
9.3991219000.0047
9.4421220000.0048
9.4850221000.0042
9.5279222000.0039
9.5708223000.0042
9.6137224000.003
9.6567225000.0031
9.6996226000.0042
9.7425227000.0028
9.7854228000.0037
9.8283229000.0035
9.8712230000.0033
9.9142231000.0029
9.9571232000.0048
10.0233000.0039

</details>

Framework Versions

  • Python: 3.10.12
  • Sentence Transformers: 3.3.1
  • Transformers: 4.47.0
  • PyTorch: 2.5.1+cu121
  • Accelerate: 1.2.1
  • Datasets: 3.2.0
  • Tokenizers: 0.21.0

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",
}
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. -->