CoolFace
Modelpublic

tomaarsen/stsb-distilbert-base-quora-duplicate-questions

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes21downloads
Model Card

SentenceTransformer based on sentence-transformers/stsb-distilbert-base

This is a sentence-transformers model finetuned from sentence-transformers/stsb-distilbert-base. 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: sentence-transformers/stsb-distilbert-base
  • —Maximum Sequence Length: 128 tokens
  • —Output Dimensionality: 768 tokens <!-- - Training Dataset: Unknown --> <!-- - Language: Unknown --> <!-- - License: Unknown -->

Model Sources

Full Model Architecture

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

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("tomaarsen/stsb-distilbert-base-quora-duplicate-questions")
# Run inference
sentences = [
    "What is a fetish?",
    "What's a fetish?",
    "Is it good to read sex stories?",
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]

<!--

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

Binary Classification
MetricValue
cosine_accuracy0.7707
cosineaccuracythreshold0.817
cosine_f10.7086
cosinef1threshold0.742
cosine_precision0.6033
cosine_recall0.8586
cosine_ap0.7191
manhattan_accuracy0.7729
manhattanaccuracythreshold181.4664
manhattan_f10.7083
manhattanf1threshold222.9119
manhattan_precision0.6063
manhattan_recall0.8515
manhattan_ap0.7188
euclidean_accuracy0.7736
euclideanaccuracythreshold8.3566
euclidean_f10.7088
euclideanf1threshold10.0929
euclidean_precision0.6079
euclidean_recall0.8499
euclidean_ap0.7191
dot_accuracy0.7442
dotaccuracythreshold168.5663
dot_f10.6832
dotf1threshold142.4585
dot_precision0.5665
dot_recall0.8603
dot_ap0.6694
max_accuracy0.7736
maxaccuracythreshold181.4664
max_f10.7088
maxf1threshold222.9119
max_precision0.6079
max_recall0.8603
max_ap0.7191
Paraphrase Mining
MetricValue
average_precision0.478
f10.5119
precision0.4683
recall0.5645
threshold0.8193
Information Retrieval
MetricValue
cosine_accuracy@10.9654
cosine_accuracy@30.9904
cosine_accuracy@50.9948
cosine_accuracy@100.9974
cosine_precision@10.9654
cosine_precision@30.4355
cosine_precision@50.2806
cosine_precision@100.1493
cosine_recall@10.8251
cosine_recall@30.9549
cosine_recall@50.9758
cosine_recall@100.9898
cosine_ndcg@100.9786
cosine_mrr@100.9786
cosine_map@1000.9714
dot_accuracy@10.9512
dot_accuracy@30.985
dot_accuracy@50.9914
dot_accuracy@100.9964
dot_precision@10.9512
dot_precision@30.4303
dot_precision@50.2788
dot_precision@100.149
dot_recall@10.8119
dot_recall@30.946
dot_recall@50.9708
dot_recall@100.9884
dot_ndcg@100.9703
dot_mrr@100.9693
dot_map@1000.96

<!--

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: 207,326 training samples
  • —Columns: <code>sentence0</code>, <code>sentence1</code>, and <code>label</code>
  • —Approximate statistics based on the first 1000 samples: | | sentence0 | sentence1 | label | |:--------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:------------------------------| | type | string | string | int | | details | <ul><li>min: 6 tokens</li><li>mean: 13.75 tokens</li><li>max: 42 tokens</li></ul> | <ul><li>min: 6 tokens</li><li>mean: 13.74 tokens</li><li>max: 44 tokens</li></ul> | <ul><li>1: ~100.00%</li></ul> |
  • —Samples: | sentence0 | sentence1 | label | |:------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------|:---------------| | <code>How do I improve writing skill by myself?</code> | <code>How can I improve writing skills?</code> | <code>1</code> | | <code>Is it best to switch to Node.js from PHP?</code> | <code>Should I switch to Node.js or continue using PHP?</code> | <code>1</code> | | <code>What do Hillary Clinton's supporters say when confronted with all her lies and scandals?</code> | <code>What do Clinton supporters say when confronted with her scandals such as the emails and 'Clinton Cash'?</code> | <code>1</code> |
  • —Loss: <code>sentence_transformers.losses.MultipleNegativesRankingLoss.MultipleNegativesRankingLoss</code> with these parameters:
json
  {
      "scale": 20.0,
      "similarity_fct": "cos_sim"
  }

Training Hyperparameters

Non-Default Hyperparameters
  • —perdevicetrainbatchsize: 64
  • —perdeviceevalbatchsize: 64
  • —numtrainepochs: 1
  • —roundrobinsampler: True
All Hyperparameters

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

  • —overwriteoutputdir: False
  • —do_predict: False
  • —predictionlossonly: False
  • —perdevicetrainbatchsize: 64
  • —perdeviceevalbatchsize: 64
  • —pergputrainbatchsize: None
  • —pergpuevalbatchsize: None
  • —gradientaccumulationsteps: 1
  • —evalaccumulationsteps: None
  • —learning_rate: 5e-05
  • —weight_decay: 0.0
  • —adam_beta1: 0.9
  • —adam_beta2: 0.999
  • —adam_epsilon: 1e-08
  • —maxgradnorm: 1
  • —numtrainepochs: 1
  • —max_steps: -1
  • —lrschedulertype: linear
  • —lrschedulerkwargs: {}
  • —warmup_ratio: 0.0
  • —warmup_steps: 0
  • —log_level: passive
  • —loglevelreplica: warning
  • —logoneach_node: True
  • —loggingnaninf_filter: True
  • —save_safetensors: True
  • —saveoneach_node: False
  • —saveonlymodel: False
  • —no_cuda: False
  • —use_cpu: False
  • —usempsdevice: False
  • —seed: 42
  • —data_seed: None
  • —jitmodeeval: False
  • —use_ipex: False
  • —bf16: False
  • —fp16: False
  • —fp16optlevel: O1
  • —halfprecisionbackend: auto
  • —bf16fulleval: False
  • —fp16fulleval: False
  • —tf32: None
  • —local_rank: 0
  • —ddp_backend: None
  • —tpunumcores: None
  • —tpumetricsdebug: False
  • —debug: []
  • —dataloaderdroplast: False
  • —dataloadernumworkers: 0
  • —dataloaderprefetchfactor: None
  • —past_index: -1
  • —disable_tqdm: False
  • —removeunusedcolumns: True
  • —label_names: None
  • —loadbestmodelatend: False
  • —ignoredataskip: False
  • —fsdp: []
  • —fsdpminnum_params: 0
  • —fsdpconfig: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgradckpt': False}
  • —fsdptransformerlayerclsto_wrap: None
  • —acceleratorconfig: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True}
  • —deepspeed: None
  • —labelsmoothingfactor: 0.0
  • —optim: adamw_torch
  • —optim_args: None
  • —adafactor: False
  • —groupbylength: False
  • —lengthcolumnname: length
  • —ddpfindunused_parameters: None
  • —ddpbucketcap_mb: None
  • —ddpbroadcastbuffers: None
  • —dataloaderpinmemory: True
  • —dataloaderpersistentworkers: False
  • —skipmemorymetrics: True
  • —uselegacyprediction_loop: False
  • —pushtohub: False
  • —resumefromcheckpoint: None
  • —hubmodelid: None
  • —hubstrategy: everysave
  • —hubprivaterepo: False
  • —hubalwayspush: False
  • —gradient_checkpointing: False
  • —gradientcheckpointingkwargs: None
  • —includeinputsfor_metrics: False
  • —fp16_backend: auto
  • —pushtohubmodelid: None
  • —pushtohub_organization: None
  • —mp_parameters:
  • —autofindbatch_size: False
  • —full_determinism: False
  • —torchdynamo: None
  • —ray_scope: last
  • —ddp_timeout: 1800
  • —torch_compile: False
  • —torchcompilebackend: None
  • —torchcompilemode: None
  • —dispatch_batches: None
  • —split_batches: None
  • —includetokensper_second: False
  • —includenuminputtokensseen: False
  • —neftunenoisealpha: None
  • —optimtargetmodules: None
  • —roundrobinsampler: True

</details>

Training Logs

EpochStepTraining Losscosine_accuracycosine_map@100dev_average_precision
00-0.76610.93710.4137
0.15435000.10550.76320.96200.4731
0.308610000.06770.76080.96750.4732
0.463015000.06120.76630.97100.4856
0.617320000.05840.77190.96930.4925
0.771625000.05060.77140.97090.4808
0.925930000.04880.77080.97130.4784
1.03240-0.77070.97140.4780

Framework Versions

  • —Python: 3.11.6
  • —Sentence Transformers: 2.7.0.dev0
  • —Transformers: 4.39.3
  • —PyTorch: 2.1.0+cu121
  • —Accelerate: 0.26.1
  • —Datasets: 2.18.0
  • —Tokenizers: 0.15.2

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