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, 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
- Supported Modality: Text
Model Sources
- Documentation: Sentence Transformers Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Sentence Transformers on Hugging Face
Full Model Architecture
SentenceTransformer(
(0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'BertModel'})
(1): Pooling({'embedding_dimension': 384, 'pooling_mode': 'mean', '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("alisha2006/beacon-minilm-v1")
# Run inference
sentences = [
'As recorded earlier, the agreed direction for the Q3 marketing spend was ₹5 lakh.',
'In the current meeting, leadership decided that the Q3 marketing spend is now ₹7.5 lakh.',
"During today's discussion, the frontend state management was confirmed as Context API.",
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[ 1.0000, 0.9976, -0.0033],
# [ 0.9976, 1.0000, -0.0019],
# [-0.0033, -0.0019, 1.0000]])
Evaluation
Metrics
Semantic Similarity
- Dataset:
val_evaluator - Evaluated with EmbeddingSimilarityEvaluator
| Metric | Value |
|---|---|
| pearson_cosine | 0.9967 |
| spearman_cosine | 0.8657 |
Training Details
Training Dataset
Unnamed Dataset
- Size: 10,500 training samples
- Columns: sentence1, sentence2, and score
- Approximate statistics based on the first 100 samples:
sentence1 sentence2 score type string string float modality text text details min: 14 tokensmean: 20.44 tokensmax: 27 tokens min: 16 tokensmean: 22.17 tokensmax: 29 tokens min: 0.0mean: 0.57max: 1.0 - Samples:
sentence1 sentence2 score Initial decisions established that the authentication protocol would run on OAuth 2.0. In the latest debrief, the team voted that the external branding agency is switched to DDB Mudra. 0.0 Earlier discussions concluded that the Q3 marketing spend would be $50,000. The current status update reveals that the data retention window is finalized as archived for 6 months. 0.0 The team earlier confirmed that the target customer segment was set to early-stage tech startups. In the current meeting, leadership decided that the target customer segment is now early-stage tech startups. 1.0 - Loss: CosineSimilarityLoss with these parameters:
{ "loss_fct": "torch.nn.modules.loss.MSELoss", "cos_score_transformation": "torch.nn.modules.linear.Identity" }
Evaluation Dataset
Unnamed Dataset
- Size: 2,250 evaluation samples
- Columns: sentence1, sentence2, and score
- Approximate statistics based on the first 100 samples:
sentence1 sentence2 score type string string float modality text text details min: 15 tokensmean: 20.34 tokensmax: 29 tokens min: 17 tokensmean: 21.98 tokensmax: 29 tokens min: 0.0mean: 0.44max: 1.0 - Samples:
sentence1 sentence2 score Earlier discussions concluded that the external branding agency would be In-house design crew. Today's agenda concluded that the primary database will currently operate with PostgreSQL. 0.0 The previous status for the caching layer was documented as Hazelcast. In the latest sync, the team reaffirmed that the caching layer remains Hazelcast. 1.0 The team earlier confirmed that the software enterprise SaaS licensing was set to ₹8 lakh annually. Today's agenda concluded that the software enterprise SaaS licensing will currently operate with ₹8 lakh annually. 1.0 - Loss: CosineSimilarityLoss with these parameters:
{ "loss_fct": "torch.nn.modules.loss.MSELoss", "cos_score_transformation": "torch.nn.modules.linear.Identity" }
Training Hyperparameters
Non-Default Hyperparameters
per_device_train_batch_size: 32num_train_epochs: 2learning_rate: 2e-05warmup_steps: 0.1per_device_eval_batch_size: 32
All Hyperparameters
per_device_train_batch_size: 32num_train_epochs: 2max_steps: -1learning_rate: 2e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0.1optim: adamw_torch_fusedoptim_args: Noneweight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08optim_target_modules: Nonegradient_accumulation_steps: 1average_tokens_across_devices: Truemax_grad_norm: 1.0label_smoothing_factor: 0.0bf16: Falsefp16: Falsebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Nonetorch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneuse_liger_kernel: Falseliger_kernel_config: Noneuse_cache: Falseneftune_noise_alpha: Nonetorch_empty_cache_steps: Noneauto_find_batch_size: Falselog_on_each_node: Truelogging_nan_inf_filter: Trueinclude_num_input_tokens_seen: nolog_level: passivelog_level_replica: warningdisable_tqdm: Falseproject: huggingfacetrackio_space_id: Nonetrackio_bucket_id: Nonetrackio_static_space_id: Noneper_device_eval_batch_size: 32prediction_loss_only: Trueeval_on_start: Falseeval_do_concat_batches: Trueeval_use_gather_object: Falseeval_accumulation_steps: Noneinclude_for_metrics: []batch_eval_metrics: Falsesave_only_model: Falsesave_on_each_node: Falseenable_jit_checkpoint: Falsepush_to_hub: Falsehub_private_repo: Nonehub_model_id: Nonehub_strategy: every_savehub_always_push: Falsehub_revision: Noneload_best_model_at_end: Falseignore_data_skip: Falserestore_callback_states_from_checkpoint: Falsefull_determinism: Falseseed: 42data_seed: Noneuse_cpu: Falseaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedataloader_drop_last: Falsedataloader_num_workers: 0dataloader_pin_memory: Truedataloader_persistent_workers: Falsedataloader_prefetch_factor: Nonedataloader_multiprocessing_context: Nonedataloader_in_order: Trueremove_unused_columns: Truelabel_names: Nonetrain_sampling_strategy: randomlength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falseddp_static_graph: Noneddp_backend: Noneddp_timeout: 1800fsdp: Nonefsdp_config: Nonedeepspeed: Nonedebug: []skip_memory_metrics: Truedo_predict: Falseresume_from_checkpoint: Nonelocal_rank: -1prompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}warmup_ratio: None
Training Logs
| Epoch | Step | Training Loss | Validation Loss | val_evaluator_spearman_cosine |
|---|---|---|---|---|
| 0.1520 | 50 | 0.0407 | - | - |
| 0.3040 | 100 | 0.0104 | - | - |
| 0.4559 | 150 | 0.0079 | - | - |
| 0.6079 | 200 | 0.0067 | - | - |
| 0.7599 | 250 | 0.0062 | - | - |
| 0.9119 | 300 | 0.0052 | - | - |
| 1.0 | 329 | - | 0.0022 | 0.8657 |
| 1.0638 | 350 | 0.0047 | - | - |
| 1.2158 | 400 | 0.0043 | - | - |
| 1.3678 | 450 | 0.0043 | - | - |
| 1.5198 | 500 | 0.0039 | - | - |
| 1.6717 | 550 | 0.0035 | - | - |
| 1.8237 | 600 | 0.0036 | - | - |
| 1.9757 | 650 | 0.0034 | - | - |
| 2.0 | 658 | - | 0.0017 | 0.8657 |
Training Time
- Training: 1.2 minutes
Framework Versions
- Python: 3.13.15
- Sentence Transformers: 5.7.0
- Transformers: 5.18.0
- PyTorch: 2.11.0+cu130
- Accelerate: 1.15.0
- Datasets: 4.8.5
- Tokenizers: 0.23.2
Additional Resources
- Training and Finetuning Embedding Models with Sentence Transformers: the end-to-end guide for training or finetuning Sentence Transformer models.
- Introduction to Matryoshka Embedding Models: variable-size embeddings that can be truncated with minimal quality loss.
- Binary and Scalar Embedding Quantization for Significantly Faster & Cheaper Retrieval: post-training compression of embedding vectors.
- Multimodal Embedding & Reranker Models with Sentence Transformers: use text, image, audio, and video models through the same API.
- Training and Finetuning Multimodal Embedding & Reranker Models with Sentence Transformers: train multimodal embedding models, with a Visual Document Retrieval walkthrough.
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",
}