Improving Efficient Neural Ranking Models with Cross-Architecture Knowledge Distillation
Paper • 2010.02666 • Published
How to use kwondw/distilbert-base-uncased-msmarco-margin-mse with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("kwondw/distilbert-base-uncased-msmarco-margin-mse")
sentences = [
"how long does raw chicken last in the fridge after buying",
"Confidence votes 7.7K. The study of tissues is called histology. Histology is the study of the microscopic anatomy of cells and tissues in plants and animals. A Histologist is a specialist in the study of the organization of tissue at all levels. Hist means Tissue Ologist means Specialist. Bio-molecules into Cells is Biochemistry.",
"It is believed that the bones of a chicken are ideal for dogs. They can easily be chewed, are soft, easily digested by most dogs, and good for their health. Obviously if you see any adverse side effects call your vet, but most healthy dogs do nothing but thrive on raw meaty bones.Some owners feed nothing but raw food.Generally, veterinarians say raw bones are safer for dogs than cooked chicken bones, which should never be fed. The reason is raw bones are typically more flexible, so theyâll bend rather than break as your dog chews it,â says Paw Posse.",
"1 How long does raw chicken last after the sell-by date? 2 After chicken is purchased, it may be refrigerated for 1 to 2 days â the sell-by date on the package may expire during that storage period, but the chicken will remain safe to use after the sell by date if it has been properly stored."
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from distilbert/distilbert-base-uncased on the msmarco dataset. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for retrieval.
SentenceTransformer(
(0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'DistilBertModel'})
(1): Pooling({'embedding_dimension': 768, 'pooling_mode': 'mean', 'include_prompt': True})
)
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("kwondw/distilbert-base-uncased-msmarco-margin-mse")
# Run inference
queries = [
'average pay of it analyst in austin texas',
]
documents = [
'How much does an IT Analyst in Austin, TX make? The average IT Analyst salary in Austin, TX is approximately $26.79 per hour, which is 26% below the national average. Salary information comes from 76 data points collected directly from employees, users, and past and present job advertisements on Indeed in the past 24 months.',
'The best city between Austin, TX and Santa Fe, NM to meet is Lubbock, Texas which is about 34 miles from the exact midpoint. The town that marks the exact halfway point is actually Close City, Texas.',
'Food and cosmetic use. Arrowroot powder is a natural powdered root starch that is white in color and very lightweight. It is derived from the tropical South American plant Maranta arundinacea. The plant was given the name â\x80\x9cArrowrootâ\x80\x9d because it was once used to treat those injured with wounds from poisoned arrows.',
]
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([[46.6321, 42.2351, 35.4387]])
NanoMSMARCOInformationRetrievalEvaluator| Metric | Value |
|---|---|
| dot_accuracy@1 | 0.02 |
| dot_accuracy@3 | 0.04 |
| dot_accuracy@5 | 0.08 |
| dot_accuracy@10 | 0.14 |
| dot_precision@1 | 0.02 |
| dot_precision@3 | 0.0133 |
| dot_precision@5 | 0.016 |
| dot_precision@10 | 0.014 |
| dot_recall@1 | 0.02 |
| dot_recall@3 | 0.04 |
| dot_recall@5 | 0.08 |
| dot_recall@10 | 0.14 |
| dot_ndcg@10 | 0.0683 |
| dot_mrr@10 | 0.0469 |
| dot_map@100 | 0.0689 |
score, query, positive, and negative| score | query | positive | negative | |
|---|---|---|---|---|
| type | float | string | string | string |
| details |
|
|
|
|
| score | query | positive | negative |
|---|---|---|---|
18.26768692334493 |
weisskopf syndrome |
Dinno-Shearer-Weisskopf syndrome: Introduction. Dinno-Shearer-Weisskopf syndrome: A very rare syndrome characterized mainly by long limbs, tall stature, large head, ataxia and facial anomalies. More detailed information about the symptoms, causes, and treatments of Dinno-Shearer-Weisskopf syndrome is available below. |
Related posts: 1 Charles Bonnet Syndrome - Treatment, Symptoms and Causes. 2 Refeeding Syndrome - Symptoms, Causes, Diagnosis, Treatment Guidelines. 3 Dubowitz Syndrome. |
21.609440167744957 |
weather in beirut, lebanon |
Beirut: Annual Weather Averages. August is the hottest month in Beirut with an average temperature of 28°C (82°F) and the coldest is February at 13°C (55°F) with the most daily sunshine hours at 14 in July. The wettest month is January with an average of 130mm of rain. |
When Brant and his Mohawk warriors joined the fortunes. of the Johnson family in Canada, the influence of President. Whelock, of Lebanon Institute, where Brant had received his. early education, was brought to bear upon the crisis. |
15.881475607554119 |
what are the clots in my period |
Blood Clots during Period. It is normal to pass blood clots during menses, as along with the blood the thickened lining of the uterus is also being shed and expelled outside the body. In case the abnormal blood clots during period occur, visit your gynecologist as it may then be an indication of other serious medical illnesses. |
Heparin lock flush is used for: Preventing blood clots from forming in intravenous (IV) lines or catheters. Heparin lock flush is an anticoagulant. It works by preventing blood clots from forming in intravenous lines when they are not in use. Do NOT use heparin lock flush if: |
MarginMSELoss with these parameters:{
"similarity_fct": "pairwise_dot_score"
}
per_device_train_batch_size: 32per_device_eval_batch_size: 32num_train_epochs: 1warmup_steps: 0.1fp16: Truedo_predict: Falseprediction_loss_only: Trueper_device_train_batch_size: 32per_device_eval_batch_size: 32gradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 5e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 1max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_ratio: Nonewarmup_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: Truedataloader_num_workers: 0dataloader_prefetch_factor: Nonedisable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Falseignore_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: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | NanoMSMARCO_dot_ndcg@10 |
|---|---|---|---|
| -1 | -1 | - | 0.0683 |
| 1.0 | 1 | 186.3345 | 0.0683 |
| -1 | -1 | - | 0.0683 |
@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{hofstätter2021improving,
title={Improving Efficient Neural Ranking Models with Cross-Architecture Knowledge Distillation},
author={Sebastian Hofstätter and Sophia Althammer and Michael Schröder and Mete Sertkan and Allan Hanbury},
year={2021},
eprint={2010.02666},
archivePrefix={arXiv},
primaryClass={cs.IR}
}
Base model
distilbert/distilbert-base-uncased