CoolFace
Modelpublic

sentence-transformers-testing/stsb-bert-tiny-lora

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
4likes
Model Card

stsb-bert-tiny adapter finetuned on GooAQ pairs

This is a sentence-transformers model finetuned from sentence-transformers-testing/stsb-bert-tiny-safetensors on the gooaq dataset. It maps sentences & paragraphs to a 128-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.

This model was trained using train_script.py.

Model Details

Model Description

  • Model Type: Sentence Transformer
  • Base model: sentence-transformers-testing/stsb-bert-tiny-safetensors <!-- at revision f3cb857cba53019a20df283396bcca179cf051a4 -->
  • Maximum Sequence Length: 512 tokens
  • Output Dimensionality: 128 dimensions
  • Similarity Function: Cosine Similarity
  • Training Dataset:
  • gooaq
  • Language: en
  • License: apache-2.0

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: BertModel 
  (1): Pooling({'word_embedding_dimension': 128, '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("sentence-transformers-testing/stsb-bert-tiny-lora")
# Run inference
sentences = [
    "how to reverse a video on tiktok that's not yours?",
    '[\'Tap "Effects" at the bottom of your screen — it\\\'s an icon that looks like a clock. Open the Effects menu. ... \', \'At the end of the new list that appears, tap "Time." Select "Time" at the end. ... \', \'Select "Reverse" — you\\\'ll then see a preview of your new, reversed video appear on the screen.\']',
    'Relative age is the age of a rock layer (or the fossils it contains) compared to other layers. It can be determined by looking at the position of rock layers. Absolute age is the numeric age of a layer of rocks or fossils. Absolute age can be determined by using radiometric dating.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 128]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]

<!--

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

Information Retrieval
  • Datasets: NanoClimateFEVER, NanoDBPedia, NanoFEVER, NanoFiQA2018, NanoHotpotQA, NanoMSMARCO, NanoNFCorpus, NanoNQ, NanoQuoraRetrieval, NanoSCIDOCS, NanoArguAna, NanoSciFact and NanoTouche2020
  • Evaluated with <code>InformationRetrievalEvaluator</code>
MetricNanoClimateFEVERNanoDBPediaNanoFEVERNanoFiQA2018NanoHotpotQANanoMSMARCONanoNFCorpusNanoNQNanoQuoraRetrievalNanoSCIDOCSNanoArguAnaNanoSciFactNanoTouche2020
cosine_accuracy@10.140.420.120.060.360.060.20.080.70.180.080.080.2041
cosine_accuracy@30.220.620.180.10.520.260.260.180.820.260.260.220.5102
cosine_accuracy@50.260.720.220.20.540.320.30.20.880.320.320.30.7551
cosine_accuracy@100.380.860.360.280.620.360.440.420.940.40.40.320.8776
cosine_precision@10.140.420.120.060.360.060.20.080.70.180.080.080.2041
cosine_precision@30.080.340.060.040.20670.08670.120.060.320.120.08670.07330.2517
cosine_precision@50.0560.3440.0440.0480.140.0640.0960.040.2240.0920.0640.0640.2531
cosine_precision@100.050.290.0360.0320.0780.0360.080.0420.1180.0660.040.0340.2449
cosine_recall@10.05670.02630.120.0440.180.060.00380.080.6240.0360.080.080.0144
cosine_recall@30.08670.06040.180.0620.310.260.00730.170.7720.07470.260.1950.0488
cosine_recall@50.11170.10270.220.12490.350.320.01270.190.8660.09470.320.280.0793
cosine_recall@100.17830.19610.340.15570.390.360.01930.40.89930.13470.40.30.1465
cosine_ndcg@100.14120.34150.21220.1040.35050.21420.09870.20520.79930.13480.23750.19370.2486
cosine_mrr@100.19940.55040.17490.10820.44760.16670.25390.15070.77980.24210.18570.16470.4082
cosine_map@1000.11360.21130.18860.08040.29310.19160.01890.1610.76350.10260.19850.16540.1638
Nano BEIR
MetricValue
cosine_accuracy@10.2065
cosine_accuracy@30.3392
cosine_accuracy@50.4104
cosine_accuracy@100.5121
cosine_precision@10.2065
cosine_precision@30.1419
cosine_precision@50.1176
cosine_precision@100.0882
cosine_recall@10.1081
cosine_recall@30.1913
cosine_recall@50.2363
cosine_recall@100.3015
cosine_ndcg@100.2524
cosine_mrr@100.2948
cosine_map@1000.204

<!--

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

gooaq
  • Dataset: gooaq at b089f72
  • Size: 3,012,496 training samples
  • Columns: <code>question</code> and <code>answer</code>
  • Approximate statistics based on the first 1000 samples: | | question | answer | |:--------|:----------------------------------------------------------------------------------|:------------------------------------------------------------------------------------| | type | string | string | | details | <ul><li>min: 8 tokens</li><li>mean: 11.86 tokens</li><li>max: 21 tokens</li></ul> | <ul><li>min: 14 tokens</li><li>mean: 60.48 tokens</li><li>max: 138 tokens</li></ul> |
  • Samples: | question | answer | |:-----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>what is the difference between broilers and layers?</code> | <code>An egg laying poultry is called egger or layer whereas broilers are reared for obtaining meat. So a layer should be able to produce more number of large sized eggs, without growing too much. On the other hand, a broiler should yield more meat and hence should be able to grow well.</code> | | <code>what is the difference between chronological order and spatial order?</code> | <code>As a writer, you should always remember that unlike chronological order and the other organizational methods for data, spatial order does not take into account the time. Spatial order is primarily focused on the location. All it does is take into account the location of objects and not the time.</code> | | <code>is kamagra same as viagra?</code> | <code>Kamagra is thought to contain the same active ingredient as Viagra, sildenafil citrate. In theory, it should work in much the same way as Viagra, taking about 45 minutes to take effect, and lasting for around 4-6 hours. However, this will vary from person to person.</code> |
  • Loss: <code>MultipleNegativesRankingLoss</code> with these parameters:
json
  {
      "scale": 20.0,
      "similarity_fct": "cos_sim"
  }

Evaluation Dataset

gooaq
  • Dataset: gooaq at b089f72
  • Size: 3,012,496 evaluation samples
  • Columns: <code>question</code> and <code>answer</code>
  • Approximate statistics based on the first 1000 samples: | | question | answer | |:--------|:----------------------------------------------------------------------------------|:------------------------------------------------------------------------------------| | type | string | string | | details | <ul><li>min: 8 tokens</li><li>mean: 11.88 tokens</li><li>max: 22 tokens</li></ul> | <ul><li>min: 14 tokens</li><li>mean: 61.03 tokens</li><li>max: 127 tokens</li></ul> |
  • Samples: | question | answer | |:-----------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>how do i program my directv remote with my tv?</code> | <code>['Press MENU on your remote.', 'Select Settings & Help > Settings > Remote Control > Program Remote.', 'Choose the device (TV, audio, DVD) you wish to program. ... ', 'Follow the on-screen prompts to complete programming.']</code> | | <code>are rodrigues fruit bats nocturnal?</code> | <code>Before its numbers were threatened by habitat destruction, storms, and hunting, some of those groups could number 500 or more members. Sunrise, sunset. Rodrigues fruit bats are most active at dawn, at dusk, and at night.</code> | | <code>why does your heart rate increase during exercise bbc bitesize?</code> | <code>During exercise there is an increase in physical activity and muscle cells respire more than they do when the body is at rest. The heart rate increases during exercise. The rate and depth of breathing increases - this makes sure that more oxygen is absorbed into the blood, and more carbon dioxide is removed from it.</code> |
  • Loss: <code>MultipleNegativesRankingLoss</code> with these parameters:
json
  {
      "scale": 20.0,
      "similarity_fct": "cos_sim"
  }

Training Hyperparameters

Non-Default Hyperparameters
  • eval_strategy: steps
  • per_device_train_batch_size: 1024
  • per_device_eval_batch_size: 1024
  • learning_rate: 2e-05
  • num_train_epochs: 1
  • warmup_ratio: 0.1
  • bf16: True
  • batch_sampler: no_duplicates
All Hyperparameters

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

  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: steps
  • prediction_loss_only: True
  • per_device_train_batch_size: 1024
  • per_device_eval_batch_size: 1024
  • per_gpu_train_batch_size: None
  • per_gpu_eval_batch_size: None
  • gradient_accumulation_steps: 1
  • eval_accumulation_steps: None
  • torch_empty_cache_steps: None
  • learning_rate: 2e-05
  • weight_decay: 0.0
  • adam_beta1: 0.9
  • adam_beta2: 0.999
  • adam_epsilon: 1e-08
  • max_grad_norm: 1.0
  • num_train_epochs: 1
  • max_steps: -1
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: {}
  • warmup_ratio: 0.1
  • warmup_steps: 0
  • log_level: passive
  • log_level_replica: warning
  • log_on_each_node: True
  • logging_nan_inf_filter: True
  • save_safetensors: True
  • save_on_each_node: False
  • save_only_model: False
  • restore_callback_states_from_checkpoint: False
  • no_cuda: False
  • use_cpu: False
  • use_mps_device: False
  • seed: 42
  • data_seed: None
  • jit_mode_eval: False
  • use_ipex: False
  • bf16: True
  • fp16: False
  • fp16_opt_level: O1
  • half_precision_backend: auto
  • bf16_full_eval: False
  • fp16_full_eval: False
  • tf32: None
  • local_rank: 0
  • ddp_backend: None
  • tpu_num_cores: None
  • tpu_metrics_debug: False
  • debug: []
  • dataloader_drop_last: False
  • dataloader_num_workers: 0
  • dataloader_prefetch_factor: None
  • past_index: -1
  • disable_tqdm: False
  • remove_unused_columns: True
  • label_names: None
  • load_best_model_at_end: False
  • ignore_data_skip: False
  • fsdp: []
  • fsdp_min_num_params: 0
  • fsdp_config: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • fsdp_transformer_layer_cls_to_wrap: None
  • accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}
  • deepspeed: None
  • label_smoothing_factor: 0.0
  • optim: adamw_torch
  • optim_args: None
  • adafactor: False
  • group_by_length: False
  • length_column_name: length
  • ddp_find_unused_parameters: None
  • ddp_bucket_cap_mb: None
  • ddp_broadcast_buffers: False
  • dataloader_pin_memory: True
  • dataloader_persistent_workers: False
  • skip_memory_metrics: True
  • use_legacy_prediction_loop: False
  • push_to_hub: False
  • resume_from_checkpoint: None
  • hub_model_id: None
  • hub_strategy: every_save
  • hub_private_repo: False
  • hub_always_push: False
  • gradient_checkpointing: False
  • gradient_checkpointing_kwargs: None
  • include_inputs_for_metrics: False
  • include_for_metrics: []
  • eval_do_concat_batches: True
  • fp16_backend: auto
  • push_to_hub_model_id: None
  • push_to_hub_organization: None
  • mp_parameters:
  • auto_find_batch_size: False
  • full_determinism: False
  • torchdynamo: None
  • ray_scope: last
  • ddp_timeout: 1800
  • torch_compile: False
  • torch_compile_backend: None
  • torch_compile_mode: None
  • dispatch_batches: None
  • split_batches: None
  • include_tokens_per_second: False
  • include_num_input_tokens_seen: False
  • neftune_noise_alpha: None
  • optim_target_modules: None
  • batch_eval_metrics: False
  • eval_on_start: False
  • use_liger_kernel: False
  • eval_use_gather_object: False
  • average_tokens_across_devices: False
  • prompts: None
  • batch_sampler: no_duplicates
  • multi_dataset_batch_sampler: proportional

</details>

Training Logs

EpochStepTraining LossValidation LossNanoClimateFEVER_cosine_ndcg@10NanoDBPedia_cosine_ndcg@10NanoFEVER_cosine_ndcg@10NanoFiQA2018_cosine_ndcg@10NanoHotpotQA_cosine_ndcg@10NanoMSMARCO_cosine_ndcg@10NanoNFCorpus_cosine_ndcg@10NanoNQ_cosine_ndcg@10NanoQuoraRetrieval_cosine_ndcg@10NanoSCIDOCS_cosine_ndcg@10NanoArguAna_cosine_ndcg@10NanoSciFact_cosine_ndcg@10NanoTouche2020_cosine_ndcg@10NanoBEIR_mean_cosine_ndcg@10
00--0.11740.30530.14050.04400.28210.22970.07730.17080.78300.11810.20170.14470.16420.2138
0.001013.6449---------------
0.0256253.6146---------------
0.0512503.6074---------------
0.0768753.5997---------------
0.10241003.57372.02050.11780.30610.14770.04610.28370.22910.08040.17130.77910.12050.20490.15340.17310.2164
0.12791253.5644---------------
0.15351503.4792---------------
0.17911753.4743---------------
0.20472003.41691.91140.13360.30840.14460.06040.29650.23500.08470.16500.78060.12700.21410.16330.18350.2228
0.23032253.3535---------------
0.25592503.3336---------------
0.28152753.3038---------------
0.30713003.25761.81140.13590.32600.17330.07520.31670.23230.08510.17530.78430.12660.22180.17520.20120.2330
0.33273253.2304---------------
0.35823503.2133---------------
0.38383753.1369---------------
0.40944003.14121.73790.13890.32980.19300.09340.32610.23100.08520.17600.78500.13490.22350.18630.21180.2396
0.43504253.0782---------------
0.46064503.0948---------------
0.48624753.0696---------------
0.51185003.06411.68500.13730.33070.19450.09370.33010.23650.09310.19500.79330.13590.22310.18850.22890.2447
0.53745253.0224---------------
0.56295502.9927---------------
0.58855752.9796---------------
0.61416002.96241.64750.13970.33210.20580.09990.34220.22760.10140.19010.79710.13930.22580.19180.23420.2482
0.63976252.9508---------------
0.66536502.958---------------
0.69096752.9428---------------
0.71657002.95891.62090.14250.33440.20610.10500.34270.22950.10010.18680.79550.13420.22980.19220.23430.2487
0.74217252.9152---------------
0.76777502.9056---------------
0.79327752.9111---------------
0.81888002.91071.60370.14150.34010.20640.10530.35230.21530.10010.19340.79760.13400.23020.19460.24610.2505
0.84448252.8675---------------
0.87008502.9175---------------
0.89568752.8592---------------
0.92129002.861.59410.14110.34150.21800.10480.35060.22100.09870.20520.79880.13490.23020.19460.24640.2528
0.94689252.8603---------------
0.97249502.8909---------------
0.99809752.8819---------------
1.0977--0.14120.34150.21220.10400.35050.21420.09870.20520.79930.13480.23750.19370.24860.2524

Environmental Impact

Carbon emissions were measured using CodeCarbon.

  • Energy Consumed: 0.025 kWh
  • Carbon Emitted: 0.010 kg of CO2
  • Hours Used: 0.15 hours

Training Hardware

  • On Cloud: No
  • GPU Model: 1 x NVIDIA GeForce RTX 3090
  • CPU Model: 13th Gen Intel(R) Core(TM) i7-13700K
  • RAM Size: 31.78 GB

Framework Versions

  • Python: 3.11.6
  • Sentence Transformers: 3.3.0.dev0
  • Transformers: 4.46.2
  • PyTorch: 2.5.0+cu121
  • Accelerate: 1.0.0
  • Datasets: 2.20.0
  • Tokenizers: 0.20.3

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