metadata
language:
- en
library_name: sentence-transformers
tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- dataset_size:100K<n<1M
- loss:CachedMultipleNegativesRankingLoss
base_model: facebook/xlm-roberta-xl
metrics:
- cosine_accuracy
- dot_accuracy
- manhattan_accuracy
- euclidean_accuracy
- max_accuracy
widget:
- source_sentence: A bird flying.
sentences:
- A butterfly flys freely.
- the animal is running
- The woman is asleep.
- source_sentence: There's a dock
sentences:
- The boat is sinking
- A man is ice skating.
- A man is sleeping.
- source_sentence: A woman sings.
sentences:
- The woman is singing.
- The girl is standing.
- A boy is sledding
- source_sentence: The boy scowls
sentences:
- The boy is smiling
- a child eats cheerios
- A woman is sitting.
- source_sentence: a baby smiling
sentences:
- The boy is smiling
- The woman is fishing.
- A man is sitting down.
pipeline_tag: sentence-similarity
model-index:
- name: SentenceTransformer based on facebook/xlm-roberta-xl
results:
- task:
type: triplet
name: Triplet
dataset:
name: all nli dev
type: all-nli-dev
metrics:
- type: cosine_accuracy
value: 0.931
name: Cosine Accuracy
- type: dot_accuracy
value: 0.063
name: Dot Accuracy
- type: manhattan_accuracy
value: 0.931
name: Manhattan Accuracy
- type: euclidean_accuracy
value: 0.927
name: Euclidean Accuracy
- type: max_accuracy
value: 0.931
name: Max Accuracy
- task:
type: triplet
name: Triplet
dataset:
name: all nli test
type: all-nli-test
metrics:
- type: cosine_accuracy
value: 0.939
name: Cosine Accuracy
- type: dot_accuracy
value: 0.056
name: Dot Accuracy
- type: manhattan_accuracy
value: 0.936
name: Manhattan Accuracy
- type: euclidean_accuracy
value: 0.938
name: Euclidean Accuracy
- type: max_accuracy
value: 0.939
name: Max Accuracy
SentenceTransformer based on facebook/xlm-roberta-xl
This is a sentence-transformers model finetuned from facebook/xlm-roberta-xl on the sentence-transformers/all-nli dataset. It maps sentences & paragraphs to a 2560-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: facebook/xlm-roberta-xl
- Maximum Sequence Length: 514 tokens
- Output Dimensionality: 2560 tokens
- Similarity Function: Cosine Similarity
- Training Dataset:
- Language: en
Model Sources
- Documentation: Sentence Transformers Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Sentence Transformers on Hugging Face
Full Model Architecture
SentenceTransformer(
(0): Transformer({'max_seq_length': 514, 'do_lower_case': False}) with Transformer model: XLMRobertaXLModel
(1): Pooling({'word_embedding_dimension': 2560, '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:
pip install -U sentence-transformers
Then you can load this model and run inference.
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("sentence_transformers_model_id")
# Run inference
sentences = [
'a baby smiling',
'The boy is smiling',
'The woman is fishing.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 2560]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
Evaluation
Metrics
Triplet
- Dataset:
all-nli-dev
- Evaluated with
TripletEvaluator
Metric | Value |
---|---|
cosine_accuracy | 0.931 |
dot_accuracy | 0.063 |
manhattan_accuracy | 0.931 |
euclidean_accuracy | 0.927 |
max_accuracy | 0.931 |
Triplet
- Dataset:
all-nli-test
- Evaluated with
TripletEvaluator
Metric | Value |
---|---|
cosine_accuracy | 0.939 |
dot_accuracy | 0.056 |
manhattan_accuracy | 0.936 |
euclidean_accuracy | 0.938 |
max_accuracy | 0.939 |
Training Details
Training Dataset
sentence-transformers/all-nli
- Dataset: sentence-transformers/all-nli at d482672
- Size: 100,000 training samples
- Columns:
anchor
,positive
, andnegative
- Approximate statistics based on the first 1000 samples:
anchor positive negative type string string string details - min: 7 tokens
- mean: 10.9 tokens
- max: 52 tokens
- min: 6 tokens
- mean: 13.62 tokens
- max: 42 tokens
- min: 5 tokens
- mean: 14.76 tokens
- max: 55 tokens
- Samples:
anchor positive negative A person on a horse jumps over a broken down airplane.
A person is outdoors, on a horse.
A person is at a diner, ordering an omelette.
Children smiling and waving at camera
There are children present
The kids are frowning
A boy is jumping on skateboard in the middle of a red bridge.
The boy does a skateboarding trick.
The boy skates down the sidewalk.
- Loss:
CachedMultipleNegativesRankingLoss
with these parameters:{ "scale": 20.0, "similarity_fct": "cos_sim" }
Evaluation Dataset
sentence-transformers/all-nli
- Dataset: sentence-transformers/all-nli at d482672
- Size: 1,000 evaluation samples
- Columns:
anchor
,positive
, andnegative
- Approximate statistics based on the first 1000 samples:
anchor positive negative type string string string details - min: 6 tokens
- mean: 20.31 tokens
- max: 83 tokens
- min: 5 tokens
- mean: 10.71 tokens
- max: 35 tokens
- min: 5 tokens
- mean: 11.39 tokens
- max: 32 tokens
- Samples:
anchor positive negative Two women are embracing while holding to go packages.
Two woman are holding packages.
The men are fighting outside a deli.
Two young children in blue jerseys, one with the number 9 and one with the number 2 are standing on wooden steps in a bathroom and washing their hands in a sink.
Two kids in numbered jerseys wash their hands.
Two kids in jackets walk to school.
A man selling donuts to a customer during a world exhibition event held in the city of Angeles
A man selling donuts to a customer.
A woman drinks her coffee in a small cafe.
- Loss:
CachedMultipleNegativesRankingLoss
with these parameters:{ "scale": 20.0, "similarity_fct": "cos_sim" }
Training Hyperparameters
Non-Default Hyperparameters
eval_strategy
: stepsper_device_train_batch_size
: 16per_device_eval_batch_size
: 16num_train_epochs
: 1warmup_ratio
: 0.1bf16
: Truebatch_sampler
: no_duplicates
All Hyperparameters
Click to expand
overwrite_output_dir
: Falsedo_predict
: Falseeval_strategy
: stepsprediction_loss_only
: Trueper_device_train_batch_size
: 16per_device_eval_batch_size
: 16per_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
: 1max_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
: Falserestore_callback_states_from_checkpoint
: Falseno_cuda
: Falseuse_cpu
: Falseuse_mps_device
: Falseseed
: 42data_seed
: Nonejit_mode_eval
: Falseuse_ipex
: Falsebf16
: Truefp16
: Falsefp16_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, 'non_blocking': False, '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_eval_metrics
: Falsebatch_sampler
: no_duplicatesmulti_dataset_batch_sampler
: proportional
Training Logs
Epoch | Step | Training Loss | loss | all-nli-dev_max_accuracy | all-nli-test_max_accuracy |
---|---|---|---|---|---|
0 | 0 | - | - | 0.536 | - |
0.016 | 100 | 3.4661 | 3.3640 | 0.54 | - |
0.032 | 200 | 3.4151 | 3.3148 | 0.592 | - |
0.048 | 300 | 3.1576 | 1.8296 | 0.82 | - |
0.064 | 400 | 1.2552 | 0.8366 | 0.879 | - |
0.08 | 500 | 0.9262 | 0.8402 | 0.888 | - |
0.096 | 600 | 1.0456 | 0.8762 | 0.899 | - |
0.112 | 700 | 0.9238 | 0.7967 | 0.894 | - |
0.128 | 800 | 1.0304 | 0.8797 | 0.881 | - |
0.144 | 900 | 1.1126 | 0.7939 | 0.903 | - |
0.16 | 1000 | 1.0165 | 0.7052 | 0.908 | - |
0.176 | 1100 | 1.06 | 0.6926 | 0.905 | - |
0.192 | 1200 | 0.9598 | 0.6843 | 0.894 | - |
0.208 | 1300 | 0.7719 | 0.6999 | 0.894 | - |
0.224 | 1400 | 0.7425 | 0.6932 | 0.902 | - |
0.24 | 1500 | 0.8434 | 0.5910 | 0.914 | - |
0.256 | 1600 | 0.6589 | 0.6143 | 0.903 | - |
0.272 | 1700 | 0.8642 | 0.6560 | 0.906 | - |
0.288 | 1800 | 0.838 | 0.6180 | 0.907 | - |
0.304 | 1900 | 0.8458 | 0.6097 | 0.91 | - |
0.32 | 2000 | 0.774 | 0.5675 | 0.914 | - |
0.336 | 2100 | 0.63 | 0.5917 | 0.909 | - |
0.352 | 2200 | 0.6185 | 0.5801 | 0.911 | - |
0.368 | 2300 | 0.8125 | 0.5623 | 0.915 | - |
0.384 | 2400 | 0.8478 | 0.5355 | 0.91 | - |
0.4 | 2500 | 0.7576 | 0.5490 | 0.91 | - |
0.416 | 2600 | 0.6457 | 0.5197 | 0.913 | - |
0.432 | 2700 | 0.918 | 0.5464 | 0.91 | - |
0.448 | 2800 | 0.8934 | 0.5375 | 0.91 | - |
0.464 | 2900 | 0.8407 | 0.5175 | 0.915 | - |
0.48 | 3000 | 0.7036 | 0.5054 | 0.919 | - |
0.496 | 3100 | 0.7929 | 0.5101 | 0.912 | - |
0.512 | 3200 | 0.613 | 0.4948 | 0.914 | - |
0.528 | 3300 | 0.5894 | 0.4953 | 0.915 | - |
0.544 | 3400 | 0.5885 | 0.4931 | 0.915 | - |
0.56 | 3500 | 0.6328 | 0.4868 | 0.921 | - |
0.576 | 3600 | 0.6128 | 0.4768 | 0.919 | - |
0.592 | 3700 | 0.5823 | 0.4730 | 0.922 | - |
0.608 | 3800 | 0.5633 | 0.4638 | 0.922 | - |
0.624 | 3900 | 0.5729 | 0.4587 | 0.926 | - |
0.64 | 4000 | 0.7778 | 0.4590 | 0.925 | - |
0.656 | 4100 | 1.0064 | 0.4550 | 0.925 | - |
0.672 | 4200 | 0.9683 | 0.4505 | 0.927 | - |
0.688 | 4300 | 0.7752 | 0.4470 | 0.926 | - |
0.704 | 4400 | 0.6738 | 0.4421 | 0.927 | - |
0.72 | 4500 | 0.6862 | 0.4374 | 0.928 | - |
0.736 | 4600 | 0.7699 | 0.4361 | 0.93 | - |
0.752 | 4700 | 0.72 | 0.4329 | 0.931 | - |
0.768 | 4800 | 0.7304 | 0.4306 | 0.929 | - |
0.784 | 4900 | 0.6679 | 0.4284 | 0.93 | - |
0.8 | 5000 | 0.7516 | 0.4285 | 0.93 | - |
0.816 | 5100 | 0.6286 | 0.4266 | 0.931 | - |
0.832 | 5200 | 0.7631 | 0.4274 | 0.931 | - |
0.848 | 5300 | 0.6368 | 0.4270 | 0.932 | - |
0.864 | 5400 | 0.767 | 0.4268 | 0.932 | - |
0.88 | 5500 | 0.6655 | 0.4254 | 0.933 | - |
0.896 | 5600 | 0.6599 | 0.4249 | 0.931 | - |
0.912 | 5700 | 0.722 | 0.4250 | 0.933 | - |
0.928 | 5800 | 0.682 | 0.4247 | 0.931 | - |
0.944 | 5900 | 0.7892 | 0.4245 | 0.931 | - |
0.96 | 6000 | 0.8095 | 0.4245 | 0.931 | - |
0.976 | 6100 | 0.6783 | 0.4243 | 0.932 | - |
0.992 | 6200 | 0.0051 | 0.4246 | 0.931 | - |
1.0 | 6250 | - | - | - | 0.939 |
Framework Versions
- Python: 3.9.10
- Sentence Transformers: 3.0.0
- Transformers: 4.41.2
- PyTorch: 2.3.0+cu121
- Accelerate: 0.26.1
- Datasets: 2.16.1
- Tokenizers: 0.19.1
Citation
BibTeX
Sentence Transformers
@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",
}
CachedMultipleNegativesRankingLoss
@misc{gao2021scaling,
title={Scaling Deep Contrastive Learning Batch Size under Memory Limited Setup},
author={Luyu Gao and Yunyi Zhang and Jiawei Han and Jamie Callan},
year={2021},
eprint={2101.06983},
archivePrefix={arXiv},
primaryClass={cs.LG}
}