Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper
• 1908.10084 • Published
• 12
This is a sentence-transformers model finetuned from BAAI/bge-small-en. 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 = [
'Can the 3051s transmitter be ordered with a G½ conduit entry size?',
'Info for 8700m\n|2 (50)|ASME 600 DERAT. So / RF|8705 020C6|223|223|221|224|223| |165|132|122|126|92| |\n|2 (50)|Din Pn40 So / RF|8705 OzocH|200|200|198|201|200|200|165|132|122|126|102| |\n|2 (50)|AS2129 TABLE D, So / RF| |8705|200| |198|201|200| |50|32|122|126|90|\n|2 (50)|AS2129 TABLE E, So / RF|8705 020CL|200| |198|201|200| |50|132|122|126|90| |\n|2 (50)|JIS B220 10K, So / RF|8705 02CP|200| |198|201|200| |155|132|122|126|96| |\n|2 (50)|JIS B220 20K, So / RF|8705 O2OCR|200| |198|201|200| |55|132|122|126|96| |\n|2 (50)|JIS B220 40K, So / RF|8705 O20CI|223| |22|224|223| |165|32|122|126|105| |\n|2 (50)|AS4087 Pni6_ Sq / RF|8705 020CU|200| |198|201|200| |150|132|122|126|90| |\n|2 (50)|AS4087 Pn2| , So / RF|8705 020CW|200| |198|201|200| |165|132|122|126|103| |\n|2 (50)|AS4087 Pn35 , So / RF|8705 O20cy|200| |198|201|200| |65|132|122|126|103| |\n|2.5 (65)|ASME 150 So / RF|8705 025C1|199| |197| |78|160|136|140|105|12| | |\n|2.5 (65)|ASME 300 So / RF|8705 025c3|199| |197| |19|60|136|140|105|15| | |',
'Info for 8700m\n# Process connections\n\n|ASME B16.5|Class 150 and Class 300: ½ inch to 24 inch (15 mm to 600 mm)|\n|---|---|\n| |Class 600: ½ inch to 24 inch (15 mm to 600 mm)(1)|\n| |Class 900: 1 inch to 12 inch (25 mm to 300 mm)(2)|\n| |Class 1500: 1½ inch to 12 inch (40 mm to 300 mm)(2)|\n| |1½ inch to 6 inch (40 mm to 150 mm)(2)|\n|ASME B16.47|Class 150: 30 inch to 36 inch (750 mm to 900 mm)|\n| |Class 300: 30 inch to 36 inch (750 mm to 900 mm)|\n|AWWA C207|Class D: 30 inch and 36 inch (750 mm and 900 mm)|\n|MSS SP44|Class 150: 30 inch to 36 inch (750 mm to 900 mm)|\n|EN 1092-1|PN10: 200 mm to 900 mm (8 inch to 36 inch)|\n| |PN16: 100 mm to 900 mm (4 inch to 36 inch)|\n| |PN25: 200 mm to 900 mm (8 inch to 36 inch)|\n| |PN40: 15 mm to 900 mm (½ inch to 36 inch)|\n|AS2129|Table D and Table E: 15 mm to 900 mm (½ inch to 36 inch)|\n|AS4087|PN16, PN21, PN35: 50 mm to 600 mm (2 inch to 24 inch)|\n|JIS B2220|10K, 20K, 40K: 15 mm to 200 mm (½ inch to 8 inch)|',
]
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]
validEmbeddingSimilarityEvaluator| Metric | Value |
|---|---|
| pearson_cosine | 0.8612 |
| spearman_cosine | 0.7357 |
sentence_0, sentence_1, and label| sentence_0 | sentence_1 | label | |
|---|---|---|---|
| type | string | string | float |
| details |
|
|
|
| sentence_0 | sentence_1 | label |
|---|---|---|
How much does the 8705 240CE model weigh in the DIN PNI6 So / RF setup? |
Info for 3051s |
Code |
What type of instrument flange is used for the Rosemount 3051S_T with F11 code? |
Info for 3051s |
Standard |
I need info on the 8700m sensor with ASME -1500 WN / RTJ, can you help? |
Info for 8700m |
(350) JIS B2200 20k, So / RF |
MultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim"
}
eval_strategy: stepsper_device_train_batch_size: 64per_device_eval_batch_size: 64num_train_epochs: 6multi_dataset_batch_sampler: round_robinoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 64per_device_eval_batch_size: 64per_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: 6max_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}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}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: Nonedispatch_batches: Nonesplit_batches: 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 | valid_spearman_cosine |
|---|---|---|---|
| 0.2496 | 163 | - | 0.7010 |
| 0.4992 | 326 | - | 0.7209 |
| 0.7489 | 489 | - | 0.7259 |
| 0.7657 | 500 | 3.9185 | - |
| 0.9985 | 652 | - | 0.7252 |
| 1.0 | 653 | - | 0.7253 |
| 1.2481 | 815 | - | 0.7285 |
| 1.4977 | 978 | - | 0.7321 |
| 1.5314 | 1000 | 3.7874 | - |
| 1.7473 | 1141 | - | 0.7300 |
| 1.9969 | 1304 | - | 0.7333 |
| 2.0 | 1306 | - | 0.7332 |
| 2.2466 | 1467 | - | 0.7304 |
| 2.2971 | 1500 | 3.7241 | - |
| 2.4962 | 1630 | - | 0.7293 |
| 2.7458 | 1793 | - | 0.7357 |
@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