Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper
• 1908.10084 • Published
• 12
This is a sentence-transformers model finetuned from Qwen/Qwen3-Embedding-4B on the flash_rag_datasets dataset. It maps sentences & paragraphs to a 2560-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
SentenceTransformer(
(0): Transformer({'max_seq_length': 40960, 'do_lower_case': False, 'architecture': 'PeftModelForFeatureExtraction'})
(1): Pooling({'word_embedding_dimension': 2560, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': False, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': True, 'include_prompt': True})
(2): Normalize()
)
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("qwen3-embedding-4b_qwen3-8b_hotpotqa_lsr")
# Run inference
queries = [
"Huddersfield Giants R.L.F.C. are an English professional rugby league club from Huddersfield, West Yorkshire, the birthplace of rugby league, who play in the Super League competition, they play their home games at the Kirklees Stadium which is shared with Huddersfield Town F.C., is a multi-use sports stadium in Huddersfield in West Yorkshire, in which country?",
]
documents = [
'England',
'Alan Menken',
'lead singer',
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
# [1, 2560] [3, 2560]
# Get the similarity scores for the embeddings
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[0.2828, 0.1562, 0.1402]])
query and response| query | response | |
|---|---|---|
| type | string | string |
| details |
|
|
| query | response |
|---|---|
Which magazine was started first Arthur's Magazine or First for Women? |
Arthur's Magazine |
The Oberoi family is part of a hotel company that has a head office in what city? |
Delhi |
Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who? |
President Richard Nixon |
fed_rag.loss.pytorch.lsr.LSRLossper_device_train_batch_size: 1gradient_accumulation_steps: 16learning_rate: 1e-05max_steps: 100lr_scheduler_type: constantremove_unused_columns: Falsedataloader_pin_memory: Falsepush_to_hub: Trueoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: noprediction_loss_only: Trueper_device_train_batch_size: 1per_device_eval_batch_size: 8per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 16eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 1e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 3.0max_steps: 100lr_scheduler_type: constantlr_scheduler_kwargs: {}warmup_ratio: 0.0warmup_steps: 0log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Truesave_safetensors: Truesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseno_cuda: Falseuse_cpu: Falseuse_mps_device: Falseseed: 42data_seed: Nonejit_mode_eval: Falsebf16: Falsefp16: Falsefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: 0ddp_backend: Nonetpu_num_cores: Nonetpu_metrics_debug: Falsedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonepast_index: -1disable_tqdm: Falseremove_unused_columns: Falselabel_names: Noneload_best_model_at_end: Falseignore_data_skip: Falsefsdp: []fsdp_min_num_params: 0fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}fsdp_transformer_layer_cls_to_wrap: Noneaccelerator_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: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthproject: huggingfacetrackio_space_id: trackioddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Falsedataloader_persistent_workers: Falseskip_memory_metrics: Trueuse_legacy_prediction_loop: Falsepush_to_hub: Trueresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Nonehub_always_push: Falsehub_revision: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_inputs_for_metrics: Falseinclude_for_metrics: []eval_do_concat_batches: Truefp16_backend: autopush_to_hub_model_id: Nonepush_to_hub_organization: Nonemp_parameters: auto_find_batch_size: Falsefull_determinism: Falsetorchdynamo: Noneray_scope: lastddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneinclude_tokens_per_second: Falseinclude_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: Trueprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss |
|---|---|---|
| 0.0002 | 1 | 0.0009 |
| 0.0004 | 2 | 0.0009 |
| 0.0005 | 3 | 0.0006 |
| 0.0007 | 4 | 0.0005 |
| 0.0009 | 5 | 0.001 |
| 0.0011 | 6 | 0.0004 |
| 0.0012 | 7 | 0.0008 |
| 0.0014 | 8 | 0.0009 |
| 0.0016 | 9 | 0.0011 |
| 0.0018 | 10 | 0.0014 |
| 0.0019 | 11 | 0.0012 |
| 0.0021 | 12 | 0.0015 |
| 0.0023 | 13 | 0.0009 |
| 0.0025 | 14 | 0.0005 |
| 0.0027 | 15 | 0.0005 |
| 0.0028 | 16 | 0.0013 |
| 0.0030 | 17 | 0.001 |
| 0.0032 | 18 | 0.0005 |
| 0.0034 | 19 | 0.0005 |
| 0.0035 | 20 | 0.001 |
| 0.0037 | 21 | 0.0007 |
| 0.0039 | 22 | 0.0015 |
| 0.0041 | 23 | 0.0013 |
| 0.0042 | 24 | 0.0014 |
| 0.0044 | 25 | 0.0009 |
| 0.0046 | 26 | 0.0012 |
| 0.0048 | 27 | 0.0011 |
| 0.0050 | 28 | 0.0011 |
| 0.0051 | 29 | 0.0007 |
| 0.0053 | 30 | 0.0007 |
| 0.0055 | 31 | 0.0011 |
| 0.0057 | 32 | 0.0014 |
| 0.0058 | 33 | 0.0006 |
| 0.0060 | 34 | 0.0008 |
| 0.0062 | 35 | 0.0012 |
| 0.0064 | 36 | 0.0006 |
| 0.0065 | 37 | 0.0008 |
| 0.0067 | 38 | 0.0006 |
| 0.0069 | 39 | 0.0008 |
| 0.0071 | 40 | 0.0005 |
| 0.0073 | 41 | 0.0008 |
| 0.0074 | 42 | 0.0008 |
| 0.0076 | 43 | 0.0013 |
| 0.0078 | 44 | 0.0005 |
| 0.0080 | 45 | 0.0009 |
| 0.0081 | 46 | 0.0007 |
| 0.0083 | 47 | 0.001 |
| 0.0085 | 48 | 0.0009 |
| 0.0087 | 49 | 0.001 |
| 0.0088 | 50 | 0.001 |
| 0.0090 | 51 | 0.0015 |
| 0.0092 | 52 | 0.0006 |
| 0.0094 | 53 | 0.0009 |
| 0.0096 | 54 | 0.0009 |
| 0.0097 | 55 | 0.0012 |
| 0.0099 | 56 | 0.0007 |
| 0.0101 | 57 | 0.0006 |
| 0.0103 | 58 | 0.0006 |
| 0.0104 | 59 | 0.0006 |
| 0.0106 | 60 | 0.0005 |
| 0.0108 | 61 | 0.0004 |
| 0.0110 | 62 | 0.0008 |
| 0.0111 | 63 | 0.001 |
| 0.0113 | 64 | 0.0012 |
| 0.0115 | 65 | 0.0011 |
| 0.0117 | 66 | 0.001 |
| 0.0119 | 67 | 0.0011 |
| 0.0120 | 68 | 0.0011 |
| 0.0122 | 69 | 0.0012 |
| 0.0124 | 70 | 0.0008 |
| 0.0126 | 71 | 0.0006 |
| 0.0127 | 72 | 0.0006 |
| 0.0129 | 73 | 0.0006 |
| 0.0131 | 74 | 0.0015 |
| 0.0133 | 75 | 0.0011 |
| 0.0134 | 76 | 0.0009 |
| 0.0136 | 77 | 0.0012 |
| 0.0138 | 78 | 0.0008 |
| 0.0140 | 79 | 0.0011 |
| 0.0142 | 80 | 0.0008 |
| 0.0143 | 81 | 0.0009 |
| 0.0145 | 82 | 0.0009 |
| 0.0147 | 83 | 0.0007 |
| 0.0149 | 84 | 0.0007 |
| 0.0150 | 85 | 0.0008 |
| 0.0152 | 86 | 0.0012 |
| 0.0154 | 87 | 0.001 |
| 0.0156 | 88 | 0.0003 |
| 0.0157 | 89 | 0.0003 |
| 0.0159 | 90 | 0.001 |
| 0.0161 | 91 | 0.0008 |
| 0.0163 | 92 | 0.0006 |
| 0.0165 | 93 | 0.0009 |
| 0.0166 | 94 | 0.0012 |
| 0.0168 | 95 | 0.0012 |
| 0.0170 | 96 | 0.0007 |
| 0.0172 | 97 | 0.0007 |
| 0.0173 | 98 | 0.001 |
| 0.0175 | 99 | 0.0008 |
| 0.0177 | 100 | 0.0007 |
@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",
}