SentenceTransformer based on sentence-transformers/all-MiniLM-L6-v2
This is a sentence-transformers model finetuned from sentence-transformers/all-MiniLM-L6-v2. It maps sentences & paragraphs to a 384-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/all-MiniLM-L6-v2
- Maximum Sequence Length: 256 tokens
- Output Dimensionality: 384 dimensions
- Similarity Function: Cosine Similarity
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': 256, 'do_lower_case': False}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 384, '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})
(2): Normalize()
)
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("aleynahukmet/all-MiniLM-L6-v2-8-layers")
# Run inference
sentences = [
'A black dog is drinking next to a brown and white dog that is looking at an orange ball in the lake, whilst a horse and rider passes behind.',
'There are two people running around a track in lane three and the one wearing a blue shirt with a green thing over the eyes is just barely ahead of the guy wearing an orange shirt and sunglasses.',
'the guy is dead',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
Evaluation
Metrics
Semantic Similarity
- Datasets:
sts-dev
andsts-test
- Evaluated with
EmbeddingSimilarityEvaluator
Metric | sts-dev | sts-test |
---|---|---|
pearson_cosine | 0.8649 | 0.8203 |
spearman_cosine | 0.8649 | 0.819 |
Knowledge Distillation
- Evaluated with
MSEEvaluator
Metric | Value |
---|---|
negative_mse | -0.0245 |
Training Details
Training Dataset
Unnamed Dataset
- Size: 9,014,210 training samples
- Columns:
sentence
andlabel
- Approximate statistics based on the first 1000 samples:
sentence label type string list details - min: 4 tokens
- mean: 12.24 tokens
- max: 52 tokens
- size: 384 elements
- Samples:
sentence label A person on a horse jumps over a broken down airplane.
[-0.009216307662427425, 0.003964003175497055, 0.04029734805226326, 0.0030935262329876423, -0.03516044840216637, ...]
Children smiling and waving at camera
[-0.03215238079428673, 0.06086821109056473, 0.013251038268208504, -0.017755677923560143, 0.07927625626325607, ...]
A boy is jumping on skateboard in the middle of a red bridge.
[-0.020561737939715385, -0.03641558438539505, -0.039370208978652954, -0.0975518748164177, 0.005307587794959545, ...]
- Loss:
MSELoss
Evaluation Dataset
Unnamed Dataset
- Size: 10,000 evaluation samples
- Columns:
sentence
andlabel
- Approximate statistics based on the first 1000 samples:
sentence label type string list details - min: 5 tokens
- mean: 13.23 tokens
- max: 57 tokens
- size: 384 elements
- Samples:
sentence label Two women are embracing while holding to go packages.
[-0.007923883385956287, -0.024198176339268684, 0.034445445984601974, 0.036053989082574844, -0.06740871071815491, ...]
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.
[-0.08869566023349762, 0.02789478376507759, 0.060685668140649796, -0.02580258436501026, 0.008359752595424652, ...]
A man selling donuts to a customer during a world exhibition event held in the city of Angeles
[0.027255145832896233, 0.07622072845697403, 0.025504805147647858, -0.0542026124894619, -0.052822694182395935, ...]
- Loss:
MSELoss
Training Hyperparameters
Non-Default Hyperparameters
eval_strategy
: stepsper_device_train_batch_size
: 64per_device_eval_batch_size
: 64learning_rate
: 0.0001num_train_epochs
: 1warmup_ratio
: 0.1fp16
: Trueload_best_model_at_end
: True
All Hyperparameters
Click to expand
overwrite_output_dir
: Falsedo_predict
: Falseeval_strategy
: stepsprediction_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
: Nonetorch_empty_cache_steps
: Nonelearning_rate
: 0.0001weight_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
: 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
: Trueignore_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
: Falseeval_on_start
: Falseeval_use_gather_object
: Falseprompts
: Nonebatch_sampler
: batch_samplermulti_dataset_batch_sampler
: proportional
Training Logs
Click to expand
Epoch | Step | Training Loss | Validation Loss | sts-dev_spearman_cosine | negative_mse | sts-test_spearman_cosine |
---|---|---|---|---|---|---|
0 | 0 | - | - | 0.7048 | -0.3846 | - |
0.0071 | 1000 | 0.0032 | - | - | - | - |
0.0142 | 2000 | 0.0023 | - | - | - | - |
0.0213 | 3000 | 0.0019 | - | - | - | - |
0.0284 | 4000 | 0.0017 | - | - | - | - |
0.0355 | 5000 | 0.0015 | 0.0013 | 0.8149 | -0.1309 | - |
0.0426 | 6000 | 0.0014 | - | - | - | - |
0.0497 | 7000 | 0.0012 | - | - | - | - |
0.0568 | 8000 | 0.0011 | - | - | - | - |
0.0639 | 9000 | 0.001 | - | - | - | - |
0.0710 | 10000 | 0.001 | 0.0008 | 0.8495 | -0.0754 | - |
0.0781 | 11000 | 0.0009 | - | - | - | - |
0.0852 | 12000 | 0.0008 | - | - | - | - |
0.0923 | 13000 | 0.0008 | - | - | - | - |
0.0994 | 14000 | 0.0007 | - | - | - | - |
0.1065 | 15000 | 0.0007 | 0.0005 | 0.8569 | -0.0528 | - |
0.1136 | 16000 | 0.0007 | - | - | - | - |
0.1207 | 17000 | 0.0007 | - | - | - | - |
0.1278 | 18000 | 0.0006 | - | - | - | - |
0.1349 | 19000 | 0.0006 | - | - | - | - |
0.1420 | 20000 | 0.0006 | 0.0004 | 0.8589 | -0.0438 | - |
0.1491 | 21000 | 0.0006 | - | - | - | - |
0.1562 | 22000 | 0.0006 | - | - | - | - |
0.1633 | 23000 | 0.0006 | - | - | - | - |
0.1704 | 24000 | 0.0006 | - | - | - | - |
0.1775 | 25000 | 0.0005 | 0.0004 | 0.8608 | -0.0392 | - |
0.1846 | 26000 | 0.0005 | - | - | - | - |
0.1917 | 27000 | 0.0005 | - | - | - | - |
0.1988 | 28000 | 0.0005 | - | - | - | - |
0.2059 | 29000 | 0.0005 | - | - | - | - |
0.2130 | 30000 | 0.0005 | 0.0004 | 0.8619 | -0.0363 | - |
0.2201 | 31000 | 0.0005 | - | - | - | - |
0.2272 | 32000 | 0.0005 | - | - | - | - |
0.2343 | 33000 | 0.0005 | - | - | - | - |
0.2414 | 34000 | 0.0005 | - | - | - | - |
0.2485 | 35000 | 0.0005 | 0.0003 | 0.8619 | -0.0343 | - |
0.2556 | 36000 | 0.0005 | - | - | - | - |
0.2627 | 37000 | 0.0005 | - | - | - | - |
0.2698 | 38000 | 0.0005 | - | - | - | - |
0.2769 | 39000 | 0.0005 | - | - | - | - |
0.2840 | 40000 | 0.0005 | 0.0003 | 0.8613 | -0.0329 | - |
0.2911 | 41000 | 0.0005 | - | - | - | - |
0.2982 | 42000 | 0.0005 | - | - | - | - |
0.3053 | 43000 | 0.0005 | - | - | - | - |
0.3124 | 44000 | 0.0005 | - | - | - | - |
0.3195 | 45000 | 0.0005 | 0.0003 | 0.8633 | -0.0316 | - |
0.3266 | 46000 | 0.0005 | - | - | - | - |
0.3337 | 47000 | 0.0005 | - | - | - | - |
0.3408 | 48000 | 0.0005 | - | - | - | - |
0.3479 | 49000 | 0.0004 | - | - | - | - |
0.3550 | 50000 | 0.0004 | 0.0003 | 0.8631 | -0.0306 | - |
0.3621 | 51000 | 0.0004 | - | - | - | - |
0.3692 | 52000 | 0.0004 | - | - | - | - |
0.3763 | 53000 | 0.0004 | - | - | - | - |
0.3834 | 54000 | 0.0004 | - | - | - | - |
0.3905 | 55000 | 0.0004 | 0.0003 | 0.8635 | -0.0297 | - |
0.3976 | 56000 | 0.0004 | - | - | - | - |
0.4047 | 57000 | 0.0004 | - | - | - | - |
0.4118 | 58000 | 0.0004 | - | - | - | - |
0.4189 | 59000 | 0.0004 | - | - | - | - |
0.4260 | 60000 | 0.0004 | 0.0003 | 0.8640 | -0.0290 | - |
0.4331 | 61000 | 0.0004 | - | - | - | - |
0.4402 | 62000 | 0.0004 | - | - | - | - |
0.4473 | 63000 | 0.0004 | - | - | - | - |
0.4544 | 64000 | 0.0004 | - | - | - | - |
0.4615 | 65000 | 0.0004 | 0.0003 | 0.8644 | -0.0285 | - |
0.4686 | 66000 | 0.0004 | - | - | - | - |
0.4757 | 67000 | 0.0004 | - | - | - | - |
0.4828 | 68000 | 0.0004 | - | - | - | - |
0.4899 | 69000 | 0.0004 | - | - | - | - |
0.4970 | 70000 | 0.0004 | 0.0003 | 0.8641 | -0.0280 | - |
0.5041 | 71000 | 0.0004 | - | - | - | - |
0.5112 | 72000 | 0.0004 | - | - | - | - |
0.5183 | 73000 | 0.0004 | - | - | - | - |
0.5254 | 74000 | 0.0004 | - | - | - | - |
0.5325 | 75000 | 0.0004 | 0.0003 | 0.8648 | -0.0276 | - |
0.5396 | 76000 | 0.0004 | - | - | - | - |
0.5467 | 77000 | 0.0004 | - | - | - | - |
0.5538 | 78000 | 0.0004 | - | - | - | - |
0.5609 | 79000 | 0.0004 | - | - | - | - |
0.5680 | 80000 | 0.0004 | 0.0003 | 0.8644 | -0.0271 | - |
0.5751 | 81000 | 0.0004 | - | - | - | - |
0.5822 | 82000 | 0.0004 | - | - | - | - |
0.5893 | 83000 | 0.0004 | - | - | - | - |
0.5964 | 84000 | 0.0004 | - | - | - | - |
0.6035 | 85000 | 0.0004 | 0.0003 | 0.8648 | -0.0267 | - |
0.6106 | 86000 | 0.0004 | - | - | - | - |
0.6177 | 87000 | 0.0004 | - | - | - | - |
0.6248 | 88000 | 0.0004 | - | - | - | - |
0.6319 | 89000 | 0.0004 | - | - | - | - |
0.6390 | 90000 | 0.0004 | 0.0003 | 0.8645 | -0.0264 | - |
0.6461 | 91000 | 0.0004 | - | - | - | - |
0.6532 | 92000 | 0.0004 | - | - | - | - |
0.6603 | 93000 | 0.0004 | - | - | - | - |
0.6674 | 94000 | 0.0004 | - | - | - | - |
0.6745 | 95000 | 0.0004 | 0.0003 | 0.8643 | -0.0261 | - |
0.6816 | 96000 | 0.0004 | - | - | - | - |
0.6887 | 97000 | 0.0004 | - | - | - | - |
0.6958 | 98000 | 0.0004 | - | - | - | - |
0.7029 | 99000 | 0.0004 | - | - | - | - |
0.7100 | 100000 | 0.0004 | 0.0003 | 0.8643 | -0.0259 | - |
0.7171 | 101000 | 0.0004 | - | - | - | - |
0.7242 | 102000 | 0.0004 | - | - | - | - |
0.7313 | 103000 | 0.0004 | - | - | - | - |
0.7384 | 104000 | 0.0004 | - | - | - | - |
0.7455 | 105000 | 0.0004 | 0.0003 | 0.8646 | -0.0257 | - |
0.7526 | 106000 | 0.0004 | - | - | - | - |
0.7597 | 107000 | 0.0004 | - | - | - | - |
0.7668 | 108000 | 0.0004 | - | - | - | - |
0.7739 | 109000 | 0.0004 | - | - | - | - |
0.7810 | 110000 | 0.0004 | 0.0003 | 0.8637 | -0.0254 | - |
0.7881 | 111000 | 0.0004 | - | - | - | - |
0.7952 | 112000 | 0.0004 | - | - | - | - |
0.8023 | 113000 | 0.0004 | - | - | - | - |
0.8094 | 114000 | 0.0004 | - | - | - | - |
0.8165 | 115000 | 0.0004 | 0.0003 | 0.8643 | -0.0252 | - |
0.8236 | 116000 | 0.0004 | - | - | - | - |
0.8307 | 117000 | 0.0004 | - | - | - | - |
0.8378 | 118000 | 0.0004 | - | - | - | - |
0.8449 | 119000 | 0.0004 | - | - | - | - |
0.8520 | 120000 | 0.0004 | 0.0003 | 0.8645 | -0.0250 | - |
0.8591 | 121000 | 0.0004 | - | - | - | - |
0.8662 | 122000 | 0.0004 | - | - | - | - |
0.8733 | 123000 | 0.0004 | - | - | - | - |
0.8804 | 124000 | 0.0004 | - | - | - | - |
0.8875 | 125000 | 0.0004 | 0.0002 | 0.8646 | -0.0248 | - |
0.8946 | 126000 | 0.0004 | - | - | - | - |
0.9017 | 127000 | 0.0004 | - | - | - | - |
0.9088 | 128000 | 0.0004 | - | - | - | - |
0.9159 | 129000 | 0.0004 | - | - | - | - |
0.9230 | 130000 | 0.0004 | 0.0002 | 0.8647 | -0.0247 | - |
0.9301 | 131000 | 0.0004 | - | - | - | - |
0.9372 | 132000 | 0.0004 | - | - | - | - |
0.9443 | 133000 | 0.0004 | - | - | - | - |
0.9514 | 134000 | 0.0004 | - | - | - | - |
0.9585 | 135000 | 0.0004 | 0.0002 | 0.8646 | -0.0246 | - |
0.9656 | 136000 | 0.0004 | - | - | - | - |
0.9727 | 137000 | 0.0004 | - | - | - | - |
0.9798 | 138000 | 0.0004 | - | - | - | - |
0.9869 | 139000 | 0.0004 | - | - | - | - |
0.994 | 140000 | 0.0004 | 0.0002 | 0.8649 | -0.0245 | - |
1.0 | 140848 | - | - | - | - | 0.8190 |
- The bold row denotes the saved checkpoint.
Framework Versions
- Python: 3.12.4
- Sentence Transformers: 3.3.1
- Transformers: 4.44.2
- PyTorch: 2.4.1+cu121
- Accelerate: 1.0.1
- Datasets: 2.19.0
- 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",
}
MSELoss
@inproceedings{reimers-2020-multilingual-sentence-bert,
title = "Making Monolingual Sentence Embeddings Multilingual using Knowledge Distillation",
author = "Reimers, Nils and Gurevych, Iryna",
booktitle = "Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing",
month = "11",
year = "2020",
publisher = "Association for Computational Linguistics",
url = "https://arxiv.org/abs/2004.09813",
}
- Downloads last month
- 12
Inference Providers
NEW
This model is not currently available via any of the supported third-party Inference Providers, and
the model is not deployed on the HF Inference API.
Model tree for aleynahukmet/all-MiniLM-L6-v2-8-layers
Base model
sentence-transformers/all-MiniLM-L6-v2Evaluation results
- Pearson Cosine on sts devself-reported0.865
- Spearman Cosine on sts devself-reported0.865
- Negative Mse on Unknownself-reported-0.025
- Pearson Cosine on sts testself-reported0.820
- Spearman Cosine on sts testself-reported0.819