bert-base-uncased adapter finetuned on GooAQ pairs

This is a sentence-transformers model finetuned from google-bert/bert-base-uncased on the gooaq dataset. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for retrieval.

Model Details

Model Description

  • Model Type: Sentence Transformer
  • Base model: google-bert/bert-base-uncased
  • Maximum Sequence Length: 512 tokens
  • Output Dimensionality: 768 dimensions
  • Similarity Function: Cosine Similarity
  • Supported Modality: Text
  • Training Dataset:
    • gooaq
  • Language: en
  • License: apache-2.0

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'BertModel'})
  (1): Pooling({'embedding_dimension': 768, 'pooling_mode': 'mean', 'include_prompt': True})
)

Usage

Direct Usage (Sentence Transformers)

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/bert-base-uncased-gooaq-peft")
# Run inference
queries = [
    "how to reverse a video on tiktok that's not yours?",
]
documents = [
    '[\'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.',
    'Franchise Facts Poke Bar has a franchise fee of up to $30,000, with a total initial investment range of $157,800 to $438,000. The initial cost of a franchise includes several fees -- Unlock this franchise to better understand the costs such as training and territory fees.',
]
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.6499, 0.2407, 0.4209]])

Evaluation

Metrics

Information Retrieval

  • Datasets: NanoClimateFEVER, NanoDBPedia, NanoFEVER, NanoFiQA2018, NanoHotpotQA, NanoMSMARCO, NanoNFCorpus, NanoNQ, NanoQuoraRetrieval, NanoSCIDOCS, NanoArguAna, NanoSciFact and NanoTouche2020
  • Evaluated with InformationRetrievalEvaluator
Metric NanoClimateFEVER NanoDBPedia NanoFEVER NanoFiQA2018 NanoHotpotQA NanoMSMARCO NanoNFCorpus NanoNQ NanoQuoraRetrieval NanoSCIDOCS NanoArguAna NanoSciFact NanoTouche2020
cosine_accuracy@1 0.1 0.32 0.06 0.08 0.24 0.0 0.12 0.04 0.68 0.22 0.08 0.18 0.1837
cosine_accuracy@3 0.28 0.52 0.18 0.14 0.44 0.12 0.24 0.1 0.76 0.26 0.28 0.24 0.5918
cosine_accuracy@5 0.3 0.58 0.26 0.24 0.5 0.28 0.3 0.14 0.8 0.4 0.4 0.26 0.6939
cosine_accuracy@10 0.44 0.74 0.38 0.3 0.58 0.4 0.4 0.34 0.94 0.5 0.52 0.3 0.9184
cosine_precision@1 0.1 0.32 0.06 0.08 0.24 0.0 0.12 0.04 0.68 0.22 0.08 0.18 0.1837
cosine_precision@3 0.1 0.3 0.06 0.0667 0.1467 0.04 0.1 0.0333 0.3133 0.12 0.0933 0.08 0.2449
cosine_precision@5 0.076 0.288 0.052 0.068 0.116 0.056 0.088 0.028 0.2 0.128 0.08 0.052 0.2286
cosine_precision@10 0.054 0.27 0.042 0.048 0.076 0.04 0.076 0.034 0.116 0.102 0.052 0.032 0.2265
cosine_recall@1 0.0317 0.0205 0.06 0.0202 0.12 0.0 0.0026 0.04 0.5973 0.0467 0.08 0.145 0.0117
cosine_recall@3 0.1117 0.0514 0.17 0.0467 0.22 0.12 0.02 0.1 0.7253 0.0747 0.28 0.205 0.049
cosine_recall@5 0.1333 0.0824 0.24 0.1134 0.29 0.28 0.0221 0.13 0.756 0.1307 0.4 0.225 0.0758
cosine_recall@10 0.2083 0.1416 0.38 0.1644 0.38 0.4 0.0501 0.33 0.8893 0.2087 0.52 0.27 0.1459
cosine_ndcg@10 0.1515 0.2926 0.1948 0.1104 0.2913 0.1779 0.0929 0.1532 0.76 0.1842 0.2907 0.2084 0.2313
cosine_mrr@10 0.2069 0.4482 0.1391 0.1365 0.3582 0.1093 0.1967 0.1021 0.7396 0.2786 0.2185 0.213 0.4017
cosine_map@100 0.1188 0.206 0.1523 0.0827 0.2335 0.1258 0.0274 0.1245 0.7242 0.1455 0.232 0.1919 0.1588

Nano BEIR

  • Dataset: NanoBEIR_mean
  • Evaluated with NanoBEIREvaluator with these parameters:
    {
        "dataset_names": [
            "climatefever",
            "dbpedia",
            "fever",
            "fiqa2018",
            "hotpotqa",
            "msmarco",
            "nfcorpus",
            "nq",
            "quoraretrieval",
            "scidocs",
            "arguana",
            "scifact",
            "touche2020"
        ],
        "dataset_id": "sentence-transformers/NanoBEIR-en"
    }
    
Metric Value
cosine_accuracy@1 0.1772
cosine_accuracy@3 0.3194
cosine_accuracy@5 0.3965
cosine_accuracy@10 0.5199
cosine_precision@1 0.1772
cosine_precision@3 0.1306
cosine_precision@5 0.1124
cosine_precision@10 0.0899
cosine_recall@1 0.0904
cosine_recall@3 0.1672
cosine_recall@5 0.2214
cosine_recall@10 0.3145
cosine_ndcg@10 0.2415
cosine_mrr@10 0.273
cosine_map@100 0.1941

Training Details

Training Dataset

gooaq

  • Dataset: gooaq
  • Size: 250,000 training samples
  • Columns: question and answer
  • Approximate statistics based on the first 1000 samples:
    question answer
    type string string
    details
    • min: 8 tokens
    • mean: 11.86 tokens
    • max: 21 tokens
    • min: 14 tokens
    • mean: 60.48 tokens
    • max: 138 tokens
  • Samples:
    question answer
    what is the difference between broilers and layers? 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.
    what is the difference between chronological order and spatial order? 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.
    is kamagra same as viagra? 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.
  • Loss: CachedMultipleNegativesRankingLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "cos_sim",
        "mini_batch_size": 64,
        "gather_across_devices": true,
        "directions": [
            "query_to_doc"
        ],
        "partition_mode": "joint",
        "hardness_mode": null,
        "hardness_strength": 0.0
    }
    

Evaluation Dataset

gooaq

  • Dataset: gooaq
  • Size: 10,000 evaluation samples
  • Columns: question and answer
  • Approximate statistics based on the first 1000 samples:
    question answer
    type string string
    details
    • min: 8 tokens
    • mean: 11.88 tokens
    • max: 22 tokens
    • min: 14 tokens
    • mean: 61.03 tokens
    • max: 127 tokens
  • Samples:
    question answer
    how do i program my directv remote with my tv? ['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.']
    are rodrigues fruit bats nocturnal? 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.
    why does your heart rate increase during exercise bbc bitesize? 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.
  • Loss: CachedMultipleNegativesRankingLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "cos_sim",
        "mini_batch_size": 64,
        "gather_across_devices": true,
        "directions": [
            "query_to_doc"
        ],
        "partition_mode": "joint",
        "hardness_mode": null,
        "hardness_strength": 0.0
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • per_device_train_batch_size: 1024
  • per_device_eval_batch_size: 1024
  • learning_rate: 2e-05
  • num_train_epochs: 1
  • warmup_steps: 0.1
  • fp16: True
  • batch_sampler: no_duplicates

All Hyperparameters

Click to expand
  • do_predict: False
  • prediction_loss_only: True
  • per_device_train_batch_size: 1024
  • per_device_eval_batch_size: 1024
  • 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: None
  • warmup_ratio: None
  • warmup_steps: 0.1
  • log_level: passive
  • log_level_replica: warning
  • log_on_each_node: True
  • logging_nan_inf_filter: True
  • enable_jit_checkpoint: False
  • save_on_each_node: False
  • save_only_model: False
  • restore_callback_states_from_checkpoint: False
  • use_cpu: False
  • seed: 42
  • data_seed: None
  • bf16: False
  • fp16: True
  • bf16_full_eval: False
  • fp16_full_eval: False
  • tf32: None
  • local_rank: -1
  • ddp_backend: None
  • debug: []
  • dataloader_drop_last: True
  • dataloader_num_workers: 0
  • dataloader_prefetch_factor: None
  • disable_tqdm: False
  • remove_unused_columns: True
  • label_names: None
  • load_best_model_at_end: False
  • ignore_data_skip: False
  • fsdp: []
  • 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: None
  • deepspeed: None
  • label_smoothing_factor: 0.0
  • optim: adamw_torch_fused
  • optim_args: None
  • group_by_length: False
  • length_column_name: length
  • project: huggingface
  • trackio_space_id: trackio
  • 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
  • push_to_hub: False
  • resume_from_checkpoint: None
  • hub_model_id: None
  • hub_strategy: every_save
  • hub_private_repo: None
  • hub_always_push: False
  • hub_revision: None
  • gradient_checkpointing: False
  • gradient_checkpointing_kwargs: None
  • include_for_metrics: []
  • eval_do_concat_batches: True
  • auto_find_batch_size: False
  • full_determinism: False
  • ddp_timeout: 1800
  • torch_compile: False
  • torch_compile_backend: None
  • torch_compile_mode: None
  • include_num_input_tokens_seen: no
  • neftune_noise_alpha: None
  • optim_target_modules: None
  • batch_eval_metrics: False
  • eval_on_start: False
  • use_liger_kernel: False
  • liger_kernel_config: None
  • eval_use_gather_object: False
  • average_tokens_across_devices: True
  • use_cache: False
  • prompts: None
  • batch_sampler: no_duplicates
  • multi_dataset_batch_sampler: proportional
  • router_mapping: {}
  • learning_rate_mapping: {}

Training Logs

Epoch Step Training Loss Validation Loss NanoClimateFEVER_cosine_ndcg@10 NanoDBPedia_cosine_ndcg@10 NanoFEVER_cosine_ndcg@10 NanoFiQA2018_cosine_ndcg@10 NanoHotpotQA_cosine_ndcg@10 NanoMSMARCO_cosine_ndcg@10 NanoNFCorpus_cosine_ndcg@10 NanoNQ_cosine_ndcg@10 NanoQuoraRetrieval_cosine_ndcg@10 NanoSCIDOCS_cosine_ndcg@10 NanoArguAna_cosine_ndcg@10 NanoSciFact_cosine_ndcg@10 NanoTouche2020_cosine_ndcg@10 NanoBEIR_mean_cosine_ndcg@10
0.0082 1 5.2273 - - - - - - - - - - - - - - -
0.2049 25 5.0022 - - - - - - - - - - - - - - -
0.2541 31 - 4.1730 0.1359 0.2292 0.1912 0.0939 0.2781 0.1820 0.0665 0.0769 0.7343 0.1322 0.2587 0.1597 0.1314 0.2054
0.4098 50 4.1202 - - - - - - - - - - - - - - -
0.5082 62 - 3.1421 0.1315 0.2757 0.1906 0.0897 0.2795 0.1788 0.0779 0.1234 0.7298 0.1654 0.2745 0.1836 0.1940 0.2226
0.6148 75 3.3739 - - - - - - - - - - - - - - -
0.7623 93 - 2.6714 0.1515 0.2926 0.1948 0.1104 0.2913 0.1779 0.0929 0.1532 0.7600 0.1842 0.2907 0.2084 0.2313 0.2415
0.8197 100 2.9527 - - - - - - - - - - - - - - -

Training Time

  • Training: 31.9 minutes

Framework Versions

  • Python: 3.12.13
  • Sentence Transformers: 5.4.1
  • Transformers: 5.0.0
  • PyTorch: 2.10.0+cu128
  • Accelerate: 1.13.0
  • Datasets: 5.0.0
  • Tokenizers: 0.22.2

Citation

BibTeX

Sentence Transformers

@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",
}

CachedMultipleNegativesRankingLoss

@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}
}
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for kwondw/bert-base-uncased-gooaq-peft

Finetuned
(6867)
this model

Papers for kwondw/bert-base-uncased-gooaq-peft

Evaluation results