SentenceTransformer based on BAAI/bge-m3

This is a sentence-transformers model finetuned from BAAI/bge-m3. It maps inputs to a 1024-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: BAAI/bge-m3
  • Maximum Sequence Length: 192 tokens
  • Output Dimensionality: 1024 dimensions
  • Similarity Function: Cosine Similarity
  • Supported Modality: Text

Model Sources

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': 'XLMRobertaModel'})
  (1): Pooling({'embedding_dimension': 1024, 'pooling_mode': 'cls', 'include_prompt': True})
  (2): Normalize({'module_input_name': 'sentence_embedding', 'module_output_name': 'sentence_embedding'})
)

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
queries = [
    "Hi, I'm feeling a bit bored. Can you tell me something interesting?",
]
documents = [
    'get_random_fact. Get a random fact',
    'get_random_trivia. Get a random piece of trivia',
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
# [1, 1024] [2, 1024]

# Get the similarity scores for the embeddings
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[0.3718, 0.4430]])

Evaluation

Metrics

Information Retrieval

Metric Value
cosine_accuracy@1 0.4588
cosine_accuracy@3 0.662
cosine_accuracy@5 0.7302
cosine_accuracy@10 0.7961
cosine_precision@1 0.4588
cosine_precision@3 0.2207
cosine_precision@5 0.146
cosine_precision@10 0.0796
cosine_recall@1 0.4588
cosine_recall@3 0.662
cosine_recall@5 0.7302
cosine_recall@10 0.7961
cosine_ndcg@10 0.6287
cosine_mrr@10 0.575
cosine_map@100 0.581

Training Details

Training Dataset

Unnamed Dataset

  • Size: 70,988 training samples
  • Columns: anchor, positive, negative_1, negative_2, negative_3, and negative_4
  • Approximate statistics based on the first 100 samples:
    anchor positive negative_1 negative_2 negative_3 negative_4
    type string string string string string string
    modality text text text text text text
    details
    • min: 9 tokens
    • mean: 32.96 tokens
    • max: 89 tokens
    • min: 18 tokens
    • mean: 32.62 tokens
    • max: 76 tokens
    • min: 16 tokens
    • mean: 30.79 tokens
    • max: 58 tokens
    • min: 10 tokens
    • mean: 30.11 tokens
    • max: 61 tokens
    • min: 10 tokens
    • mean: 31.28 tokens
    • max: 64 tokens
    • min: 11 tokens
    • mean: 31.76 tokens
    • max: 92 tokens
  • Samples:
    anchor positive negative_1 negative_2 negative_3 negative_4
    Is the email 'john.doe@example.com' part of any known data breaches? data_breach_checker_endpoint. Checks if the given email has been compromised in any known data breaches using the Data Breach Checker API.. Tham số: email emailvalidation. Validates if an email address exists using the RapidAPI Whois Lookup service.. Tham số: email mailcheck. Validates the given email address against specified domain(s) using an external API.. Tham số: email, domain emailvalidation. Validates an email address using an API service.. Tham số: email bouncer_email_checker. Validates an email address using the Bouncer Email Checker API.. Tham số: email
    Search for movies and TV shows with the title 'The Dark Knight' without any limit on the number of results. search_by_title. Search for Movies or TV Shows by title, with optional filters for year, media type, and limit on the number of results.. Tham số: s, l, y, m search_movies. Search for movies based on a query. Tham số: query, limit search. Searches for a movie or TV show based on the given title.. Tham số: title, page search_movie. Search for a movie by title or genre. Tham số: query, max_results search_movies. Search for movies based on title. Tham số: title
    Hi, I need to calculate the volume of a rectangular prism. The length is 5, width is 3 and height is 2. calculate_volume. Calculate the volume of a rectangular prism. Tham số: length, width, height calculate_cylinder_volume. Calculate the volume of a cylinder. Tham số: radius, height calculate_cylinder_volume. Calculate the volume of a cylinder. Tham số: radius, height calculate_area_volume. Calculate the area and volume of a three-dimensional object. Tham số: object_type, dimensions calculate_area_volume. Calculate the area and volume of a 3D shape. Tham số: shape, dimensions
  • Loss: CachedMultipleNegativesRankingLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "cos_sim",
        "mini_batch_size": 32,
        "mini_batch_num_tokens": null,
        "gather_across_devices": false,
        "directions": [
            "query_to_doc"
        ],
        "partition_mode": "joint",
        "hardness_mode": null,
        "hardness_strength": 0.0
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • per_device_train_batch_size: 256
  • learning_rate: 2e-05
  • lr_scheduler_type: cosine
  • warmup_steps: 0.1
  • fp16: True

All Hyperparameters

Click to expand
  • per_device_train_batch_size: 256
  • num_train_epochs: 3
  • max_steps: -1
  • learning_rate: 2e-05
  • lr_scheduler_type: cosine
  • lr_scheduler_kwargs: None
  • warmup_steps: 0.1
  • optim: adamw_torch_fused
  • optim_args: None
  • weight_decay: 0.0
  • adam_beta1: 0.9
  • adam_beta2: 0.999
  • adam_epsilon: 1e-08
  • optim_target_modules: None
  • gradient_accumulation_steps: 1
  • average_tokens_across_devices: True
  • max_grad_norm: 1.0
  • label_smoothing_factor: 0.0
  • bf16: False
  • fp16: True
  • bf16_full_eval: False
  • fp16_full_eval: False
  • tf32: None
  • gradient_checkpointing: False
  • gradient_checkpointing_kwargs: None
  • torch_compile: False
  • torch_compile_backend: None
  • torch_compile_mode: None
  • use_liger_kernel: False
  • liger_kernel_config: None
  • use_cache: False
  • neftune_noise_alpha: None
  • torch_empty_cache_steps: None
  • auto_find_batch_size: False
  • log_on_each_node: True
  • logging_nan_inf_filter: True
  • include_num_input_tokens_seen: no
  • log_level: passive
  • log_level_replica: warning
  • disable_tqdm: False
  • project: huggingface
  • trackio_space_id: None
  • trackio_bucket_id: None
  • trackio_static_space_id: None
  • per_device_eval_batch_size: 8
  • prediction_loss_only: True
  • eval_on_start: False
  • eval_do_concat_batches: True
  • eval_use_gather_object: False
  • eval_accumulation_steps: None
  • include_for_metrics: []
  • batch_eval_metrics: False
  • save_only_model: False
  • save_on_each_node: False
  • enable_jit_checkpoint: False
  • push_to_hub: False
  • hub_private_repo: None
  • hub_model_id: None
  • hub_strategy: every_save
  • hub_always_push: False
  • hub_revision: None
  • load_best_model_at_end: False
  • ignore_data_skip: False
  • restore_callback_states_from_checkpoint: False
  • full_determinism: False
  • seed: 42
  • data_seed: None
  • use_cpu: False
  • 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
  • dataloader_drop_last: False
  • dataloader_num_workers: 0
  • dataloader_pin_memory: True
  • dataloader_persistent_workers: False
  • dataloader_prefetch_factor: None
  • dataloader_multiprocessing_context: None
  • dataloader_in_order: True
  • remove_unused_columns: True
  • label_names: None
  • train_sampling_strategy: random
  • length_column_name: length
  • ddp_find_unused_parameters: None
  • ddp_bucket_cap_mb: None
  • ddp_broadcast_buffers: False
  • ddp_static_graph: None
  • ddp_backend: None
  • ddp_timeout: 1800
  • fsdp: None
  • fsdp_config: None
  • deepspeed: None
  • debug: []
  • skip_memory_metrics: True
  • do_predict: False
  • resume_from_checkpoint: None
  • local_rank: -1
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: proportional
  • router_mapping: {}
  • learning_rate_mapping: {}
  • warmup_ratio: None

Training Logs

Epoch Step Training Loss custom_val_cosine_ndcg@10
0.1799 50 3.7251 -
0.3597 100 2.7619 -
0.5396 150 2.1278 -
0.7194 200 1.9997 -
0.8993 250 1.8913 -
1.0791 300 1.8380 0.5842
1.2590 350 1.7996 -
1.4388 400 1.7590 -
1.6187 450 1.7098 -
1.7986 500 1.6860 -
1.9784 550 1.6494 -
2.1583 600 1.6049 0.6243
2.3381 650 1.6211 -
2.5180 700 1.6014 -
2.6978 750 1.5894 -
2.8777 800 1.6079 -
3.0 834 - 0.6287

Training Time

  • Training: 6.0 hours
  • Evaluation: 10.5 minutes
  • Total: 6.2 hours

Framework Versions

  • Python: 3.12.13
  • Sentence Transformers: 6.0.0
  • Transformers: 5.15.1
  • PyTorch: 2.10.0+cu128
  • Accelerate: 1.13.0
  • Datasets: 5.0.0
  • Tokenizers: 0.22.2

Additional Resources

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}
}

MultipleNegativesRankingLoss

@misc{oord2019representationlearningcontrastivepredictive,
      title={Representation Learning with Contrastive Predictive Coding},
      author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},
      year={2019},
      eprint={1807.03748},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/1807.03748},
}
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Dathq12/bge-m3-tool-retrieval-vi

Base model

BAAI/bge-m3
Finetuned
(567)
this model

Papers for Dathq12/bge-m3-tool-retrieval-vi

Evaluation results