SentenceTransformer based on BAAI/bge-small-en-v1.5
This is a sentence-transformers model finetuned from BAAI/bge-small-en-v1.5. It maps inputs 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: BAAI/bge-small-en-v1.5
- Maximum Sequence Length: 512 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': '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
sentences = [
'Represent this sentence for searching relevant passages: Which years does the table provide information for accounts receivable for the company?',
'||March 31,||\n||2019|2018|\n|Trade accounts receivable|$875.8|$557.8|\n|Other|6.8|8.1|\n|Total accounts receivable, gross|882.6|565.9|\n|Less allowance for doubtful accounts|2.0|2.2|\n|Total accounts receivable, net|$880.6|$563.7|\nNote 8. Other Financial Statement Details\nAccounts Receivable\nAccounts receivable consists of the following (in millions):',
'|Year Ended May 31,|||||\n||||Percent Change||\n|(Dollars in millions)|2019|Actual|Constant|2018|\n|Interest expense|$2,082|3%|3%|$2,025|\nInterest Expense:\nInterest expense increased in fiscal 2019 compared to fiscal 2018 primarily due to higher average borrowings resulting from our issuance of $10.0 billion of senior notes in November 2017, which was partially offset by a reduction in interest expense resulting primarily from the maturities and repayments of $2.0 billion of senior notes during fiscal 2019 and $6.0 billion of senior notes during fiscal 2018.',
]
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.6351, 0.1055],
# [0.6351, 1.0000, 0.1877],
# [0.1055, 0.1877, 1.0000]])
Training Details
Training Dataset
Unnamed Dataset
- Size: 8,457 training samples
- Columns: anchor and positive
- Approximate statistics based on the first 100 samples:
anchor positive type string string modality text text details min: 19 tokensmean: 29.68 tokensmax: 54 tokens min: 195 tokensmean: 491.32 tokensmax: 512 tokens - Samples:
anchor positive Represent this sentence for searching relevant passages: what is the net change in net revenue during 2015 for entergy corporation? entergy corporation and subsidiaries management 2019s financial discussion and analysis a result of the entergy louisiana and entergy gulf states louisiana business combination , results of operations for 2015 also include two items that occurred in october 2015 : 1 ) a deferred tax asset and resulting net increase in tax basis of approximately $ 334 million and 2 ) a regulatory liability of $ 107 million ( $ 66 million net-of-tax ) as a result of customer credits to be realized by electric customers of entergy louisiana , consistent with the terms of the stipulated settlement in the business combination proceeding . see note 2 to the financial statements for further discussion of the business combination and customer credits . results of operations for 2015 also include the sale in december 2015 of the 583 mw rhode island state energy center for a realized gain of $ 154 million ( $ 100 million net-of-tax ) on the sale and the $ 77 million ( $ 47 million net-of-tax ) write-off and regu... Represent this sentence for searching relevant passages: what percentage of total facilities as measured in square feet are leased? item 1b . unresolved staff comments not applicable . item 2 . properties as of december 26 , 2015 , our major facilities consisted of : ( square feet in millions ) united states countries total owned facilities1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30.7 17.2 47.9 leased facilities2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1 6.0 8.1 .|( square feet in millions )|unitedstates|othercountries|total||owned facilities1|30.7|17.2|47.9||leased facilities2|2.1|6.0|8.1||total facilities|32.8|23.2|56.0|1 leases on portions of the land used for these facilities expire on varying dates through 2062 . 2 leases expire on varying dates through 2030 and generally include renewals at our option . our principal executive offices are located in the u.s . and a majority of our wafer fabrication activities are also located in the u.s . we completed ... Represent this sentence for searching relevant passages: what is the percentage change in cash flow hedges in 2011 compare to the 2010? undesignated hedges was $ 41.2 million and $ 42.1 million , respectively . the fair value of these hedging instruments in the company 2019s consolidated balance sheets as of october 29 , 2011 and october 30 , 2010 was immaterial . interest rate exposure management 2014 on june 30 , 2009 , the company entered into interest rate swap transactions related to its outstanding 5.0% ( 5.0 % ) senior unsecured notes where the company swapped the notional amount of its $ 375 million of fixed rate debt at 5.0% ( 5.0 % ) into floating interest rate debt through july 1 , 2014 . under the terms of the swaps , the company will ( i ) receive on the $ 375 million notional amount a 5.0% ( 5.0 % ) annual interest payment that is paid in two installments on the 1st of every january and july , commencing january 1 , 2010 through and ending on the maturity date ; and ( ii ) pay on the $ 375 million notional amount an annual three month libor plus 2.05% ( 2.05 % ) ( 2.42% ( 2.42 % ) as of october 29 , 2011 ... - 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: 64num_train_epochs: 4learning_rate: 2e-05warmup_steps: 0.1fp16: Truebatch_sampler: no_duplicates
All Hyperparameters
per_device_train_batch_size: 64num_train_epochs: 4max_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: 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: 8prediction_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: no_duplicatesmulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}warmup_ratio: None
Training Logs
| Epoch | Step | Training Loss |
|---|---|---|
| 0.1504 | 20 | 2.6075 |
| 0.3008 | 40 | 1.8592 |
| 0.4511 | 60 | 1.4213 |
| 0.6015 | 80 | 1.2615 |
| 0.7519 | 100 | 1.1356 |
| 0.9023 | 120 | 1.1272 |
| 1.0526 | 140 | 1.0339 |
| 1.2030 | 160 | 0.9350 |
| 1.3534 | 180 | 0.9439 |
| 1.5038 | 200 | 0.9283 |
| 1.6541 | 220 | 0.8123 |
| 1.8045 | 240 | 0.8857 |
| 1.9549 | 260 | 0.8654 |
| 2.1053 | 280 | 0.8034 |
| 2.2556 | 300 | 0.7560 |
| 2.4060 | 320 | 0.7184 |
| 2.5564 | 340 | 0.7267 |
| 2.7068 | 360 | 0.7975 |
| 2.8571 | 380 | 0.7435 |
| 3.0075 | 400 | 0.7414 |
| 3.1579 | 420 | 0.7204 |
| 3.3083 | 440 | 0.6914 |
| 3.4586 | 460 | 0.6518 |
| 3.6090 | 480 | 0.6586 |
| 3.7594 | 500 | 0.7923 |
| 3.9098 | 520 | 0.7091 |
Training Time
- Training: 1.5 minutes
Framework Versions
- Python: 3.12.3
- Sentence Transformers: 6.0.1
- Transformers: 5.16.1
- PyTorch: 2.14.0+cu130
- Accelerate: 1.14.0
- Datasets: 5.0.1
- 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",
}
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},
}