Views
No views yet
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({})
)pip install -U sentence-transformers1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("sentence_transformers_model_id")
5# Run inference
6queries = [
7 'define reservedness',
8]
9documents = [
10 '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',
11 "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.",
12 '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 ...',
13]
14query_embeddings = model.encode_query(queries)
15document_embeddings = model.encode_document(documents)
16print(query_embeddings.shape, document_embeddings.shape)
17# [1, 768] [3, 768]
18
19# Get the similarity scores for the embeddings
20similarities = model.similarity(query_embeddings, document_embeddings)
21print(similarities)
22# tensor([[0.5320, 0.4636, 0.3707]])NanoClimateFEVER, NanoDBPedia, NanoFEVER, NanoFiQA2018,
NanoHotpotQA, NanoMSMARCO, NanoNFCorpus, NanoNQ, NanoQuoraRetrieval,
NanoSCIDOCS, NanoArguAna, NanoSciFact and NanoTouche2020InformationRetrievalEvaluator
with these parameters:
1{
2 "query_prompt": "query: ",
3 "corpus_prompt": "document: "
4}| 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 |
NanoBEIR_meanNanoBEIREvaluator
with these parameters:
1{
2 "dataset_names": [
3 "climatefever",
4 "dbpedia",
5 "fever",
6 "fiqa2018",
7 "hotpotqa",
8 "msmarco",
9 "nfcorpus",
10 "nq",
11 "quoraretrieval",
12 "scidocs",
13 "arguana",
14 "scifact",
15 "touche2020"
16 ],
17 "dataset_id": "sentence-transformers/NanoBEIR-en",
18 "query_prompts": {
19 "climatefever": "query: ",
20 "dbpedia": "query: ",
21 "fever": "query: ",
22 "fiqa2018": "query: ",
23 "hotpotqa": "query: ",
24 "msmarco": "query: ",
25 "nfcorpus": "query: ",
26 "nq": "query: ",
27 "quoraretrieval": "query: ",
28 "scidocs": "query: ",
29 "arguana": "query: ",
30 "scifact": "query: ",
31 "touche2020": "query: "
32 },
33 "corpus_prompts": {
34 "climatefever": "document: ",
35 "dbpedia": "document: ",
36 "fever": "document: ",
37 "fiqa2018": "document: ",
38 "hotpotqa": "document: ",
39 "msmarco": "document: ",
40 "nfcorpus": "document: ",
41 "nq": "document: ",
42 "quoraretrieval": "document: ",
43 "scidocs": "document: ",
44 "arguana": "document: ",
45 "scifact": "document: ",
46 "touche2020": "document: "
47 }
48}| 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 |
query, positive, negative_1,
negative_2, negative_3, negative_4,
negative_5, negative_6, negative_7,
negative_8, and label
|EmbedDistillLoss
with these parameters:
1{
2 "distance_metric": "l2",
3 "projection_dim": null
4}EmbedDistillLoss
with these parameters:1{
2 "distance_metric": "l2",
3 "projection_dim": null
4}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: Falseper_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: {}1@inproceedings{reimers-2019-sentence-bert,
2 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
3 author = "Reimers, Nils and Gurevych, Iryna",
4 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
5 month = "11",
6 year = "2019",
7 publisher = "Association for Computational Linguistics",
8 url = "https://arxiv.org/abs/1908.10084",
9}1@article{kim2023embeddistill,
2 title={EmbedDistill: A Geometric Knowledge Distillation for Information Retrieval},
3 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},
4 year={2023},
5 eprint={2301.12005},
6 archivePrefix={arXiv},
7 primaryClass={cs.IR}
8}