Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 19
How to use kokitabayashi/bge-m3_FinModernBERT_query with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("kokitabayashi/bge-m3_FinModernBERT_query")
sentences = [
"What was the reported net income for the Global Markets segment in 2012, and what was the adjusted net income after accounting for intangibles?",
"This facility contains a financial covenant requiring the Company not to exceed a 37.5% debt to capitalization ratio as defined in the agreement.",
"Research and development expense during the years ended December 31, 2013 and 2012 , the six months ended December 31, 2012 and 2011, and the years ended June 30, 2012 and 2011, net of reimbursements of government grants, was approximately $59 million , $55 million , $28 million , $29 million , $56 million , and $60 million , respectively.",
"Global Markets Reported net income $ 1,054 $ 988 Adjustment related to intangibles (2) 9 12 Adjusted net income $ 1,063 $ 1,000"
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from BAAI/bge-m3 on the fin_modern_bert-pairs-sec-synthetic-v1 dataset. It maps sentences & paragraphs to a 1024-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, classification, clustering, and more.
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({})
)
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("kokitabayashi/bge-m3_FinModernBERT_query")
# Run inference
queries = [
'What is the specific debt-to-capital resources ratio covenant for the company, and what was the actual ratio as of December 31, 2005?',
]
documents = [
'Our only financial covenant exists with respect to our credit facility and our synthetic lease VIE obligations. The covenant requires that we not exceed a 37.5% debt to capital resources ratio as defined in the agreements. This ratio at December 31, 2005 was 21.5%.',
'S & P has a stable outlook on all of the ratings of the Companies, except for John Alden Life Insurance Company and Time Insurance Company, which have a negative outlook.',
'In 2017, production costs increased $10 million, or 3.5%, primarily due to a: • $6 million increase in purchased water principally due to usage increases in our California subsidiary, the result of the lifting in April 2017 of California water usage restrictions that had been mandated in 2015 due to the state’s extreme drought; • $2 million increase in fuel and power largely attributable to higher system delivery of water and supplier price increases in our Missouri and California subsidiaries; and • $2 million increase in waste disposal mainly due to higher sludge removal costs in our Illinois and Missouri subsidiaries.',
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
# [1, 1024] [3, 1024]
# Get the similarity scores for the embeddings
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[0.8410, 0.0446, 0.0053]])
finance-evalInformationRetrievalEvaluator| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.8257 |
| cosine_accuracy@3 | 0.9508 |
| cosine_accuracy@5 | 0.9714 |
| cosine_accuracy@10 | 0.987 |
| cosine_precision@1 | 0.8257 |
| cosine_precision@3 | 0.3169 |
| cosine_precision@5 | 0.1943 |
| cosine_precision@10 | 0.0987 |
| cosine_recall@1 | 0.8257 |
| cosine_recall@3 | 0.9508 |
| cosine_recall@5 | 0.9714 |
| cosine_recall@10 | 0.987 |
| cosine_ndcg@10 | 0.9145 |
| cosine_mrr@10 | 0.8903 |
| cosine_map@100 | 0.891 |
query and positive| query | positive | |
|---|---|---|
| type | string | string |
| modality | text | text |
| details |
|
|
| query | positive |
|---|---|
What is the breakdown of the estimated fair value of debt securities classified as short-term investments by their stated maturities? |
The following table summarizes the cost and estimated fair value of debt securities classified as short-term investments based on stated maturities. Due within one year $ 660,921 $ 664,819; Due within two years 268,508 271,841; Due within three years 72,187 73,547; Due after three years 113,446 119,498; Total $ 1,115,062 $ 1,129,705 |
What were the specific drivers for the 24% increase in HUMIRA revenues in the United States during 2016? |
In the United States, HUMIRA revenues increased 24% in 2016 and 29% in 2015, driven by prescription volume, favorable pricing, market growth across all indications and higher market share. |
What is the average rental rate and physical occupancy for the Avalon at Mission Bay III property in San Francisco? |
Avalon at Mission Bay III North San Francisco, CA 260 261,169 2009 1,004 93.1 % 95.2 % 96.2 % 4,445 4.43 147,918 |
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
}
query and positive| query | positive | |
|---|---|---|
| type | string | string |
| modality | text | text |
| details |
|
|
| query | positive |
|---|---|
How does the seasonality of orders and revenues typically affect the Life Sciences and Applied Markets business segment? |
The life sciences and applied markets business is susceptible to seasonality in its orders and revenues primarily related to U.S. and foreign government budgets, chemical and energy and environmental customers and large pharmaceutical company budgets. Historically, the result is that our first and fourth fiscal quarters tend to deliver the strongest profits for this group. |
What specific factors are identified as potential drivers for increased claim severity in auto bodily injury, property damage, and homeowners coverages? |
The following factors may impact claim severity for auto bodily injury, property damage and homeowners coverages: • Bodily injury — inflation in medical costs, litigation trends and precedents and regulation • Vehicle property damage — inflation in repair costs, including parts and labor rates, mix of total losses declared, costs associated with repairing sophisticated newer vehicles, model year and used-car values • Homeowners — inflation in the construction industry, building materials and home furnishings, changes in the mix of loss type, and other economic and environmental factors, including short-term supply imbalances for services and supplies in areas affected by catastrophes |
What is the remaining indebtedness on the subordinated notes as of December 31, 2005, and what were the conversion terms for these notes? |
As of December 31, 2005, our remaining indebtedness under the subordinated notes was approximately $75.4 million at maturity, due to conversion of subordinated notes into common stock. Each $1,000 aggregate principal face value subordinated note is convertible at the holder’s option at any time through maturity into 40.404 shares of our common stock at an initial conversion price of $8.36 per share. |
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
}
per_device_train_batch_size: 64num_train_epochs: 4learning_rate: 2e-05warmup_steps: 0.1bf16: Truedataloader_num_workers: 2batch_sampler: no_duplicatesper_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: Truefp16: 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: 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: 2dataloader_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| Epoch | Step | Training Loss | Validation Loss | finance-eval_cosine_ndcg@10 |
|---|---|---|---|---|
| -1 | -1 | - | - | 0.7985 |
| 1.0 | 699 | 0.0548 | 0.0035 | 0.9021 |
| 2.0 | 1398 | 0.0166 | 0.0025 | 0.9088 |
| 3.0 | 2097 | 0.0107 | 0.0028 | 0.9127 |
| 4.0 | 2796 | 0.0089 | 0.0024 | 0.9145 |
| -1 | -1 | - | - | 0.9145 |
@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",
}
@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},
}
Base model
BAAI/bge-m3