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

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 256, 'do_lower_case': False, 'architecture': '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("Mercity/memory-retrieval-minilm-l6-v2")
# Run inference
sentences = [
    'Provide the amortization schedule difference for CC1 under both prioritization schemas.',
    "Mark's primary long-term goal is to start his own small business within the next four years, requiring significant capital savings to begin operations.",
    "Last spring, Dr. Vasquez received high praise from the Dean for successfully transitioning her entire curriculum to align with a newly adopted, highly structured 'Systems Thinking Framework' mandated by the university board.",
]
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.9104, -0.3007],
#         [ 0.9104,  1.0000, -0.2945],
#         [-0.3007, -0.2945,  1.0000]])

Training Details

Training Dataset

Unnamed Dataset

  • Size: 370,023 training samples
  • Columns: sentence_0, sentence_1, and sentence_2
  • Approximate statistics based on the first 1000 samples:
    sentence_0 sentence_1 sentence_2
    type string string string
    details
    • min: 11 tokens
    • mean: 31.57 tokens
    • max: 76 tokens
    • min: 17 tokens
    • mean: 36.18 tokens
    • max: 64 tokens
    • min: 13 tokens
    • mean: 32.21 tokens
    • max: 154 tokens
  • Samples:
    sentence_0 sentence_1 sentence_2
    Yoga by the sea for Nina's soul? Add scenic drives that whisper sweet nothings. Nina developed a strong, vocal aversion to driving manual transmission cars after a stressful rental experience in Tuscany in 2018. Sofia recently shared that her grandmother, who is a major influencer in the family, is recovering from a minor surgery and requires quiet, low-stress environments for the next few months.
    Targeting analysis of 200 sites to sway city green space policies; realistic under these limits? Dr. Patel has a strong, established working relationship with the City Planning Department head, who is personally invested in seeing the pollinator data incorporated into the 2026 municipal budget review. Alex reviewed the seed funding agreement which stipulated that 10% ($50,000) of the capital must be reserved solely for executive bonuses upon Series A closing.
    Gluten-free options avoiding cross-contamination in our small kitchen? I truly value this. Lisa has a very close relationship with her neighbor, Sarah, who is a professional chef specializing in South American cuisine and often offers to help prep on Sundays. Alex's agent advised varying sentence structure with occasional future tense projections during character betrayals to heighten emotional stakes in the plot.
  • Loss: TripletLoss with these parameters:
    {
        "distance_metric": "TripletDistanceMetric.COSINE",
        "triplet_margin": 0.5
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • eval_strategy: steps
  • per_device_train_batch_size: 32
  • per_device_eval_batch_size: 32
  • multi_dataset_batch_sampler: round_robin

All Hyperparameters

Click to expand
  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: steps
  • prediction_loss_only: True
  • per_device_train_batch_size: 32
  • per_device_eval_batch_size: 32
  • 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: 5e-05
  • weight_decay: 0.0
  • adam_beta1: 0.9
  • adam_beta2: 0.999
  • adam_epsilon: 1e-08
  • max_grad_norm: 1
  • num_train_epochs: 3
  • max_steps: -1
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: {}
  • warmup_ratio: 0.0
  • 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
  • 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: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
  • fsdp_transformer_layer_cls_to_wrap: None
  • accelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
  • parallelism_config: None
  • deepspeed: None
  • label_smoothing_factor: 0.0
  • optim: adamw_torch_fused
  • optim_args: None
  • adafactor: False
  • group_by_length: False
  • length_column_name: length
  • project: huggingface
  • trackio_space_id: trackio
  • 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
  • hub_revision: None
  • 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
  • include_tokens_per_second: False
  • include_num_input_tokens_seen: no
  • neftune_noise_alpha: None
  • optim_target_modules: None
  • batch_eval_metrics: False
  • eval_on_start: False
  • use_liger_kernel: False
  • liger_kernel_config: None
  • eval_use_gather_object: False
  • average_tokens_across_devices: True
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: round_robin
  • router_mapping: {}
  • learning_rate_mapping: {}

Training Logs

Epoch Step Training Loss
0.0432 500 0.3372
0.0865 1000 0.1651
0.1297 1500 0.1505
0.1730 2000 0.1367
0.2162 2500 0.128
0.2594 3000 0.1213
0.3027 3500 0.1167
0.3459 4000 0.1087
0.3891 4500 0.1017
0.4324 5000 0.1019
0.4756 5500 0.096
0.5189 6000 0.0963
0.5621 6500 0.0883
0.6053 7000 0.0879
0.6486 7500 0.0865
0.6918 8000 0.0822
0.7350 8500 0.0815
0.7783 9000 0.0784
0.8215 9500 0.0754
0.8648 10000 0.0767
0.9080 10500 0.0732
0.9512 11000 0.0713
0.9945 11500 0.0677
1.0 11564 -
1.0377 12000 0.0611
1.0809 12500 0.0572
1.1242 13000 0.0596
1.1674 13500 0.0576
1.2107 14000 0.0562
1.2539 14500 0.0544
1.2971 15000 0.0543
1.3404 15500 0.0544
1.3836 16000 0.0533
1.4268 16500 0.0515
1.4701 17000 0.0501
1.5133 17500 0.0515
1.5566 18000 0.0494
1.5998 18500 0.0495
1.6430 19000 0.0477
1.6863 19500 0.0471
1.7295 20000 0.0478
1.7727 20500 0.0453
1.8160 21000 0.0447
1.8592 21500 0.0463
1.9025 22000 0.0462
1.9457 22500 0.0445
1.9889 23000 0.0436
2.0 23128 -
2.0322 23500 0.0376
2.0754 24000 0.0377
2.1186 24500 0.0364
2.1619 25000 0.0381
2.2051 25500 0.0382
2.2484 26000 0.0359
2.2916 26500 0.036
2.3348 27000 0.0365
2.3781 27500 0.0362
2.4213 28000 0.036
2.4645 28500 0.0359
2.5078 29000 0.0364
2.5510 29500 0.0355
2.5943 30000 0.0354
2.6375 30500 0.0348
2.6807 31000 0.0362
2.7240 31500 0.0345
2.7672 32000 0.0351
2.8104 32500 0.0345
2.8537 33000 0.0351
2.8969 33500 0.0339
2.9402 34000 0.0354
2.9834 34500 0.0356
3.0 34692 -

Framework Versions

  • Python: 3.12.3
  • Sentence Transformers: 5.1.2
  • Transformers: 4.57.1
  • PyTorch: 2.8.0+cu128
  • Accelerate: 1.11.0
  • Datasets: 4.4.0
  • Tokenizers: 0.22.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",
}

TripletLoss

@misc{hermans2017defense,
    title={In Defense of the Triplet Loss for Person Re-Identification},
    author={Alexander Hermans and Lucas Beyer and Bastian Leibe},
    year={2017},
    eprint={1703.07737},
    archivePrefix={arXiv},
    primaryClass={cs.CV}
}
Downloads last month
14
Safetensors
Model size
22.7M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Mercity/memory-retrieval-minilm-l6-v2

Finetuned
(677)
this model