E5-Mistral-7B-Instruct QLoRA Financial Retrieval
This is a sentence-transformers model finetuned from intfloat/e5-mistral-7b-instruct on the fin_modern_bert-pairs-sec-synthetic-v1 dataset. It maps inputs to a 4096-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: intfloat/e5-mistral-7b-instruct
- Maximum Sequence Length: 384 tokens
- Output Dimensionality: 4096 dimensions
- Similarity Function: Cosine Similarity
- Supported Modality: Text
- Training Dataset:
- fin_modern_bert-pairs-sec-synthetic-v1
- Language: en
- License: apache-2.0
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': 'MistralModel'})
(1): Pooling({'embedding_dimension': 4096, 'pooling_mode': 'lasttoken', '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("kokitabayashi/e5-mistral-qlora_FinModernBERT_query")
# Run inference
queries = [
'Where can I find the computation for the Ratio of Earnings to Fixed Charges?',
]
documents = [
'12.1 Computation of Ratio of Earnings to Fixed Charges.',
'Total Utility Operating Revenues $ 3,011,574',
'Net income per common share -- diluted $ 1.60 $ 1.64 $ 1.48 $ 1.30',
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
# [1, 4096] [3, 4096]
# Get the similarity scores for the embeddings
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[0.9219, 0.0568, 0.0930]])
Evaluation
Metrics
Information Retrieval
- Dataset:
finance-eval - Evaluated with
InformationRetrievalEvaluatorwith these parameters:{ "query_prompt": "Instruct: Given a financial question, retrieve relevant financial passages that answer the question\nQuery: " }
| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.8282 |
| cosine_accuracy@3 | 0.9568 |
| cosine_accuracy@5 | 0.9778 |
| cosine_accuracy@10 | 0.9913 |
| cosine_precision@1 | 0.8282 |
| cosine_precision@3 | 0.3189 |
| cosine_precision@5 | 0.1956 |
| cosine_precision@10 | 0.0991 |
| cosine_recall@1 | 0.8282 |
| cosine_recall@3 | 0.9568 |
| cosine_recall@5 | 0.9778 |
| cosine_recall@10 | 0.9913 |
| cosine_ndcg@10 | 0.9187 |
| cosine_mrr@10 | 0.8944 |
| cosine_map@100 | 0.8949 |
Training Details
Training Dataset
fin_modern_bert-pairs-sec-synthetic-v1
- Dataset: fin_modern_bert-pairs-sec-synthetic-v1
- Size: 44,709 training samples
- Columns:
queryandpositive - Approximate statistics based on the first 100 samples:
query positive type string string modality text text details - min: 16 tokens
- mean: 31.38 tokens
- max: 58 tokens
- min: 17 tokens
- mean: 74.24 tokens
- max: 222 tokens
- Samples:
query positive What was the net income for Bank of America Corporation for the fiscal year 2012?Net income $ 4,188 $ 4,188What specific changes were made to the Company's credit agreement in April 2021 regarding its revolving credit facility?The credit agreement amends the Company’s existing revolving credit facility to add a new five-year, delayed draw, term loan for up to $800 million.What are the SEC file numbers for the Ameren Companies' filings?The file number references for the Ameren Companies filings with the SEC are: Ameren, 1-14756; Ameren Missouri, 1-2967; Ameren Illinois, 1-3672; and Genco, 333-56594. - Loss:
CachedMultipleNegativesRankingLosswith these parameters:{ "scale": 20.0, "similarity_fct": "cos_sim", "mini_batch_size": 2, "mini_batch_num_tokens": null, "gather_across_devices": false, "directions": [ "query_to_doc" ], "partition_mode": "joint", "hardness_mode": null, "hardness_strength": 0.0 }
Evaluation Dataset
fin_modern_bert-pairs-sec-synthetic-v1
- Dataset: fin_modern_bert-pairs-sec-synthetic-v1
- Size: 9,580 evaluation samples
- Columns:
queryandpositive - Approximate statistics based on the first 100 samples:
query positive type string string modality text text details - min: 12 tokens
- mean: 32.1 tokens
- max: 58 tokens
- min: 18 tokens
- mean: 78.29 tokens
- max: 329 tokens
- Samples:
query positive What were the specific terms and maturity dates of the unsecured notes issued by the Company in September 2012 and December 2012?In September 2012, the Company issued $450,000,000 principal amount of unsecured notes in a public offering under its existing shelf registration statement. The notes mature in September 2022 and were issued at a 2.95% rate. In December 2012, the Company issued $250,000,000 principal amount of unsecured notes in a public offering under its existing shelf registration statement. The notes mature in March 2023 and were issued at a 2.85% rate.What was the estimated fair value of the company's debt as of December 31, 2005, and how does it compare to the carrying amount?As of December 31, 2005 and 2004, the carrying amount of debt, net of capital leases, was $10,516 and $11,884 and the fair value of debt, based on current market rates for debt of the same risk and maturities, was estimated at $11,643 and $13,198.What was the total amount of assets managed by the Asset Management segment for owned assets as of December 31, 2016?At December 31, 2016, the Asset Management segment managed $36.2 billion of owned assets. - Loss:
CachedMultipleNegativesRankingLosswith these parameters:{ "scale": 20.0, "similarity_fct": "cos_sim", "mini_batch_size": 2, "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: 32num_train_epochs: 4warmup_steps: 0.1bf16: Truelogging_nan_inf_filter: Falseper_device_eval_batch_size: 32prompts: {'query': 'Instruct: Given a financial question, retrieve relevant financial passages that answer the question\nQuery: ', 'positive': ''}batch_sampler: no_duplicates
All Hyperparameters
Click to expandper_device_train_batch_size: 32num_train_epochs: 4max_steps: -1learning_rate: 5e-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: Falseinclude_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: 32prediction_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: {'query': 'Instruct: Given a financial question, retrieve relevant financial passages that answer the question\nQuery: ', 'positive': ''}batch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}warmup_ratio: None
Training Logs
Click to expand| Epoch | Step | Training Loss | Validation Loss | finance-eval_cosine_ndcg@10 |
|---|---|---|---|---|
| -1 | -1 | - | - | 0.6145 |
| 0.0358 | 50 | 0.8241 | - | - |
| 0.0715 | 100 | 0.2215 | - | - |
| 0.1073 | 150 | 0.0492 | - | - |
| 0.1431 | 200 | 0.0277 | - | - |
| 0.1788 | 250 | 0.0200 | - | - |
| 0.2146 | 300 | 0.0214 | - | - |
| 0.2504 | 350 | 0.0145 | - | - |
| 0.2861 | 400 | 0.0115 | - | - |
| 0.3219 | 450 | 0.0089 | - | - |
| 0.3577 | 500 | 0.0134 | - | - |
| 0.3934 | 550 | 0.0145 | - | - |
| 0.4292 | 600 | 0.0120 | - | - |
| 0.4649 | 650 | 0.0126 | - | - |
| 0.5007 | 700 | 0.0088 | - | - |
| 0.5365 | 750 | 0.0073 | - | - |
| 0.5722 | 800 | 0.0050 | - | - |
| 0.6080 | 850 | 0.0130 | - | - |
| 0.6438 | 900 | 0.0114 | - | - |
| 0.6795 | 950 | 0.0098 | - | - |
| 0.7153 | 1000 | 0.0136 | - | - |
| 0.7511 | 1050 | 0.0083 | - | - |
| 0.7868 | 1100 | 0.0088 | - | - |
| 0.8226 | 1150 | 0.0106 | - | - |
| 0.8584 | 1200 | 0.0135 | - | - |
| 0.8941 | 1250 | 0.0093 | - | - |
| 0.9299 | 1300 | 0.0114 | - | - |
| 0.9657 | 1350 | 0.0112 | - | - |
| 1.0 | 1398 | - | 0.0077 | 0.9085 |
| 1.0014 | 1400 | 0.0082 | - | - |
| 1.0372 | 1450 | 0.0058 | - | - |
| 1.0730 | 1500 | 0.0075 | - | - |
| 1.1087 | 1550 | 0.0050 | - | - |
| 1.1445 | 1600 | 0.0056 | - | - |
| 1.1803 | 1650 | 0.0042 | - | - |
| 1.2160 | 1700 | 0.0074 | - | - |
| 1.2518 | 1750 | 0.0049 | - | - |
| 1.2876 | 1800 | 0.0051 | - | - |
| 1.3233 | 1850 | 0.0083 | - | - |
| 1.3591 | 1900 | 0.0043 | - | - |
| 1.3948 | 1950 | 0.0055 | - | - |
| 1.4306 | 2000 | 0.0029 | - | - |
| 1.4664 | 2050 | 0.0035 | - | - |
| 1.5021 | 2100 | 0.0052 | - | - |
| 1.5379 | 2150 | 0.0049 | - | - |
| 1.5737 | 2200 | 0.0065 | - | - |
| 1.6094 | 2250 | 0.0039 | - | - |
| 1.6452 | 2300 | 0.0035 | - | - |
| 1.6810 | 2350 | 0.0037 | - | - |
| 1.7167 | 2400 | 0.0039 | - | - |
| 1.7525 | 2450 | 0.0060 | - | - |
| 1.7883 | 2500 | 0.0053 | - | - |
| 1.8240 | 2550 | 0.0040 | - | - |
| 1.8598 | 2600 | 0.0062 | - | - |
| 1.8956 | 2650 | 0.0067 | - | - |
| 1.9313 | 2700 | 0.0054 | - | - |
| 1.9671 | 2750 | 0.0062 | - | - |
| 2.0 | 2796 | - | 0.0060 | 0.9114 |
| 2.0029 | 2800 | 0.0048 | - | - |
| 2.0386 | 2850 | 0.0033 | - | - |
| 2.0744 | 2900 | 0.0068 | - | - |
| 2.1102 | 2950 | 0.0045 | - | - |
| 2.1459 | 3000 | 0.0065 | - | - |
| 2.1817 | 3050 | 0.0052 | - | - |
| 2.2175 | 3100 | 0.0070 | - | - |
| 2.2532 | 3150 | 0.0030 | - | - |
| 2.2890 | 3200 | 0.0030 | - | - |
| 2.3247 | 3250 | 0.0028 | - | - |
| 2.3605 | 3300 | 0.0045 | - | - |
| 2.3963 | 3350 | 0.0045 | - | - |
| 2.4320 | 3400 | 0.0079 | - | - |
| 2.4678 | 3450 | 0.0036 | - | - |
| 2.5036 | 3500 | 0.0036 | - | - |
| 2.5393 | 3550 | 0.0028 | - | - |
| 2.5751 | 3600 | 0.0072 | - | - |
| 2.6109 | 3650 | 0.0051 | - | - |
| 2.6466 | 3700 | 0.0036 | - | - |
| 2.6824 | 3750 | 0.0061 | - | - |
| 2.7182 | 3800 | 0.0067 | - | - |
| 2.7539 | 3850 | 0.0027 | - | - |
| 2.7897 | 3900 | 0.0040 | - | - |
| 2.8255 | 3950 | 0.0032 | - | - |
| 2.8612 | 4000 | 0.0046 | - | - |
| 2.8970 | 4050 | 0.0023 | - | - |
| 2.9328 | 4100 | 0.0034 | - | - |
| 2.9685 | 4150 | 0.0059 | - | - |
| 3.0 | 4194 | - | 0.0052 | 0.9151 |
| 3.0043 | 4200 | 0.0022 | - | - |
| 3.0401 | 4250 | 0.0069 | - | - |
| 3.0758 | 4300 | 0.0060 | - | - |
| 3.1116 | 4350 | 0.0048 | - | - |
| 3.1474 | 4400 | 0.0028 | - | - |
| 3.1831 | 4450 | 0.0031 | - | - |
| 3.2189 | 4500 | 0.0029 | - | - |
| 3.2546 | 4550 | 0.0035 | - | - |
| 3.2904 | 4600 | 0.0021 | - | - |
| 3.3262 | 4650 | 0.0026 | - | - |
| 3.3619 | 4700 | 0.0038 | - | - |
| 3.3977 | 4750 | 0.0025 | - | - |
| 3.4335 | 4800 | 0.0022 | - | - |
| 3.4692 | 4850 | 0.0042 | - | - |
| 3.5050 | 4900 | 0.0061 | - | - |
| 3.5408 | 4950 | 0.0034 | - | - |
| 3.5765 | 5000 | 0.0063 | - | - |
| 3.6123 | 5050 | 0.0018 | - | - |
| 3.6481 | 5100 | 0.0042 | - | - |
| 3.6838 | 5150 | 0.0036 | - | - |
| 3.7196 | 5200 | 0.0051 | - | - |
| 3.7554 | 5250 | 0.0036 | - | - |
| 3.7911 | 5300 | 0.0030 | - | - |
| 3.8269 | 5350 | 0.0029 | - | - |
| 3.8627 | 5400 | 0.0040 | - | - |
| 3.8984 | 5450 | 0.0030 | - | - |
| 3.9342 | 5500 | 0.0035 | - | - |
| 3.9700 | 5550 | 0.0044 | - | - |
| 4.0 | 5592 | - | 0.0051 | 0.9187 |
| -1 | -1 | - | - | 0.9187 |
Training Time
- Training: 6.5 hours
Framework Versions
- Python: 3.13.16
- Sentence Transformers: 6.2.0
- Transformers: 5.22.1
- PyTorch: 2.14.1+cu130
- Accelerate: 1.15.0
- Datasets: 4.8.5
- Tokenizers: 0.23.3
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",
}
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},
}