CoolFace
Modelpublic

Master-thesis-NAP/ModernBERT-DAPT-Embed-DAPT-Math-v2

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
1likes67downloads
Model Card

ModernBERT DAPT Embed DAPT Math

This is a sentence-transformers model finetuned from Master-thesis-NAP/ModernBert-DAPT-math. 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.

Model Details

Model Description

  • Model Type: Sentence Transformer
  • Base model: Master-thesis-NAP/ModernBert-DAPT-math <!-- at revision a30384f91d764c272e6b740c256d5581325ea4bb -->
  • Maximum Sequence Length: 8192 tokens
  • Output Dimensionality: 768 dimensions
  • Similarity Function: Cosine Similarity <!-- - Training Dataset: Unknown -->
  • Language: en
  • License: apache-2.0

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 8192, 'do_lower_case': False}) with Transformer model: 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()
)

Usage

Direct Usage (Sentence Transformers)

First install the Sentence Transformers library:

bash
pip install -U sentence-transformers

Then you can load this model and run inference.

python
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("Master-thesis-NAP/ModernBERT-DAPT-Embed-DAPT-Math-v2")
# Run inference
sentences = [
    'What is the meaning of the identity containment $1_x:x\\to x$ in the context of the bond system?',
    "A \\emph{bond system} is a tuple $(B,C,s,t,1,\\cdot)$, where $B$ is a set of \\emph{bonds}, $C$ is a set of \\emph{content} relations, and $s,t:C\\to B$ are \\emph{source} and \\emph{target} functions. For $c\\in C$ with $s(c)=x$ and $t(c)=y$, we write $x\\xrightarrow{c}y$ or $c:x\\to y$, indicating that $x$ \\emph{contains} $y$. Each bond $x\\in B$ has an \\emph{identity} containment $1_x:x\\to x$, meaning every bond trivially contains itself. For $c:x\\to y$ and $c':y\\to z$, their composition is $cc':x\\to z$. These data must satisfy:\n    \\begin{enumerate}\n        \\item Identity laws: For each $c:x\\to y$, $1_x c= c=c1_y$\n        \\item Associativity: For $c:x\\to y$, $c':y\\to z$, $c'':z\\to w$, $c(c'c'')=(cc')c''$\n        \\item Anti-symmetry: For $c:x\\to y$ and $c':y\\to x$, $x=y$\n        \\item Left cancellation: For $c,c':x\\to y$ and $c'':y\\to z$, if $cc''=c'c''$, then $c=c'$\n    \\end{enumerate}",
    '\\label{lem:opt_lin}\nConsider the optimization problem\n\\begin{equation}\\label{eq:max_tr_lem}\n\\begin{aligned}\n    \\max_{\\bs{U}}&\\;\\; \\Re\\{\\mrm{tr}(\\bs{U}^\\mrm{H}\\bs{B}) \\}\\\\\n    \\mrm{s.t. \\;\\;}& \\bs{U}\\in \\mathcal{U}(N),\n\\end{aligned}\n\\end{equation}\nwhere $\\bs{B}$ may be an arbitrary $N\\times N$ matrix with singular value decomposition (SVD) $\\bs{B}=\\bs{U}_{\\bs{B}}\\bs{S}_{\\bs{B}}\\bs{V}_{\\bs{B}}^\\mrm{H}$. The solution to \\eqref{eq:max_tr_lem} is given by\n\\begin{equation}\\label{eq:sol_max}\n    \\bs{U}_\\mrm{opt} = \\bs{U}_{\\bs{B}}^\\mrm{H}\\bs{V}_{\\bs{B}}.\n\\end{equation}\n\\begin{skproof}\n    A formal proof, which may be included in the extended version, can be obtained by defining the Riemannian gradient over the unitary group and finding the stationary point where it vanishes. However, an intuitive argument is that the solution to \\eqref{eq:max_tr_lem} is obtained by positively combining the singular values of $\\bs{B}$, leading to \\eqref{eq:sol_max}.\n\\end{skproof}',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]

<!--

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. -->

Evaluation

Metrics

Information Retrieval
MetricValue
cosine_accuracy@10.868
cosine_accuracy@30.9183
cosine_accuracy@50.9325
cosine_accuracy@100.9496
cosine_precision@10.868
cosine_precision@30.6119
cosine_precision@50.4935
cosine_precision@100.3476
cosine_recall@10.0419
cosine_recall@30.0832
cosine_recall@50.1074
cosine_recall@100.1421
cosine_ndcg@100.4493
cosine_mrr@100.8964
cosine_map@1000.1638

<!--

Bias, Risks and Limitations

What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model. -->

<!--

Recommendations

What are recommendations with respect to the foreseeable issues? For example, filtering explicit content. -->

Training Details

Training Dataset

Unnamed Dataset
  • Size: 79,876 training samples
  • Columns: <code>anchor</code> and <code>positive</code>
  • Approximate statistics based on the first 1000 samples: | | anchor | positive | |:--------|:-----------------------------------------------------------------------------------|:------------------------------------------------------------------------------------| | type | string | string | | details | <ul><li>min: 9 tokens</li><li>mean: 38.48 tokens</li><li>max: 142 tokens</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 210.43 tokens</li><li>max: 924 tokens</li></ul> |
  • Samples: | anchor | positive | |:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>What is the limit of the proportion of 1's in the sequence $an$ as $n$ approaches infinity, given that $0 \leq 3gn -2n \leq 4$?</code> | <code>Let $gn$ be the number of $1$'s in the sequence $a1 a2 \cdots an$.<br>Then <br>\begin{equation}<br>0 \leq 3gn -2n \leq 4<br>\label{star}<br>\end{equation}<br>for all $n$, and hence<br>$\lim{n \rightarrow \infty} gn/n = 2/3$.<br>\label{thm1}</code> | | <code>Does the statement of \textbf{ThmConjAreTrue} imply that the maximum genus of a locally Cohen-Macaulay curve in $\mathbb{P}^3{\mathbb{C}}$ of degree $d$ that does not lie on a surface of degree $s-1$ is always equal to $g(d,s)$?</code> | <code>\label{ThmConjAreTrue}<br>Conjectures \ref{Conj1} and \ref{Conj2} are true.<br>As a consequence, <br>if either $d=s \geq 1$ or $d \geq 2s+1 \geq 3$, <br>the maximum genus of a locally Cohen-Macaulay curve in $\mathbb{P}^3_{\mathbb{C}}$ of degree $d$ that does not lie on a surface of degree $s-1$ is equal to $g(d,s)$.</code> | | <code>\\emph{Is the statement \emph{If $X$ is a compact Hausdorff space, then $X$ is normal}, proven in the first isomorphism theorem for topological groups, or is it a well-known result in topology?}</code> | <code>}<br>\newcommand{\ep}{</code> |
  • Loss: <code>MultipleNegativesRankingLoss</code> with these parameters:
json
  {
      "scale": 20.0,
      "similarity_fct": "cos_sim"
  }

Training Hyperparameters

Non-Default Hyperparameters
  • eval_strategy: epoch
  • per_device_train_batch_size: 16
  • per_device_eval_batch_size: 16
  • gradient_accumulation_steps: 8
  • learning_rate: 2e-05
  • num_train_epochs: 4
  • lr_scheduler_type: cosine
  • warmup_ratio: 0.1
  • bf16: True
  • tf32: True
  • load_best_model_at_end: True
  • optim: adamwtorchfused
  • batch_sampler: no_duplicates
All Hyperparameters

<details><summary>Click to expand</summary>

  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: epoch
  • prediction_loss_only: True
  • per_device_train_batch_size: 16
  • per_device_eval_batch_size: 16
  • per_gpu_train_batch_size: None
  • per_gpu_eval_batch_size: None
  • gradient_accumulation_steps: 8
  • eval_accumulation_steps: None
  • torch_empty_cache_steps: None
  • learning_rate: 2e-05
  • weight_decay: 0.0
  • adam_beta1: 0.9
  • adam_beta2: 0.999
  • adam_epsilon: 1e-08
  • max_grad_norm: 1.0
  • num_train_epochs: 4
  • max_steps: -1
  • lr_scheduler_type: cosine
  • lr_scheduler_kwargs: {}
  • warmup_ratio: 0.1
  • warmup_steps: 0
  • log_level: passive
  • log_level_replica: warning
  • log_on_each_node: True
  • logging_nan_inf_filter: True
  • save_safetensors: True
  • save_on_each_node: False
  • save_only_model: False
  • restore_callback_states_from_checkpoint: False
  • no_cuda: False
  • use_cpu: False
  • use_mps_device: False
  • seed: 42
  • data_seed: None
  • jit_mode_eval: False
  • use_ipex: False
  • bf16: True
  • fp16: False
  • fp16_opt_level: O1
  • half_precision_backend: auto
  • bf16_full_eval: False
  • fp16_full_eval: False
  • tf32: True
  • local_rank: 0
  • ddp_backend: None
  • tpu_num_cores: None
  • tpu_metrics_debug: False
  • debug: []
  • dataloader_drop_last: False
  • dataloader_num_workers: 0
  • dataloader_prefetch_factor: None
  • past_index: -1
  • disable_tqdm: False
  • remove_unused_columns: True
  • label_names: None
  • load_best_model_at_end: True
  • ignore_data_skip: False
  • fsdp: []
  • fsdp_min_num_params: 0
  • fsdp_config: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • tp_size: 0
  • fsdp_transformer_layer_cls_to_wrap: None
  • accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}
  • deepspeed: None
  • label_smoothing_factor: 0.0
  • optim: adamwtorchfused
  • optim_args: None
  • adafactor: False
  • group_by_length: False
  • length_column_name: length
  • ddp_find_unused_parameters: None
  • ddp_bucket_cap_mb: None
  • ddp_broadcast_buffers: False
  • dataloader_pin_memory: True
  • dataloader_persistent_workers: False
  • skip_memory_metrics: True
  • use_legacy_prediction_loop: False
  • push_to_hub: False
  • resume_from_checkpoint: None
  • hub_model_id: None
  • hub_strategy: every_save
  • hub_private_repo: None
  • hub_always_push: False
  • gradient_checkpointing: False
  • gradient_checkpointing_kwargs: None
  • include_inputs_for_metrics: False
  • include_for_metrics: []
  • eval_do_concat_batches: True
  • fp16_backend: auto
  • push_to_hub_model_id: None
  • push_to_hub_organization: None
  • mp_parameters:
  • auto_find_batch_size: False
  • full_determinism: False
  • torchdynamo: None
  • ray_scope: last
  • ddp_timeout: 1800
  • torch_compile: False
  • torch_compile_backend: None
  • torch_compile_mode: None
  • include_tokens_per_second: False
  • include_num_input_tokens_seen: False
  • neftune_noise_alpha: None
  • optim_target_modules: None
  • batch_eval_metrics: False
  • eval_on_start: False
  • use_liger_kernel: False
  • eval_use_gather_object: False
  • average_tokens_across_devices: False
  • prompts: None
  • batch_sampler: no_duplicates
  • multi_dataset_batch_sampler: proportional

</details>

Training Logs

<details><summary>Click to expand</summary>

EpochStepTraining LossTESTING_cosine_ndcg@10
0.01601020.2777-
0.03202019.6613-
0.04813018.8588-
0.06414017.5525-
0.08015015.1065-
0.09616010.8128-
0.1122707.0698-
0.1282804.532-
0.1442903.5143-
0.16021002.3256-
0.17621101.4688-
0.19231201.0081-
0.20831300.949-
0.22431400.9709-
0.24031500.8403-
0.25641600.8749-
0.27241700.7955-
0.28841800.6587-
0.30441900.5832-
0.32042000.5376-
0.33652100.608-
0.35252200.4639-
0.36852300.6611-
0.38452400.5589-
0.40062500.5845-
0.41662600.4392-
0.43262700.4746-
0.44862800.4517-
0.46472900.4034-
0.48073000.4437-
0.49673100.4339-
0.51273200.4445-
0.52873300.3793-
0.54483400.3591-
0.56083500.4694-
0.57683600.4668-
0.59283700.4121-
0.60893800.4688-
0.62493900.387-
0.64094000.3748-
0.65694100.2997-
0.67294200.3756-
0.68904300.2993-
0.70504400.3514-
0.72104500.3646-
0.73704600.308-
0.75314700.3612-
0.76914800.2845-
0.78514900.2792-
0.80115000.2204-
0.81715100.2757-
0.83325200.2674-
0.84925300.3753-
0.86525400.3546-
0.88125500.3166-
0.89735600.2656-
0.91335700.3215-
0.92935800.2559-
0.94535900.4629-
0.96136000.31-
0.97746100.3601-
0.99346200.2391-
1.0625-0.4229
1.00806300.2507-
1.02406400.1852-
1.04016500.1836-
1.05616600.1487-
1.07216700.1495-
1.08816800.1567-
1.10416900.1497-
1.12027000.1632-
1.13627100.1997-
1.15227200.182-
1.16827300.1884-
1.18437400.1766-
1.20037500.1477-
1.21637600.181-
1.23237700.092-
1.24837800.1506-
1.26447900.1305-
1.28048000.1533-
1.29648100.2306-
1.31248200.1861-
1.32858300.1157-
1.34458400.1054-
1.36058500.1696-
1.37658600.1327-
1.39258700.1485-
1.40868800.1395-
1.42468900.1021-
1.44069000.1283-
1.45669100.102-
1.47279200.1825-
1.48879300.1395-
1.50479400.157-
1.52079500.1444-
1.53689600.1317-
1.55289700.146-
1.56889800.1809-
1.58489900.1368-
1.600810000.2036-
1.616910100.1292-
1.632910200.1306-
1.648910300.1473-
1.664910400.1595-
1.681010500.1471-
1.697010600.1869-
1.713010700.1445-
1.729010800.157-
1.745010900.1382-
1.761111000.157-
1.777111100.1073-
1.793111200.0864-
1.809111300.1312-
1.825211400.1644-
1.841211500.1366-
1.857211600.1257-
1.873211700.127-
1.889211800.1494-
1.905311900.1516-
1.921312000.1709-
1.937312100.1717-
1.953312200.1044-
1.969412300.1551-
1.985412400.1303-
2.012500.10810.4392
2.016012600.0572-
2.032012700.0504-
2.048112800.0535-
2.064112900.0512-
2.080113000.0539-
2.096113100.0462-
2.112213200.0611-
2.128213300.0989-
2.144213400.0462-
2.160213500.061-
2.176213600.0557-
2.192313700.0622-
2.208313800.0744-
2.224313900.0531-
2.240314000.0507-
2.256414100.0533-
2.272414200.0676-
2.288414300.0706-
2.304414400.0452-
2.320414500.0415-
2.336514600.0562-
2.352514700.0487-
2.368514800.0614-
2.384514900.045-
2.400615000.0529-
2.416615100.048-
2.432615200.059-
2.448615300.0593-
2.464715400.0631-
2.480715500.0506-
2.496715600.058-
2.512715700.0896-
2.528715800.0522-
2.544815900.035-
2.560816000.0677-
2.576816100.0538-
2.592816200.0485-
2.608916300.0575-
2.624916400.0571-
2.640916500.0761-
2.656916600.0582-
2.672916700.0366-
2.689016800.0445-
2.705016900.0519-
2.721017000.0506-
2.737017100.0637-
2.753117200.0618-
2.769117300.0433-
2.785117400.0503-
2.801117500.0541-
2.817117600.0443-
2.833217700.0634-
2.849217800.0586-
2.865217900.0497-
2.881218000.0444-
2.897318100.0397-
2.913318200.0483-
2.929318300.0441-
2.945318400.0758-
2.961318500.0988-
2.977418600.0566-
2.993418700.0497-
3.01875-0.4466
3.008018800.0388-
3.024018900.0278-
3.040119000.0231-
3.056119100.0482-
3.072119200.0416-
3.088119300.052-
3.104119400.0403-
3.120219500.0384-
3.136219600.0288-
3.152219700.0368-
3.168219800.0301-
3.184319900.029-
3.200320000.0332-
3.216320100.0307-
3.232320200.0502-
3.248320300.0474-
3.264420400.0383-
3.280420500.0392-
3.296420600.0308-
3.312420700.0479-
3.328520800.0448-
3.344520900.0478-
3.360521000.0249-
3.376521100.03-
3.392521200.0284-
3.408621300.0323-
3.424621400.0379-
3.440621500.0221-
3.456621600.0354-
3.472721700.0332-
3.488721800.0287-
3.504721900.0382-
3.520722000.0342-
3.536822100.0381-
3.552822200.056-
3.568822300.0426-
3.584822400.0465-
3.600822500.0372-
3.616922600.0345-
3.632922700.0459-
3.648922800.0368-
3.664922900.0349-
3.681023000.059-
3.697023100.0275-
3.713023200.0305-
3.729023300.0406-
3.745023400.0456-
3.761123500.0311-
3.777123600.0428-
3.793123700.0308-
3.809123800.0345-
3.825223900.0378-
3.841224000.0322-
3.857224100.0236-
3.873224200.0383-
3.889224300.0295-
3.905324400.0273-
3.921324500.0286-
3.937324600.0366-
3.953324700.0285-
3.969424800.0335-
3.985424900.0278-
3.9952496-0.4493
  • The bold row denotes the saved checkpoint. </details>

Framework Versions

  • Python: 3.11.12
  • Sentence Transformers: 4.1.0
  • Transformers: 4.51.3
  • PyTorch: 2.6.0+cu124
  • Accelerate: 1.6.0
  • Datasets: 2.14.4
  • Tokenizers: 0.21.1

Citation

BibTeX

Sentence Transformers
bibtex
@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
bibtex
@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. -->