Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper
•
1908.10084
•
Published
•
9
This is a sentence-transformers model finetuned from BAAI/bge-small-en-v1.5. It maps sentences & paragraphs to a 384-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': 512, 'do_lower_case': True}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 384, 'pooling_mode_cls_token': True, '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': False, '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("sentence_transformers_model_id")
# Run inference
sentences = [
'If I save the project after clicking "Continue," will the missing files be automatically relinked or do I need to fix the file paths manually?',
'Title: Error: no disk in drive\nAnswer: Issue This error usually occurs when an FLP (FL Studio project) looks for a sample/file in a location that doesn\'t exist (disconnected/offline drives or renamed drives) or one that doesn\'t have a disc inserted (DVD drive for example). Solution Click "Continue" and let the FLP load until the end. Save the project and the message should no longer present for that project. Note: If the error still presents itself after following the above steps try restarting your computer. Image-Line Support Team',
'Document_title: The Playlist \nFile_name: playlist.htm\nHeading_hierarchy: [The Playlist -> Universal Clip Editing Methods]\nAnchor_id: [none]\n• Snap settings ( [Image: Horseshoe magnet icon, gray background | Ref: img_glob/flicon_snap.png] ) - Snap controls how Clips move on the Playlist grid and many of the other editing functions below. Set this to \' line \' if you want the Clips to snap to bar boundaries or to \' none \' if you want to\nfreely position & slice Clips. • Inserting Clips - To insert a Clip, select the Clip you want to place from the Clip Source menu (indicated above) OR Right-Click the Clip focus selectors (indicated above) to choose Clips of the type selected. Next, in Draw ( [Image: Gray pencil drawing/editing tool\nicon | Ref: img_glob/flicon_pencilup.png] ) or Paint ( [Image: Paintbrush dripping with liquid icon | Ref: img_glob/flicon_paint.png] ) mode, Left-click on an empty area of a Clips track where you want to place the Clip. Paint mode allows you to paint multiple instances of the Clip at once (hold the\nMouse button & drag). • Insert time into the Playlist (shift Clips to the right) - Hold ( Ctrl ), click and drag on the time-line at the top of the Playlist starting from the point you want to insert space into the timeline AND for the duration of the insertion you want. With ( Ctrl ) still held press the ( Ins\nert ) key on your keyboard. Insert time into the Playlist (slice and move Clips to the right) - Make a time selection as above, then hold ( Ctrl+Alt ) and press the ( Insert ) key on your keyboard. The slice point will be at the start of the selection. • Delete a time selection - Hold ( Ctrl ), click and\ndrag on the time-line at the\n top of the Playlist to select the region to be deleted. Press ( Ctrl+Del ) to delete all patterns in the current selection and move Clips to the right of the selection into the gap. • Select Clips - To make a selection of more than one Clip. Use the [Image: Dashed square crop selection icon | Ref:\nimg_glob/flicon_select.png] Select tool and click and drag a rectangle around the Clips to be selected. To add Clips to this selection hold the ( Shift ) key and make further selections. OR if you are in Draw or Paint mode, hold ( Ctrl ) key and you will drop into Select mode while the ( Ctrl ) key is\nheld. Holding the ( Ctrl+Shift ) keys will allow you to add and remove Clips to / from an existing selection. OR use the Magic lasso feature. Move your Mouse pointer in a loop that encloses the Clips you want to select (no clicking required, it\'s \'magic\' remember). Make sure you have no Clips\nselected before you perform the lasso action (Right-Click the empty Playlist to deselect all Clips and make another selection). • Zoom to area - ( Ctrl+Right-Click ) and drag over a selection of the Playlist. Un-Zoom area - ( Ctrl+Right-Click ) anywhere\n on the Playlist (don\'t drag). • Zoom to a Clip - ( Ctrl+Shift+Right-Click ) on a Clip will maximize the zoom\n of the Playlist to the selected Clip. To Un-Zoom Clip - ( Ctrl+Right-Click ) anywhere\n on the Playlist (don\'t drag in this mode since that is how to zoom to selection). • Delete/Erase a Clip - Right-Click the target Clip or use the left Mouse button if you are in erase ( [Image: Circular gray "no entry" symbol icon | Ref: img_glob/flicon_delete.png] ) mode. • Copy/Paste Clips - Make\na selection, release the Mouse and any keys held, then hold the ( Shift ) key, then click on the selection and drag. A copy of the selection will follow the Mouse cursor. Release the selection when the Clips are in the alternative location. NOTE: In \' Slice tool \' mode this will initiate a slice, not\ncopy. OR Make a selection, press ( Ctrl+C ) to copy, then scroll the Playlist so that the starting bar for the paste location is at the left edge of the Playlist and press ( Ctrl+V ). • Duplicate selection - Make a selection and press ( Ctrl+B ). The selection, or all Clips if no selection is made, will be\nduplicated to the right of the original selection.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
InformationRetrievalEvaluator| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.7821 |
| cosine_accuracy@3 | 0.9177 |
| cosine_accuracy@5 | 0.9447 |
| cosine_accuracy@10 | 0.9696 |
| cosine_precision@1 | 0.7821 |
| cosine_precision@3 | 0.3059 |
| cosine_precision@5 | 0.1889 |
| cosine_precision@10 | 0.097 |
| cosine_recall@1 | 0.7821 |
| cosine_recall@3 | 0.9177 |
| cosine_recall@5 | 0.9447 |
| cosine_recall@10 | 0.9696 |
| cosine_ndcg@10 | 0.8817 |
| cosine_mrr@10 | 0.8529 |
| cosine_map@100 | 0.8542 |
sentence_0 and sentence_1| sentence_0 | sentence_1 | |
|---|---|---|
| type | string | string |
| details |
|
|
| sentence_0 | sentence_1 |
|---|---|
How long does it usually take for the payment status to update from 'unpaid' to 'processed' on the site? |
Title: My payment at my online bank page shows as processed, but your site still says 'unpaid'. |
If refreshing the order status page doesn't update the payment status, what should I do next? |
Title: My payment at my online bank page shows as processed, but your site still says 'unpaid'. |
Why do delay echoes not work properly with BooBass? |
Document_title: BooBass |
MultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim"
}
eval_strategy: stepsper_device_train_batch_size: 10per_device_eval_batch_size: 10num_train_epochs: 2multi_dataset_batch_sampler: round_robinoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 10per_device_eval_batch_size: 10per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 5e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1num_train_epochs: 2max_steps: -1lr_scheduler_type: linearlr_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: Falseuse_ipex: 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: Truelabel_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}tp_size: 0fsdp_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}deepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torchoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Trueuse_legacy_prediction_loop: Falsepush_to_hub: Falseresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Nonehub_always_push: Falsegradient_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: Falseneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseeval_use_gather_object: Falseaverage_tokens_across_devices: Falseprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: round_robin| Epoch | Step | Training Loss | cosine_ndcg@10 |
|---|---|---|---|
| 0.0847 | 50 | - | 0.8231 |
| 0.1695 | 100 | - | 0.8503 |
| 0.2542 | 150 | - | 0.8584 |
| 0.3390 | 200 | - | 0.8736 |
| 0.4237 | 250 | - | 0.8737 |
| 0.5085 | 300 | - | 0.8731 |
| 0.5932 | 350 | - | 0.8749 |
| 0.6780 | 400 | - | 0.8711 |
| 0.7627 | 450 | - | 0.8707 |
| 0.8475 | 500 | 0.1329 | 0.8779 |
| 0.9322 | 550 | - | 0.8817 |
@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{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}
}
Base model
BAAI/bge-small-en-v1.5