SentenceTransformer based on BAAI/bge-base-en-v1.5
This is a sentence-transformers model finetuned from BAAI/bge-base-en-v1.5. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for retrieval.
Model Details
Model Description
- Model Type: Sentence Transformer
- Base model: BAAI/bge-base-en-v1.5
- Maximum Sequence Length: 512 tokens
- Output Dimensionality: 768 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': 768, 'pooling_mode': 'cls', '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("sentence_transformers_model_id")
# Run inference
queries = [
'web console not functioning properly',
]
documents = [
'Multiple cross-site scripting (XSS) vulnerabilities in IBM InfoSphere Information Server through 8.5 FP3, 8.7 through FP2, and 9.1 allow remote authenticated users to inject arbitrary web script or HTML via vectors related to the (1) web console and (2) repository management user interfaces.',
'Cross-site scripting (XSS) vulnerability in the Taxonomy Breadcrumb module 6.x before 6.x-1.1 for Drupal allows remote authenticated users, with administer taxonomy permissions, to inject arbitrary web script or HTML via the node title in a Breadcrumb display.',
'The Relish (Verve Connect) VH510 device with firmware before 1.0.1.6L0516 contains undocumented default admin credentials for the web management interface. A remote attacker could exploit this vulnerability to login and execute commands on the device, as well as upgrade the firmware image to a malicious version.',
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
# [1, 768] [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[ 0.5274, -0.1275, 0.2536]])
Evaluation
Metrics
Information Retrieval
- Dataset:
validation - Evaluated with InformationRetrievalEvaluator
| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.7696 |
| cosine_accuracy@3 | 0.8714 |
| cosine_accuracy@5 | 0.9001 |
| cosine_accuracy@10 | 0.9349 |
| cosine_precision@1 | 0.7696 |
| cosine_precision@3 | 0.2905 |
| cosine_precision@5 | 0.18 |
| cosine_precision@10 | 0.0935 |
| cosine_recall@1 | 0.7696 |
| cosine_recall@3 | 0.8714 |
| cosine_recall@5 | 0.9001 |
| cosine_recall@10 | 0.9349 |
| cosine_ndcg@10 | 0.8527 |
| cosine_mrr@10 | 0.8263 |
| cosine_map@100 | 0.8289 |
Training Details
Training Dataset
Unnamed Dataset
- Size: 861,607 training samples
- Columns: sentence_0 and sentence_1
- Approximate statistics based on the first 100 samples:
sentence_0 sentence_1 type string string modality text text details min: 7 tokensmean: 12.17 tokensmax: 21 tokens min: 28 tokensmean: 87.76 tokensmax: 512 tokens - Samples:
sentence_0 sentence_1 broadcom bcm4355c0 wifi issues On Broadcom BCM4355C0 Wi-Fi chips 9.44.78.27.0.1.56 and other chips, properly crafted malicious over-the-air Fast Transition frames can potentially trigger internal Wi-Fi firmware heap and/or stack overflows, leading to denial of service or other effects, aka B-V2017061205. Tenda AC10 firmware crashes when changing WiFi settings Tenda AC10 V1.0 V15.03.06.23 is vulnerable to Buffer Overflow in form_fast_setting_wifi_set via the parameter ssid. issues with apache axis2 administration console Cross-site scripting (XSS) vulnerability in axis2-admin/axis2-admin/engagingglobally in the administration console in Apache Axis2/Java 1.4.1, 1.5.1, and possibly other versions, as used in SAP Business Objects 12, 3com IMC, and possibly other products, allows remote attackers to inject arbitrary web script or HTML via the modules parameter. NOTE: some of these details are obtained from third party information. - Loss: MultipleNegativesRankingLoss with these parameters:
{ "scale": 20.0, "similarity_fct": "cos_sim", "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: 16num_train_epochs: 1fp16: Trueper_device_eval_batch_size: 16multi_dataset_batch_sampler: round_robin
All Hyperparameters
per_device_train_batch_size: 16num_train_epochs: 1max_steps: -1learning_rate: 5e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0optim: 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: 1label_smoothing_factor: 0.0bf16: Falsefp16: Truebf16_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: 16prediction_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: Noneremove_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: []fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}deepspeed: Nonedebug: []skip_memory_metrics: Truedo_predict: Falseresume_from_checkpoint: Nonewarmup_ratio: Nonelocal_rank: -1prompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: round_robinrouter_mapping: {}learning_rate_mapping: {}
Training Logs
| Epoch | Step | Training Loss | validation_cosine_ndcg@10 |
|---|---|---|---|
| 0.0093 | 500 | 0.3136 | - |
| 0.0186 | 1000 | 0.1300 | - |
| 0.0279 | 1500 | 0.1098 | - |
| 0.0371 | 2000 | 0.1112 | - |
| 0.0464 | 2500 | 0.0935 | - |
| 0.0557 | 3000 | 0.0961 | - |
| 0.0650 | 3500 | 0.0856 | - |
| 0.0743 | 4000 | 0.0872 | - |
| 0.0836 | 4500 | 0.0857 | - |
| 0.0928 | 5000 | 0.0795 | - |
| 0.1021 | 5500 | 0.0787 | - |
| 0.1114 | 6000 | 0.0749 | - |
| 0.1207 | 6500 | 0.0747 | - |
| 0.1300 | 7000 | 0.0720 | - |
| 0.1393 | 7500 | 0.0720 | - |
| 0.1486 | 8000 | 0.0718 | - |
| 0.1578 | 8500 | 0.0651 | - |
| 0.1671 | 9000 | 0.0660 | - |
| 0.1764 | 9500 | 0.0725 | - |
| 0.1857 | 10000 | 0.0638 | 0.8264 |
| 0.1950 | 10500 | 0.0639 | - |
| 0.2043 | 11000 | 0.0698 | - |
| 0.2136 | 11500 | 0.0637 | - |
| 0.2228 | 12000 | 0.0646 | - |
| 0.2321 | 12500 | 0.0746 | - |
| 0.2414 | 13000 | 0.0623 | - |
| 0.2507 | 13500 | 0.0629 | - |
| 0.2600 | 14000 | 0.0650 | - |
| 0.2693 | 14500 | 0.0578 | - |
| 0.2785 | 15000 | 0.0618 | - |
| 0.2878 | 15500 | 0.0572 | - |
| 0.2971 | 16000 | 0.0535 | - |
| 0.3064 | 16500 | 0.0594 | - |
| 0.3157 | 17000 | 0.0553 | - |
| 0.3250 | 17500 | 0.0530 | - |
| 0.3343 | 18000 | 0.0566 | - |
| 0.3435 | 18500 | 0.0537 | - |
| 0.3528 | 19000 | 0.0597 | - |
| 0.3621 | 19500 | 0.0645 | - |
| 0.3714 | 20000 | 0.0508 | 0.8397 |
| 0.3807 | 20500 | 0.0517 | - |
| 0.3900 | 21000 | 0.0544 | - |
| 0.3992 | 21500 | 0.0499 | - |
| 0.4085 | 22000 | 0.0559 | - |
| 0.4178 | 22500 | 0.0528 | - |
| 0.4271 | 23000 | 0.0552 | - |
| 0.4364 | 23500 | 0.0570 | - |
| 0.4457 | 24000 | 0.0541 | - |
| 0.4550 | 24500 | 0.0536 | - |
| 0.4642 | 25000 | 0.0504 | - |
| 0.4735 | 25500 | 0.0493 | - |
| 0.4828 | 26000 | 0.0545 | - |
| 0.4921 | 26500 | 0.0548 | - |
| 0.5014 | 27000 | 0.0525 | - |
| 0.5107 | 27500 | 0.0571 | - |
| 0.5200 | 28000 | 0.0481 | - |
| 0.5292 | 28500 | 0.0523 | - |
| 0.5385 | 29000 | 0.0512 | - |
| 0.5478 | 29500 | 0.0541 | - |
| 0.5571 | 30000 | 0.0513 | 0.8433 |
| 0.5664 | 30500 | 0.0510 | - |
| 0.5757 | 31000 | 0.0548 | - |
| 0.5849 | 31500 | 0.0463 | - |
| 0.5942 | 32000 | 0.0448 | - |
| 0.6035 | 32500 | 0.0544 | - |
| 0.6128 | 33000 | 0.0481 | - |
| 0.6221 | 33500 | 0.0491 | - |
| 0.6314 | 34000 | 0.0485 | - |
| 0.6407 | 34500 | 0.0509 | - |
| 0.6499 | 35000 | 0.0518 | - |
| 0.6592 | 35500 | 0.0513 | - |
| 0.6685 | 36000 | 0.0516 | - |
| 0.6778 | 36500 | 0.0482 | - |
| 0.6871 | 37000 | 0.0526 | - |
| 0.6964 | 37500 | 0.0462 | - |
| 0.7057 | 38000 | 0.0420 | - |
| 0.7149 | 38500 | 0.0445 | - |
| 0.7242 | 39000 | 0.0430 | - |
| 0.7335 | 39500 | 0.0428 | - |
| 0.7428 | 40000 | 0.0412 | 0.8483 |
| 0.7521 | 40500 | 0.0418 | - |
| 0.7614 | 41000 | 0.0456 | - |
| 0.7706 | 41500 | 0.0442 | - |
| 0.7799 | 42000 | 0.0449 | - |
| 0.7892 | 42500 | 0.0463 | - |
| 0.7985 | 43000 | 0.0429 | - |
| 0.8078 | 43500 | 0.0392 | - |
| 0.8171 | 44000 | 0.0404 | - |
| 0.8264 | 44500 | 0.0494 | - |
| 0.8356 | 45000 | 0.0472 | - |
| 0.8449 | 45500 | 0.0456 | - |
| 0.8542 | 46000 | 0.0463 | - |
| 0.8635 | 46500 | 0.0398 | - |
| 0.8728 | 47000 | 0.0448 | - |
| 0.8821 | 47500 | 0.0428 | - |
| 0.8913 | 48000 | 0.0447 | - |
| 0.9006 | 48500 | 0.0408 | - |
| 0.9099 | 49000 | 0.0403 | - |
| 0.9192 | 49500 | 0.0419 | - |
| 0.9285 | 50000 | 0.0398 | 0.8515 |
| 0.9378 | 50500 | 0.0420 | - |
| 0.9471 | 51000 | 0.0393 | - |
| 0.9563 | 51500 | 0.0428 | - |
| 0.9656 | 52000 | 0.0451 | - |
| 0.9749 | 52500 | 0.0448 | - |
| 0.9842 | 53000 | 0.0361 | - |
| 0.9935 | 53500 | 0.0411 | - |
| 1.0 | 53851 | - | 0.8527 |
Training Time
- Training: 2.4 hours
- Evaluation: 57.2 seconds
- Total: 2.4 hours
Framework Versions
- Python: 3.12.10
- Sentence Transformers: 5.5.1
- Transformers: 5.9.0
- PyTorch: 2.11.0+cu128
- Accelerate: 1.13.0
- Datasets: 4.8.5
- Tokenizers: 0.22.2
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",
}
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},
}