SentenceTransformer based on capemox/ettin-encoder-17m-pretrain-50m
This is a sentence-transformers model finetuned from capemox/ettin-encoder-17m-pretrain-50m on the msmarco-embed-dense_on-triples-v3 dataset. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for retrieval.
Model Details
Model Description
- Model Type: Sentence Transformer
- Base model: capemox/ettin-encoder-17m-pretrain-50m
- Maximum Sequence Length: 8192 tokens
- Output Dimensionality: 768 dimensions
- Similarity Function: Cosine Similarity
- Supported Modality: Text
- Training Dataset:
- msmarco-embed-dense_on-triples-v3
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': 'ModernBertModel'})
(1): Pooling({'embedding_dimension': 256, 'pooling_mode': 'cls', 'include_prompt': True})
(2): Dense({'in_features': 256, 'out_features': 768, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity', 'module_input_name': 'sentence_embedding', 'module_output_name': 'sentence_embedding'})
(3): Normalize({})
)
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("sentence_transformers_model_id")
# Run inference
queries = [
'define reservedness',
]
documents = [
'Definition of reservedness in the English dictionary The definition of reservedness in the dictionary is the quality or state of being cool or formal in manner or of being restrained, silent, or reticent. english words that begin like reservedness reserve tank',
"Princeton's WordNet(0.00 / 0 votes)Rate this definition: 1 reserved(adj) set aside for the use of a particular person or party. 2 reserved(adj) marked by self-restraint and reticence.",
'In a computer language, a reserved word is a word that cannot be used as an identifier, such as the name of a variable, function, or label â\x80\x93 it is reserved from use. This is a syntactic definition, and a reserved word may have no meaning. A closely related and often conflated notion is a keyword, which is a word with special meaning in a particular context. This is a semantic definition. By contrast, names in a standard library but not built into the language are not considered reserved ...',
]
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.5320, 0.4636, 0.3707]])
Evaluation
Metrics
Information Retrieval
- Datasets:
NanoClimateFEVER,NanoDBPedia,NanoFEVER,NanoFiQA2018,NanoHotpotQA,NanoMSMARCO,NanoNFCorpus,NanoNQ,NanoQuoraRetrieval,NanoSCIDOCS,NanoArguAna,NanoSciFactandNanoTouche2020 - Evaluated with
InformationRetrievalEvaluator
with these parameters:
{ "query_prompt": "query: ", "corpus_prompt": "document: " }
| Metric | NanoClimateFEVER | NanoDBPedia | NanoFEVER | NanoFiQA2018 | NanoHotpotQA | NanoMSMARCO | NanoNFCorpus | NanoNQ | NanoQuoraRetrieval | NanoSCIDOCS | NanoArguAna | NanoSciFact | NanoTouche2020 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| cosine_accuracy@1 | 0.26 | 0.56 | 0.56 | 0.26 | 0.54 | 0.3 | 0.42 | 0.26 | 0.84 | 0.24 | 0.08 | 0.34 | 0.5714 |
| cosine_accuracy@3 | 0.4 | 0.76 | 0.8 | 0.46 | 0.76 | 0.54 | 0.46 | 0.48 | 0.96 | 0.4 | 0.32 | 0.54 | 0.8367 |
| cosine_accuracy@5 | 0.56 | 0.8 | 0.86 | 0.64 | 0.76 | 0.64 | 0.56 | 0.54 | 1.0 | 0.52 | 0.46 | 0.56 | 0.898 |
| cosine_accuracy@10 | 0.66 | 0.86 | 0.9 | 0.7 | 0.82 | 0.76 | 0.64 | 0.68 | 1.0 | 0.62 | 0.54 | 0.62 | 0.9796 |
| cosine_precision@1 | 0.26 | 0.56 | 0.56 | 0.26 | 0.54 | 0.3 | 0.42 | 0.26 | 0.84 | 0.24 | 0.08 | 0.34 | 0.5714 |
| cosine_precision@3 | 0.1733 | 0.5 | 0.2733 | 0.1867 | 0.3333 | 0.18 | 0.32 | 0.16 | 0.38 | 0.18 | 0.1067 | 0.2 | 0.517 |
| cosine_precision@5 | 0.14 | 0.48 | 0.176 | 0.16 | 0.204 | 0.128 | 0.28 | 0.108 | 0.256 | 0.172 | 0.092 | 0.128 | 0.498 |
| cosine_precision@10 | 0.086 | 0.404 | 0.092 | 0.098 | 0.114 | 0.076 | 0.228 | 0.068 | 0.134 | 0.122 | 0.054 | 0.072 | 0.4367 |
| cosine_recall@1 | 0.1017 | 0.0498 | 0.53 | 0.1399 | 0.27 | 0.3 | 0.0291 | 0.24 | 0.764 | 0.049 | 0.08 | 0.315 | 0.0401 |
| cosine_recall@3 | 0.2183 | 0.1139 | 0.78 | 0.276 | 0.5 | 0.54 | 0.0557 | 0.45 | 0.9147 | 0.1127 | 0.32 | 0.525 | 0.1104 |
| cosine_recall@5 | 0.3007 | 0.1549 | 0.84 | 0.4096 | 0.51 | 0.64 | 0.0664 | 0.5 | 0.9693 | 0.1767 | 0.46 | 0.555 | 0.174 |
| cosine_recall@10 | 0.3573 | 0.229 | 0.8667 | 0.4854 | 0.57 | 0.76 | 0.1061 | 0.63 | 0.99 | 0.2497 | 0.54 | 0.62 | 0.29 |
| cosine_ndcg@10 | 0.2816 | 0.4775 | 0.7181 | 0.3499 | 0.5209 | 0.5205 | 0.2818 | 0.4391 | 0.9278 | 0.2268 | 0.2978 | 0.4842 | 0.4805 |
| cosine_mrr@10 | 0.3716 | 0.6667 | 0.6857 | 0.3898 | 0.6437 | 0.4452 | 0.4679 | 0.3978 | 0.91 | 0.3449 | 0.2207 | 0.4427 | 0.7127 |
| cosine_map@100 | 0.2128 | 0.3258 | 0.6655 | 0.2702 | 0.4542 | 0.4553 | 0.1071 | 0.379 | 0.8999 | 0.1651 | 0.233 | 0.4466 | 0.3715 |
Nano BEIR
- Dataset:
NanoBEIR_mean - Evaluated with
NanoBEIREvaluator
with these parameters:
{ "dataset_names": [ "climatefever", "dbpedia", "fever", "fiqa2018", "hotpotqa", "msmarco", "nfcorpus", "nq", "quoraretrieval", "scidocs", "arguana", "scifact", "touche2020" ], "dataset_id": "sentence-transformers/NanoBEIR-en", "query_prompts": { "climatefever": "query: ", "dbpedia": "query: ", "fever": "query: ", "fiqa2018": "query: ", "hotpotqa": "query: ", "msmarco": "query: ", "nfcorpus": "query: ", "nq": "query: ", "quoraretrieval": "query: ", "scidocs": "query: ", "arguana": "query: ", "scifact": "query: ", "touche2020": "query: " }, "corpus_prompts": { "climatefever": "document: ", "dbpedia": "document: ", "fever": "document: ", "fiqa2018": "document: ", "hotpotqa": "document: ", "msmarco": "document: ", "nfcorpus": "document: ", "nq": "document: ", "quoraretrieval": "document: ", "scidocs": "document: ", "arguana": "document: ", "scifact": "document: ", "touche2020": "document: " } }
| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.4024 |
| cosine_accuracy@3 | 0.5936 |
| cosine_accuracy@5 | 0.6768 |
| cosine_accuracy@10 | 0.7523 |
| cosine_precision@1 | 0.4024 |
| cosine_precision@3 | 0.27 |
| cosine_precision@5 | 0.2171 |
| cosine_precision@10 | 0.1527 |
| cosine_recall@1 | 0.2237 |
| cosine_recall@3 | 0.3782 |
| cosine_recall@5 | 0.4428 |
| cosine_recall@10 | 0.5149 |
| cosine_ndcg@10 | 0.462 |
| cosine_mrr@10 | 0.5153 |
| cosine_map@100 | 0.3835 |
Training Details
Training Dataset
msmarco-embed-dense_on-triples-v3
- Dataset: msmarco-embed-dense_on-triples-v3
- Size: 483,497 training samples
- Columns: query, positive, negative_1, negative_2, negative_3, negative_4, negative_5, negative_6, negative_7, negative_8, and label |
- Loss:
EmbedDistillLoss
with these parameters:
{ "distance_metric": "l2", "projection_dim": null }
Evaluation Dataset
msmarco-embed-dense_on-triples-v3
-
Dataset: msmarco-embed-dense_on-triples-v3
-
Size: 10,000 evaluation samples
-
Loss: EmbedDistillLoss with these parameters:
{ "distance_metric": "l2", "projection_dim": null }
Training Hyperparameters
Non-Default Hyperparameters
per_device_train_batch_size: 128num_train_epochs: 4max_steps: 15000learning_rate: 0.0001lr_scheduler_type: constantweight_decay: 0.01bf16: Trueper_device_eval_batch_size: 16seed: 12dataloader_num_workers: 2remove_unused_columns: False
All Hyperparameters
per_device_train_batch_size: 128num_train_epochs: 4max_steps: 15000learning_rate: 0.0001lr_scheduler_type: constantlr_scheduler_kwargs: Nonewarmup_steps: 0optim: adamw_torch_fusedoptim_args: Noneweight_decay: 0.01adam_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: 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: Falseignore_data_skip: Falserestore_callback_states_from_checkpoint: Falsefull_determinism: Falseseed: 12data_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: Noneremove_unused_columns: Falselabel_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: Nonewarmup_ratio: Nonelocal_rank: -1prompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}
Training Time
- Training: 3.3 hours
- Evaluation: 32.0 minutes
- Total: 3.9 hours
Framework Versions
- Python: 3.11.12
- Sentence Transformers: 5.6.1
- Transformers: 5.14.1
- PyTorch: 2.13.0+cu130
- Accelerate: 1.14.0
- Datasets: 5.0.1
- Tokenizers: 0.22.2
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",
}
EmbedDistillLoss
@article{kim2023embeddistill,
title={EmbedDistill: A Geometric Knowledge Distillation for Information Retrieval},
author={Kim, Seungyeon and Rawat, Ankit Singh and Zaheer, Manzil and Jayasumana, Sadeep and Sadhanala, Veeranjaneyulu and Jitkrittum, Wittawat and Menon, Aditya Krishna and Fergus, Rob and Kumar, Sanjiv},
year={2023},
eprint={2301.12005},
archivePrefix={arXiv},
primaryClass={cs.IR}
}