Downloads · 30 days
84
14% of all-time downloads
rya23/modernbert-embed-finance-matryoshka
modernbert-embed-finance-matryoshka is a sentence similarity model from rya23. Use it when you need a score for how close two texts are. It is set up for sentence-transformers.
This is a sentence-transformers model finetuned from nomic-ai/modernbert-embed-base on the json dataset. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual simi…
Downloads · 30 days
84
14% of all-time downloads
All-time downloads
605
Public
Parameters
149M
596 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors596 MB · 99%
From the Hugging Face model README
This is a sentence-transformers model finetuned from nomic-ai/modernbert-embed-base 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, text classification, clustering, and more.
SentenceTransformer(
(0): Transformer({'max_seq_length': 8192, 'do_lower_case': False, 'architecture': 'ModernBertModel'})
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, '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("rya23/modernbert-embed-finance-matryoshka")
# Run inference
sentences = [
"What typical reimbursement methods are used in the company's contracts with hospitals for inpatient and outpatient services?",
'We typically contract with hospitals on either (1) a per diem rate, which is an all-inclusive rate per day, (2) a case rate for diagnosis-related groups (DRG), which is an all-inclusive rate per admission, or (3) a discounted charge for inpatient hospital services. Outpatient hospital services generally are contracted at a flat rate by type of service, ambulatory payment classifications, or APCs, or at a discounted charge.',
'In IBM’s 2023 Annual Report to Stockholders, the Financial Statements and Supplementary Data are detailed on pages 44 through 121.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.6756, 0.0659],
# [0.6756, 1.0000, 0.0087],
# [0.0659, 0.0087, 1.0000]])
<!--
### 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.7244 |
| cosine_accuracy@3 | 0.8554 |
| cosine_accuracy@5 | 0.8903 |
| cosine_accuracy@10 | 0.9271 |
| cosine_precision@1 | 0.7244 |
| cosine_precision@3 | 0.2851 |
| cosine_precision@5 | 0.1781 |
| cosine_precision@10 | 0.0927 |
| cosine_recall@1 | 0.7244 |
| cosine_recall@3 | 0.8554 |
| cosine_recall@5 | 0.8903 |
| cosine_recall@10 | 0.9271 |
| cosine_ndcg@10 | 0.8286 |
| cosine_mrr@10 | 0.7968 |
| cosine_map@100 | 0.7999 |
dim_512{
"truncate_dim": 512
}
| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.7239 |
| cosine_accuracy@3 | 0.8533 |
| cosine_accuracy@5 | 0.8874 |
| cosine_accuracy@10 | 0.927 |
| cosine_precision@1 | 0.7239 |
| cosine_precision@3 | 0.2844 |
| cosine_precision@5 | 0.1775 |
| cosine_precision@10 | 0.0927 |
| cosine_recall@1 | 0.7239 |
| cosine_recall@3 | 0.8533 |
| cosine_recall@5 | 0.8874 |
| cosine_recall@10 | 0.927 |
| cosine_ndcg@10 | 0.8273 |
| cosine_mrr@10 | 0.7952 |
| cosine_map@100 | 0.7983 |
dim_256{
"truncate_dim": 256
}
| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.7231 |
| cosine_accuracy@3 | 0.8513 |
| cosine_accuracy@5 | 0.886 |
| cosine_accuracy@10 | 0.924 |
| cosine_precision@1 | 0.7231 |
| cosine_precision@3 | 0.2838 |
| cosine_precision@5 | 0.1772 |
| cosine_precision@10 | 0.0924 |
| cosine_recall@1 | 0.7231 |
| cosine_recall@3 | 0.8513 |
| cosine_recall@5 | 0.886 |
| cosine_recall@10 | 0.924 |
| cosine_ndcg@10 | 0.8256 |
| cosine_mrr@10 | 0.7938 |
| cosine_map@100 | 0.7971 |
dim_128{
"truncate_dim": 128
}
| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.7017 |
| cosine_accuracy@3 | 0.8363 |
| cosine_accuracy@5 | 0.8726 |
| cosine_accuracy@10 | 0.9166 |
| cosine_precision@1 | 0.7017 |
| cosine_precision@3 | 0.2788 |
| cosine_precision@5 | 0.1745 |
| cosine_precision@10 | 0.0917 |
| cosine_recall@1 | 0.7017 |
| cosine_recall@3 | 0.8363 |
| cosine_recall@5 | 0.8726 |
| cosine_recall@10 | 0.9166 |
| cosine_ndcg@10 | 0.8108 |
| cosine_mrr@10 | 0.7767 |
| cosine_map@100 | 0.7803 |
dim_64{
"truncate_dim": 64
}
| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.6703 |
| cosine_accuracy@3 | 0.8053 |
| cosine_accuracy@5 | 0.8491 |
| cosine_accuracy@10 | 0.8959 |
| cosine_precision@1 | 0.6703 |
| cosine_precision@3 | 0.2684 |
| cosine_precision@5 | 0.1698 |
| cosine_precision@10 | 0.0896 |
| cosine_recall@1 | 0.6703 |
| cosine_recall@3 | 0.8053 |
| cosine_recall@5 | 0.8491 |
| cosine_recall@10 | 0.8959 |
| cosine_ndcg@10 | 0.7834 |
| cosine_mrr@10 | 0.7474 |
| cosine_map@100 | 0.7516 |
| anchor | positive | |
|---|---|---|
| type | string | string |
| details | <ul><li>min: 9 tokens</li><li>mean: 20.55 tokens</li><li>max: 43 tokens</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 46.3 tokens</li><li>max: 243 tokens</li></ul> |
| anchor | positive |
|---|---|
| <code>How many shares of class A common stock were authorized for grant under Visa's Equity Incentive Compensation Plan?</code> | <code>Under the Company’s 2007 Amended and Restated Equity Incentive Compensation Plan (EIP), the compensation committee of the board of directors was authorized to grant up to 198 million shares of class A common stock to its employees and non-employee directors.</code> |
| <code>What was Garmin Ltd.'s net income for the fiscal year ended December 30, 2023?</code> | <code>Garmin Ltd. reported a net income of $1,289,636 for the fiscal year ended December 30, 2023.</code> |
| <code>Why are some device sales revenue at AT&T not immediately recognized upon the device sale?</code> | <code>AT&T recognizes revenue from device sales with promotions or installment payments differently. For promotional discounts, revenue is deferred and amortized over the contract term. Meanwhile, installment sales involve recognizing revenue upfront but deferring the cash receipt until payments are made, resulting in a recorded contract asset to be amortized over time.</code> |
{
"loss": "MultipleNegativesRankingLoss",
"matryoshka_dims": [
768,
512,
256,
128,
64
],
"matryoshka_weights": [
1,
1,
1,
1,
1
],
"n_dims_per_step": -1
}
eval_strategy: epochper_device_eval_batch_size: 4gradient_accumulation_steps: 48learning_rate: 2e-05num_train_epochs: 4lr_scheduler_type: cosinewarmup_ratio: 0.1warmup_steps: 0.1fp16: Trueload_best_model_at_end: Truebatch_sampler: no_duplicatesdo_predict: Falseeval_strategy: epochprediction_loss_only: Trueper_device_train_batch_size: 8per_device_eval_batch_size: 4gradient_accumulation_steps: 48eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 2e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 4max_steps: -1lr_scheduler_type: cosinelr_scheduler_kwargs: Nonewarmup_ratio: 0.1warmup_steps: 0.1log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Trueenable_jit_checkpoint: Falsesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseuse_cpu: Falseseed: 42data_seed: Nonebf16: Falsefp16: Truebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: -1ddp_backend: Nonedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonedisable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Trueignore_data_skip: Falsefsdp: []fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}accelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedeepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torch_fusedoptim_args: Nonegroup_by_length: Falselength_column_name: lengthproject: huggingfacetrackio_space_id: trackioddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Truepush_to_hub: Falseresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Nonehub_always_push: Falsehub_revision: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_for_metrics: []eval_do_concat_batches: Trueauto_find_batch_size: Falsefull_determinism: Falseddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneinclude_num_input_tokens_seen: noneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseliger_kernel_config: Noneeval_use_gather_object: Falseaverage_tokens_across_devices: Trueuse_cache: Falseprompts: Nonebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| 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.6091 | 10 | 0.3092 | - | - | - | - | - |
| 1.0 | 17 | - | 0.8155 | 0.8138 | 0.8104 | 0.7948 | 0.7647 |
| 1.1827 | 20 | 0.0958 | - | - | - | - | - |
| 1.7919 | 30 | 0.0675 | - | - | - | - | - |
| 2.0 | 34 | - | 0.8257 | 0.8245 | 0.8219 | 0.8045 | 0.7757 |
| 2.3655 | 40 | 0.0458 | - | - | - | - | - |
| 2.9746 | 50 | 0.0505 | - | - | - | - | - |
| 3.0 | 51 | - | 0.8277 | 0.8259 | 0.8243 | 0.8087 | 0.7819 |
| 3.5482 | 60 | 0.0593 | - | - | - | - | - |
| 4.0 | 68 | - | 0.8286 | 0.8273 | 0.8256 | 0.8108 | 0.7834 |
@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{henderson2017efficient,
title={Efficient Natural Language Response Suggestion for Smart Reply},
author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
year={2017},
eprint={1705.00652},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
<!--
## 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.*
-->