Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 15
How to use austinpatrickm/multilingual-e5-small-finetuned with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("austinpatrickm/multilingual-e5-small-finetuned")
sentences = [
"Can I use Fruity Bass Boost on sounds other than bass and kick drums?",
"Document_title: Locating FL Studio Installation Files\nFile_name: app_flstudioinstallationfiles.htm\nHeading_hierarchy: [Locating FL Studio Installation Files -> Multiple Installations]\nAnchor_id: [none]\nTo avoid installing a Beta, or any new version, over an existing installation, you can rename the existing FL Studio application prior to installation of the beta or new release. • Close FL Studio. • Open Finder and select the ' Applications ' folder in the Sidebar. • Locate and right-click the ' FL\nStudio N ' application. Where N is the version number. • Select ' Rename '. • Rename the application to something other than ' FL Studio N ', such as 'FL Studio N Stable'. • Install the beta, or new release, as normal. It will become the default FL Studio installation. • To maintain quick access to\nthe various installations, make Alias shortcuts . • Open Finder and select the ' Applications ' folder in the Sidebar. • Right-click the application you would like to create a shortcut for and select ' Make alias '. • Relocate the alias to your Desktop. Alternatively, you can drag the application from\nthe Applications directory to your Dock to create a shortcut.",
"Document_title: Fruity Bass Boost\nFile_name: plugins/Fruity Bass Boost.htm\nHeading_hierarchy: [Fruity Bass Boost]\nAnchor_id: [none]\nFruity Bass Boost is a bass enhancing effect (specialized EQ). You may need to adjust the track volume to avoid clipping since this FX works by boosting frequencies. Try it on bass\n and kick drum sounds. Yes it's just a fancy 'bass' knob :) [Image: Knob controls with frequency display | Ref: img_plug/Fruity_bass_boost.png]",
"Document_title: \n Image-Line Remote \nFile_name: il_remote.htm\nHeading_hierarchy: [Image-Line Remote -> Layouts]\nAnchor_id: [none]\nA Layout (*.ilr format) is a collection of tabs in an IL\n Remote project. The Layout menu is located to the top-left of the\n display while in Edit mode. Presets (*.ilrp format) are a\n collection of controls saved in a [Container](https://www.image-line.com/fl-studio-learning/fl-studio-online-manual/html/il_remote.htm#IL_Remote_Container) that can\n be loaded on a tab. This is the fastest way to build new Layouts. [Image: Document icon with layout options menu | Ref: img_shot/ILRemote_menu_layoutsettings.jpg]"
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from intfloat/multilingual-e5-small. 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': False, 'architecture': 'BertModel'})
(1): Pooling({'word_embedding_dimension': 384, '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})
(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 I automate the Gain image over time to create dynamic volume changes?',
'Document_title: Harmor \nFile_name: plugins/Harmor.htm\nHeading_hierarchy: [Harmor -> About images and planes]\nAnchor_id: [none]\nThere are independent images that control the Pitch/Frequency and Gain of partials. Together these can create any sound, just as sampler can. In the image window the vertical dimension\n is frequency (each line of pixels is a single partial), while the horizontal dimension is time.',
'Document_title: PoiZone V2 \nFile_name: plugins/PoiZone.htm\nHeading_hierarchy: [PoiZone V2 -> Voicing]\nAnchor_id: [none]\n• 2 main oscillators for subtractive synthesis: SAW and PULSE shapes, pulse width adjustable. • 1 NOISE Oscillator. • Variable polyphony (1 to 32 voices).',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.4301, 0.1394],
# [0.4301, 1.0000, 0.1051],
# [0.1394, 0.1051, 1.0000]])
InformationRetrievalEvaluator| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.6911 |
| cosine_accuracy@3 | 0.878 |
| cosine_accuracy@5 | 0.9252 |
| cosine_accuracy@10 | 0.9643 |
| cosine_precision@1 | 0.6911 |
| cosine_precision@3 | 0.2927 |
| cosine_precision@5 | 0.185 |
| cosine_precision@10 | 0.0964 |
| cosine_recall@1 | 0.6911 |
| cosine_recall@3 | 0.878 |
| cosine_recall@5 | 0.9252 |
| cosine_recall@10 | 0.9643 |
| cosine_ndcg@10 | 0.834 |
| cosine_mrr@10 | 0.7914 |
| cosine_map@100 | 0.7931 |
sentence_0 and sentence_1| sentence_0 | sentence_1 | |
|---|---|---|
| type | string | string |
| details |
|
|
| sentence_0 | sentence_1 |
|---|---|
How do I load a *.SPEECH preset into the Sampler plugin? |
Document_title: Speech Preset (.SPEECH) |
Can I use Speech presets with the Fruity Granulizer to create vocal effects? |
Document_title: Speech Preset (.SPEECH) |
What kind of vocals can the Speech synthesizer create from text? |
Document_title: Speech Preset (.SPEECH) |
MultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim",
"gather_across_devices": false
}
eval_strategy: stepsper_device_train_batch_size: 10per_device_eval_batch_size: 10num_train_epochs: 2multi_dataset_batch_sampler: round_robindo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 10per_device_eval_batch_size: 10gradient_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: Nonewarmup_ratio: Nonewarmup_steps: 0log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Trueenable_jit_checkpoint: Falsesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseuse_cpu: Falseseed: 42data_seed: Nonebf16: Falsefp16: Falsebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: -1ddp_backend: Nonedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonedisable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Falseignore_data_skip: Falsefsdp: []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: Nonedeepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torch_fusedoptim_args: Nonegroup_by_length: Falselength_column_name: lengthproject: huggingfacetrackio_space_id: trackioddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Truepush_to_hub: Falseresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Nonehub_always_push: Falsehub_revision: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_for_metrics: []eval_do_concat_batches: Trueauto_find_batch_size: Falsefull_determinism: Falseddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneinclude_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: Trueuse_cache: Falseprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: round_robinrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | cosine_ndcg@10 |
|---|---|---|---|
| 0.0168 | 50 | - | 0.7103 |
| 0.0335 | 100 | - | 0.7267 |
| 0.0503 | 150 | - | 0.7500 |
| 0.0670 | 200 | - | 0.7715 |
| 0.0838 | 250 | - | 0.7892 |
| 0.1005 | 300 | - | 0.7921 |
| 0.1173 | 350 | - | 0.7940 |
| 0.1340 | 400 | - | 0.7958 |
| 0.1508 | 450 | - | 0.7889 |
| 0.1676 | 500 | 0.3978 | 0.7999 |
| 0.1843 | 550 | - | 0.7861 |
| 0.2011 | 600 | - | 0.7848 |
| 0.2178 | 650 | - | 0.7780 |
| 0.2346 | 700 | - | 0.7885 |
| 0.2513 | 750 | - | 0.7926 |
| 0.2681 | 800 | - | 0.7914 |
| 0.2849 | 850 | - | 0.8043 |
| 0.3016 | 900 | - | 0.7939 |
| 0.3184 | 950 | - | 0.8057 |
| 0.3351 | 1000 | 0.1115 | 0.8093 |
| 0.3519 | 1050 | - | 0.8056 |
| 0.3686 | 1100 | - | 0.7941 |
| 0.3854 | 1150 | - | 0.8042 |
| 0.4021 | 1200 | - | 0.8007 |
| 0.4189 | 1250 | - | 0.8071 |
| 0.4357 | 1300 | - | 0.8121 |
| 0.4524 | 1350 | - | 0.8037 |
| 0.4692 | 1400 | - | 0.7958 |
| 0.4859 | 1450 | - | 0.8052 |
| 0.5027 | 1500 | 0.0989 | 0.8028 |
| 0.5194 | 1550 | - | 0.7989 |
| 0.5362 | 1600 | - | 0.8078 |
| 0.5529 | 1650 | - | 0.8117 |
| 0.5697 | 1700 | - | 0.8108 |
| 0.5865 | 1750 | - | 0.8101 |
| 0.6032 | 1800 | - | 0.8102 |
| 0.6200 | 1850 | - | 0.8080 |
| 0.6367 | 1900 | - | 0.8150 |
| 0.6535 | 1950 | - | 0.8156 |
| 0.6702 | 2000 | 0.0901 | 0.8138 |
| 0.6870 | 2050 | - | 0.8127 |
| 0.7038 | 2100 | - | 0.8123 |
| 0.7205 | 2150 | - | 0.8128 |
| 0.7373 | 2200 | - | 0.8141 |
| 0.7540 | 2250 | - | 0.8108 |
| 0.7708 | 2300 | - | 0.8108 |
| 0.7875 | 2350 | - | 0.8164 |
| 0.8043 | 2400 | - | 0.8159 |
| 0.8210 | 2450 | - | 0.8175 |
| 0.8378 | 2500 | 0.0908 | 0.8206 |
| 0.8546 | 2550 | - | 0.8223 |
| 0.8713 | 2600 | - | 0.8238 |
| 0.8881 | 2650 | - | 0.8264 |
| 0.9048 | 2700 | - | 0.8212 |
| 0.9216 | 2750 | - | 0.8204 |
| 0.9383 | 2800 | - | 0.8236 |
| 0.9551 | 2850 | - | 0.8170 |
| 0.9718 | 2900 | - | 0.8217 |
| 0.9886 | 2950 | - | 0.8246 |
| 1.0 | 2984 | - | 0.8222 |
| 1.0054 | 3000 | 0.0868 | 0.8207 |
| 1.0221 | 3050 | - | 0.8173 |
| 1.0389 | 3100 | - | 0.8165 |
| 1.0556 | 3150 | - | 0.8211 |
| 1.0724 | 3200 | - | 0.8236 |
| 1.0891 | 3250 | - | 0.8207 |
| 1.1059 | 3300 | - | 0.8173 |
| 1.1227 | 3350 | - | 0.8197 |
| 1.1394 | 3400 | - | 0.8164 |
| 1.1562 | 3450 | - | 0.8212 |
| 1.1729 | 3500 | 0.0611 | 0.8225 |
| 1.1897 | 3550 | - | 0.8250 |
| 1.2064 | 3600 | - | 0.8256 |
| 1.2232 | 3650 | - | 0.8253 |
| 1.2399 | 3700 | - | 0.8254 |
| 1.2567 | 3750 | - | 0.8254 |
| 1.2735 | 3800 | - | 0.8284 |
| 1.2902 | 3850 | - | 0.8324 |
| 1.3070 | 3900 | - | 0.8311 |
| 1.3237 | 3950 | - | 0.8272 |
| 1.3405 | 4000 | 0.0581 | 0.8245 |
| 1.3572 | 4050 | - | 0.8227 |
| 1.3740 | 4100 | - | 0.8235 |
| 1.3908 | 4150 | - | 0.8211 |
| 1.4075 | 4200 | - | 0.8199 |
| 1.4243 | 4250 | - | 0.8230 |
| 1.4410 | 4300 | - | 0.8248 |
| 1.4578 | 4350 | - | 0.8266 |
| 1.4745 | 4400 | - | 0.8268 |
| 1.4913 | 4450 | - | 0.8273 |
| 1.5080 | 4500 | 0.0499 | 0.8305 |
| 1.5248 | 4550 | - | 0.8293 |
| 1.5416 | 4600 | - | 0.8291 |
| 1.5583 | 4650 | - | 0.8287 |
| 1.5751 | 4700 | - | 0.8285 |
| 1.5918 | 4750 | - | 0.8286 |
| 1.6086 | 4800 | - | 0.8289 |
| 1.6253 | 4850 | - | 0.8277 |
| 1.6421 | 4900 | - | 0.8283 |
| 1.6588 | 4950 | - | 0.8287 |
| 1.6756 | 5000 | 0.0595 | 0.8285 |
| 1.6924 | 5050 | - | 0.8289 |
| 1.7091 | 5100 | - | 0.8274 |
| 1.7259 | 5150 | - | 0.8277 |
| 1.7426 | 5200 | - | 0.8296 |
| 1.7594 | 5250 | - | 0.8326 |
| 1.7761 | 5300 | - | 0.8323 |
| 1.7929 | 5350 | - | 0.8308 |
| 1.8097 | 5400 | - | 0.8312 |
| 1.8264 | 5450 | - | 0.8314 |
| 1.8432 | 5500 | 0.0544 | 0.8328 |
| 1.8599 | 5550 | - | 0.8331 |
| 1.8767 | 5600 | - | 0.8327 |
| 1.8934 | 5650 | - | 0.8335 |
| 1.9102 | 5700 | - | 0.8340 |
@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
intfloat/multilingual-e5-small
from sentence_transformers import SentenceTransformer model = SentenceTransformer("austinpatrickm/multilingual-e5-small-finetuned") sentences = [ "Can I use Fruity Bass Boost on sounds other than bass and kick drums?", "Document_title: Locating FL Studio Installation Files\nFile_name: app_flstudioinstallationfiles.htm\nHeading_hierarchy: [Locating FL Studio Installation Files -> Multiple Installations]\nAnchor_id: [none]\nTo avoid installing a Beta, or any new version, over an existing installation, you can rename the existing FL Studio application prior to installation of the beta or new release. • Close FL Studio. • Open Finder and select the ' Applications ' folder in the Sidebar. • Locate and right-click the ' FL\nStudio N ' application. Where N is the version number. • Select ' Rename '. • Rename the application to something other than ' FL Studio N ', such as 'FL Studio N Stable'. • Install the beta, or new release, as normal. It will become the default FL Studio installation. • To maintain quick access to\nthe various installations, make Alias shortcuts . • Open Finder and select the ' Applications ' folder in the Sidebar. • Right-click the application you would like to create a shortcut for and select ' Make alias '. • Relocate the alias to your Desktop. Alternatively, you can drag the application from\nthe Applications directory to your Dock to create a shortcut.", "Document_title: Fruity Bass Boost\nFile_name: plugins/Fruity Bass Boost.htm\nHeading_hierarchy: [Fruity Bass Boost]\nAnchor_id: [none]\nFruity Bass Boost is a bass enhancing effect (specialized EQ). You may need to adjust the track volume to avoid clipping since this FX works by boosting frequencies. Try it on bass\n and kick drum sounds. Yes it's just a fancy 'bass' knob :) [Image: Knob controls with frequency display | Ref: img_plug/Fruity_bass_boost.png]", "Document_title: \n Image-Line Remote \nFile_name: il_remote.htm\nHeading_hierarchy: [Image-Line Remote -> Layouts]\nAnchor_id: [none]\nA Layout (*.ilr format) is a collection of tabs in an IL\n Remote project. The Layout menu is located to the top-left of the\n display while in Edit mode. Presets (*.ilrp format) are a\n collection of controls saved in a [Container](https://www.image-line.com/fl-studio-learning/fl-studio-online-manual/html/il_remote.htm#IL_Remote_Container) that can\n be loaded on a tab. This is the fastest way to build new Layouts. [Image: Document icon with layout options menu | Ref: img_shot/ILRemote_menu_layoutsettings.jpg]" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4]