Downloads · 30 days
16
28% of all-time downloads
iammayur/bge-base-financial-matryoshka
bge-base-financial-matryoshka is a sentence similarity model from iammayur. Use it when you need a score for how close two texts are. It is set up for sentence-transformers. The card lists the license as apache-2.0.
This is a sentence-transformers model finetuned from BAAI/bge-base-en-v1.5 on the json dataset. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, s…
Downloads · 30 days
16
28% of all-time downloads
All-time downloads
58
Public
Parameters
109M
438 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors438 MB · 100%
From the Hugging Face model README
This is a sentence-transformers model finetuned from BAAI/bge-base-en-v1.5 on the json dataset. It maps sentences & paragraphs to a 768-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': 'BertModel'})
(1): Pooling({'embedding_dimension': 768, '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("iammayur/bge-base-financial-matryoshka")
# Run inference
queries = [
'Cost of sales for the company was $5,920.5 million in 2022, up from $4,922.7 million in 2021, which represents a 20.3% increase. This included $767.7 million of unfavorable costs driven by higher sales volume and increased supply chain inflation costs, including logistics and labor.',
]
documents = [
'What were the main components of the increased cost of sales in 2022 compared to 2021?',
'How much is the service fee on client cash deposits held at the TD Depository Institutions under the 2023 IDA agreement?',
'What is the primary method by which the company manages its cash, cash equivalents, and marketable securities?',
]
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.8170, 0.1130, 0.1414]])
<!--
### Direct Usage (Transformers)
<details><summary>Click to see the direct usage in Transformers</summary>
</details>
-->
<!--
### Downstream Usage (Sentence Transformers)
You can finetune this model on your own dataset.
<details><summary>Click to expand</summary>
</details>
-->
<!--
### Out-of-Scope Use
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
-->
dim_768{
"truncate_dim": 768
}
| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.7257 |
| cosine_accuracy@3 | 0.8357 |
| cosine_accuracy@5 | 0.8771 |
| cosine_accuracy@10 | 0.9014 |
| cosine_precision@1 | 0.7257 |
| cosine_precision@3 | 0.2786 |
| cosine_precision@5 | 0.1754 |
| cosine_precision@10 | 0.0901 |
| cosine_recall@1 | 0.7257 |
| cosine_recall@3 | 0.8357 |
| cosine_recall@5 | 0.8771 |
| cosine_recall@10 | 0.9014 |
| cosine_ndcg@10 | 0.8168 |
| cosine_mrr@10 | 0.7892 |
| cosine_map@100 | 0.7928 |
dim_512{
"truncate_dim": 512
}
| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.7229 |
| cosine_accuracy@3 | 0.8357 |
| cosine_accuracy@5 | 0.8729 |
| cosine_accuracy@10 | 0.9029 |
| cosine_precision@1 | 0.7229 |
| cosine_precision@3 | 0.2786 |
| cosine_precision@5 | 0.1746 |
| cosine_precision@10 | 0.0903 |
| cosine_recall@1 | 0.7229 |
| cosine_recall@3 | 0.8357 |
| cosine_recall@5 | 0.8729 |
| cosine_recall@10 | 0.9029 |
| cosine_ndcg@10 | 0.8158 |
| cosine_mrr@10 | 0.7876 |
| cosine_map@100 | 0.7912 |
dim_256{
"truncate_dim": 256
}
| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.7186 |
| cosine_accuracy@3 | 0.8329 |
| cosine_accuracy@5 | 0.8743 |
| cosine_accuracy@10 | 0.9057 |
| cosine_precision@1 | 0.7186 |
| cosine_precision@3 | 0.2776 |
| cosine_precision@5 | 0.1749 |
| cosine_precision@10 | 0.0906 |
| cosine_recall@1 | 0.7186 |
| cosine_recall@3 | 0.8329 |
| cosine_recall@5 | 0.8743 |
| cosine_recall@10 | 0.9057 |
| cosine_ndcg@10 | 0.8137 |
| cosine_mrr@10 | 0.7839 |
| cosine_map@100 | 0.7872 |
dim_128{
"truncate_dim": 128
}
| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.7043 |
| cosine_accuracy@3 | 0.8257 |
| cosine_accuracy@5 | 0.8586 |
| cosine_accuracy@10 | 0.8986 |
| cosine_precision@1 | 0.7043 |
| cosine_precision@3 | 0.2752 |
| cosine_precision@5 | 0.1717 |
| cosine_precision@10 | 0.0899 |
| cosine_recall@1 | 0.7043 |
| cosine_recall@3 | 0.8257 |
| cosine_recall@5 | 0.8586 |
| cosine_recall@10 | 0.8986 |
| cosine_ndcg@10 | 0.8034 |
| cosine_mrr@10 | 0.7726 |
| cosine_map@100 | 0.7761 |
dim_64{
"truncate_dim": 64
}
| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.6643 |
| cosine_accuracy@3 | 0.7829 |
| cosine_accuracy@5 | 0.8271 |
| cosine_accuracy@10 | 0.8743 |
| cosine_precision@1 | 0.6643 |
| cosine_precision@3 | 0.261 |
| cosine_precision@5 | 0.1654 |
| cosine_precision@10 | 0.0874 |
| cosine_recall@1 | 0.6643 |
| cosine_recall@3 | 0.7829 |
| cosine_recall@5 | 0.8271 |
| cosine_recall@10 | 0.8743 |
| cosine_ndcg@10 | 0.7682 |
| cosine_mrr@10 | 0.7343 |
| cosine_map@100 | 0.7385 |
| positive | anchor | |
|---|---|---|
| type | string | string |
| modality | text | text |
| details | <ul><li>min: 14 tokens</li><li>mean: 42.72 tokens</li><li>max: 122 tokens</li></ul> | <ul><li>min: 10 tokens</li><li>mean: 20.15 tokens</li><li>max: 40 tokens</li></ul> |
| positive | anchor |
|---|---|
| <code>Alphabet is a collection of businesses, the largest of which is Google. Alphabet reports Google in two segments, Google Services and Google Cloud; all non-Google businesses are collectively reported as Other Bets.</code> | <code>What are Alphabet's primary business segments and how are they reported?</code> |
| <code>The company has the option to redeem the Notes for cash between specific dates if the sale price of their common stock exceeds a set threshold relative to the conversion price over a specified number of trading days, including on the day immediately before the notice of redemption is sent.</code> | <code>What are the conditions under which the company may redeem the Notes for cash?</code> |
| <code>Net earnings attributable to Hasbro, Inc. declined in 2022 to $203.5 million, compared to $428.7 million in 2021.</code> | <code>How much did Hasbro's net earnings attributable to Hasbro, Inc. decline in 2022 compared to 2021?</code> |
{
"loss": "MultipleNegativesRankingLoss",
"matryoshka_dims": [
768,
512,
256,
128,
64
],
"matryoshka_weights": [
1,
1,
1,
1,
1
],
"n_dims_per_step": -1
}
per_device_train_batch_size: 16num_train_epochs: 4learning_rate: 2e-05lr_scheduler_type: cosinewarmup_steps: 0.1gradient_accumulation_steps: 16bf16: Trueper_device_eval_batch_size: 16load_best_model_at_end: Truebatch_sampler: no_duplicatesper_device_train_batch_size: 16num_train_epochs: 4max_steps: -1learning_rate: 2e-05lr_scheduler_type: cosinelr_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: 16average_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: 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: Trueignore_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| Epoch | Step | Training Loss | dim_768_cosine_ndcg@10 | dim_512_cosine_ndcg@10 | dim_256_cosine_ndcg@10 | dim_128_cosine_ndcg@10 | dim_64_cosine_ndcg@10 |
|---|---|---|---|---|---|---|---|
| 0.4061 | 10 | 1.0226 | - | - | - | - | - |
| 0.8122 | 20 | 0.4788 | - | - | - | - | - |
| 1.0 | 25 | - | 0.8082 | 0.8071 | 0.8053 | 0.7850 | 0.7460 |
| 1.2030 | 30 | 0.3296 | - | - | - | - | - |
| 1.6091 | 40 | 0.2549 | - | - | - | - | - |
| 2.0 | 50 | 0.2531 | 0.8140 | 0.8147 | 0.8125 | 0.8013 | 0.7630 |
| 2.4061 | 60 | 0.2018 | - | - | - | - | - |
| 2.8122 | 70 | 0.2165 | - | - | - | - | - |
| 3.0 | 75 | - | 0.8172 | 0.8165 | 0.8126 | 0.8019 | 0.7680 |
| 3.2030 | 80 | 0.1983 | - | - | - | - | - |
| 3.6091 | 90 | 0.1817 | - | - | - | - | - |
| 4.0 | 100 | 0.1899 | 0.8168 | 0.8158 | 0.8137 | 0.8034 | 0.7682 |
@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{kusupati2024matryoshka,
title={Matryoshka Representation Learning},
author={Aditya Kusupati and Gantavya Bhatt and Aniket Rege and Matthew Wallingford and Aditya Sinha and Vivek Ramanujan and William Howard-Snyder and Kaifeng Chen and Sham Kakade and Prateek Jain and Ali Farhadi},
year={2024},
eprint={2205.13147},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
@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},
}
<!--
## Glossary
*Clearly define terms in order to be accessible across audiences.*
-->
<!--
## Model Card Authors
*Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
-->
<!--
## Model Card Contact
*Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
-->