sentence-transformers/quora-duplicates
Viewer • Updated • 3.45M • 1.12k • 9
How to use kwondw/quora-mnrl with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("kwondw/quora-mnrl")
sentences = [
"What is the main circuit board of a computer? How is it built and what is its function?",
"Information systems are too important to be left to computer specialist. Do you agree?",
"What is the main circuit board of a computer? What are its functions?",
"Has reading a book ever changed your life? Which one?"
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from sentence-transformers/stsb-distilbert-base on the quora-duplicates 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/quora-mnrl")
# Run inference
queries = [
'What are the best car gadgets in 2016?',
]
documents = [
'What are some of the best gadgets of 2016?',
'What is the origin of saying God Bless You after sneezing?',
'Are there any good summer programs for high school students?',
]
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.8092, -0.1531, 0.0052]])
quora-irInformationRetrievalEvaluator| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.9612 |
| cosine_accuracy@3 | 0.99 |
| cosine_accuracy@5 | 0.9948 |
| cosine_accuracy@10 | 0.998 |
| cosine_precision@1 | 0.9612 |
| cosine_precision@3 | 0.4268 |
| cosine_precision@5 | 0.2743 |
| cosine_precision@10 | 0.1449 |
| cosine_recall@1 | 0.8277 |
| cosine_recall@3 | 0.9562 |
| cosine_recall@5 | 0.9788 |
| cosine_recall@10 | 0.9925 |
| cosine_ndcg@10 | 0.9767 |
| cosine_mrr@10 | 0.9761 |
| cosine_map@100 | 0.968 |
anchor and positive| anchor | positive | |
|---|---|---|
| type | string | string |
| modality | text | text |
| details |
|
|
| anchor | positive |
|---|---|
Astrology: I am a Capricorn Sun Cap moon and cap rising...what does that say about me? |
I'm a triple Capricorn (Sun, Moon and ascendant in Capricorn) What does this say about me? |
How can I be a good geologist? |
What should I do to be a great geologist? |
How do I read and find my YouTube comments? |
How can I see all my Youtube comments? |
CachedMultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim",
"mini_batch_size": 32,
"gather_across_devices": false,
"directions": [
"query_to_doc"
],
"partition_mode": "joint",
"hardness_mode": null,
"hardness_strength": 0.0
}
anchor and positive| anchor | positive | |
|---|---|---|
| type | string | string |
| modality | text | text |
| details |
|
|
| anchor | positive |
|---|---|
What is the best English translation of the Bhagavad Gita? |
Which is the best English version of Bhagavad-Gita? |
Quora kept refreshing on its own. Is this a normal thing or is it just me? |
Why does Quora keep refreshing the page? |
What is it like to study in McGill University? |
What is it like to study at McGill University? |
CachedMultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim",
"mini_batch_size": 32,
"gather_across_devices": false,
"directions": [
"query_to_doc"
],
"partition_mode": "joint",
"hardness_mode": null,
"hardness_strength": 0.0
}
per_device_train_batch_size: 64num_train_epochs: 1learning_rate: 2e-05warmup_steps: 0.1fp16: Trueper_device_eval_batch_size: 64load_best_model_at_end: Truebatch_sampler: no_duplicatesper_device_train_batch_size: 64num_train_epochs: 1max_steps: -1learning_rate: 2e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0.1optim: adamw_torch_fusedoptim_args: Noneweight_decay: 0.0adam_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: Falsefp16: Truebf16_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: 64prediction_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: Trueignore_data_skip: Falserestore_callback_states_from_checkpoint: Falsefull_determinism: Falseseed: 42data_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: 0dataloader_pin_memory: Truedataloader_persistent_workers: Falsedataloader_prefetch_factor: Noneremove_unused_columns: Truelabel_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: no_duplicatesmulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | Validation Loss | quora-ir_cosine_ndcg@10 |
|---|---|---|---|---|
| -1 | -1 | - | - | 0.9415 |
| 0.0640 | 100 | 0.1075 | - | - |
| 0.1280 | 200 | 0.0788 | - | - |
| 0.1599 | 250 | - | 0.0425 | 0.9656 |
| 0.1919 | 300 | 0.0625 | - | - |
| 0.2559 | 400 | 0.0601 | - | - |
| 0.3199 | 500 | 0.0626 | 0.0383 | 0.9702 |
| 0.3839 | 600 | 0.0513 | - | - |
| 0.4479 | 700 | 0.0450 | - | - |
| 0.4798 | 750 | - | 0.0383 | 0.9714 |
| 0.5118 | 800 | 0.0476 | - | - |
| 0.5758 | 900 | 0.0514 | - | - |
| 0.6398 | 1000 | 0.0383 | 0.0365 | 0.9735 |
| 0.7038 | 1100 | 0.0488 | - | - |
| 0.7678 | 1200 | 0.0425 | - | - |
| 0.7997 | 1250 | - | 0.0344 | 0.9742 |
| 0.8317 | 1300 | 0.0495 | - | - |
| 0.8957 | 1400 | 0.0379 | - | - |
| 0.9597 | 1500 | 0.0481 | 0.0340 | 0.9749 |
| 1.0 | 1563 | - | 0.0341 | 0.9748 |
| -1 | -1 | - | - | 0.9749 |
| 0.0640 | 100 | 0.0408 | - | - |
| 0.1280 | 200 | 0.0322 | - | - |
| 0.1599 | 250 | - | 0.0342 | 0.9727 |
| 0.1919 | 300 | 0.0277 | - | - |
| 0.2559 | 400 | 0.0294 | - | - |
| 0.3199 | 500 | 0.0324 | 0.0365 | 0.9742 |
| 0.3839 | 600 | 0.0327 | - | - |
| 0.4479 | 700 | 0.0284 | - | - |
| 0.4798 | 750 | - | 0.0335 | 0.9750 |
| 0.5118 | 800 | 0.0300 | - | - |
| 0.5758 | 900 | 0.0360 | - | - |
| 0.6398 | 1000 | 0.0261 | 0.0350 | 0.9753 |
| 0.7038 | 1100 | 0.0353 | - | - |
| 0.7678 | 1200 | 0.0335 | - | - |
| 0.7997 | 1250 | - | 0.0331 | 0.9763 |
| 0.8317 | 1300 | 0.0388 | - | - |
| 0.8957 | 1400 | 0.0308 | - | - |
| 0.9597 | 1500 | 0.0410 | 0.0327 | 0.9767 |
| 1.0 | 1563 | - | 0.0328 | 0.9767 |
| -1 | -1 | - | - | 0.9767 |
@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{gao2021scaling,
title={Scaling Deep Contrastive Learning Batch Size under Memory Limited Setup},
author={Luyu Gao and Yunyi Zhang and Jiawei Han and Jamie Callan},
year={2021},
eprint={2101.06983},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
Base model
sentence-transformers/stsb-distilbert-base