Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper
•
1908.10084
•
Published
•
10
This is a sentence-transformers model finetuned from dbourget/pb-ds1-48K. It maps sentences & paragraphs to a 768-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}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 768, '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})
)
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("dbourget/pb-ds1-48K-philsim")
# Run inference
sentences = [
'This essay explores the historical and modern perspectives on the Gettier problem, highlighting the connections between this issue, skepticism, and relevance. Through methods such as historical analysis, induction, and deduction, it is found that while contextual theories and varying definitions of knowledge do not fully address skeptical challenges, they can help clarify our understanding of knowledge. Ultimately, embracing subjectivity and intuition can provide insight into what it truly means to claim knowledge.',
'Objective: In this essay, I will try to track some historical and modern stages of the discussion on the Gettier problem, and point out the interrelations of the questions that this problem raises for epistemologists, with sceptical arguments, and a so-called problem of relevance. Methods: historical analysis, induction, generalization, deduction, discourse, intuition results: Albeit the contextual theories of knowledge, the use of different definitions of knowledge, and the different ways of the uses of knowledge do not resolve all the issues that the sceptic can put forward, but they can be productive in giving clarity to a concept of knowledge for us. On the other hand, our knowledge will always have an element of intuition and subjectivity, however not equating to epistemic luck and probability. Significance novelty: the approach to the context in general, not giving up being a Subject may give us a clarity about the sense of what it means to say – “I know”.',
"Teaching competency in bioethics has been a concern since the field's inception. The first report on the teaching of contemporary bioethics was published in 1976 by The Hastings Center, which concluded that graduate programs were not necessary at the time. However, the report speculated that future developments may require new academic structures for graduate education in bioethics. The creation of a terminal degree in bioethics has its critics, with scholars debating whether bioethics is a discipline with its own methods and theoretical grounding, a multidisciplinary field, or something else entirely. Despite these debates, new bioethics training programs have emerged at all postsecondary levels in the U.S. This essay examines the number and types of programs and degrees in this growing field.",
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
sts-devEmbeddingSimilarityEvaluator| Metric | Value |
|---|---|
| pearson_cosine | 0.9378 |
| spearman_cosine | 0.8943 |
| pearson_manhattan | 0.971 |
| spearman_manhattan | 0.8969 |
| pearson_euclidean | 0.9711 |
| spearman_euclidean | 0.8966 |
| pearson_dot | 0.942 |
| spearman_dot | 0.8551 |
| pearson_max | 0.9711 |
| spearman_max | 0.8969 |
eval_strategy: stepsper_device_train_batch_size: 190per_device_eval_batch_size: 190learning_rate: 5e-06num_train_epochs: 2warmup_ratio: 0.1bf16: Truebatch_sampler: no_duplicatesoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 190per_device_eval_batch_size: 190per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonelearning_rate: 5e-06weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 2max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.1warmup_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: Truefp16: 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: Falsehub_always_push: Falsegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_inputs_for_metrics: Falseeval_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: Falsebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportional| Epoch | Step | Training Loss | loss | sts-dev_spearman_cosine |
|---|---|---|---|---|
| 0 | 0 | - | - | 0.8229 |
| 0.0178 | 10 | 0.0545 | - | - |
| 0.0355 | 20 | 0.0556 | - | - |
| 0.0533 | 30 | 0.0502 | - | - |
| 0.0710 | 40 | 0.0497 | - | - |
| 0.0888 | 50 | 0.0413 | - | - |
| 0.1066 | 60 | 0.0334 | - | - |
| 0.1243 | 70 | 0.0238 | - | - |
| 0.1421 | 80 | 0.0206 | - | - |
| 0.1599 | 90 | 0.0167 | - | - |
| 0.1776 | 100 | 0.0146 | 0.0725 | 0.8788 |
| 0.1954 | 110 | 0.0127 | - | - |
| 0.2131 | 120 | 0.0125 | - | - |
| 0.2309 | 130 | 0.0115 | - | - |
| 0.2487 | 140 | 0.0116 | - | - |
| 0.2664 | 150 | 0.0111 | - | - |
| 0.2842 | 160 | 0.0107 | - | - |
| 0.3020 | 170 | 0.0113 | - | - |
| 0.3197 | 180 | 0.0106 | - | - |
| 0.3375 | 190 | 0.0099 | - | - |
| 0.3552 | 200 | 0.0092 | 0.0207 | 0.8856 |
| 0.3730 | 210 | 0.0097 | - | - |
| 0.3908 | 220 | 0.0099 | - | - |
| 0.4085 | 230 | 0.0087 | - | - |
| 0.4263 | 240 | 0.0087 | - | - |
| 0.4440 | 250 | 0.0082 | - | - |
| 0.4618 | 260 | 0.0083 | - | - |
| 0.4796 | 270 | 0.0089 | - | - |
| 0.4973 | 280 | 0.0082 | - | - |
| 0.5151 | 290 | 0.0078 | - | - |
| 0.5329 | 300 | 0.0081 | 0.0078 | 0.8891 |
| 0.5506 | 310 | 0.0081 | - | - |
| 0.5684 | 320 | 0.0072 | - | - |
| 0.5861 | 330 | 0.0084 | - | - |
| 0.6039 | 340 | 0.0083 | - | - |
| 0.6217 | 350 | 0.0078 | - | - |
| 0.6394 | 360 | 0.0077 | - | - |
| 0.6572 | 370 | 0.008 | - | - |
| 0.6750 | 380 | 0.0073 | - | - |
| 0.6927 | 390 | 0.008 | - | - |
| 0.7105 | 400 | 0.0073 | 0.0058 | 0.8890 |
| 0.7282 | 410 | 0.0075 | - | - |
| 0.7460 | 420 | 0.0077 | - | - |
| 0.7638 | 430 | 0.0074 | - | - |
| 0.7815 | 440 | 0.0073 | - | - |
| 0.7993 | 450 | 0.007 | - | - |
| 0.8171 | 460 | 0.0043 | - | - |
| 0.8348 | 470 | 0.0052 | - | - |
| 0.8526 | 480 | 0.0046 | - | - |
| 0.8703 | 490 | 0.0073 | - | - |
| 0.8881 | 500 | 0.0056 | 0.0069 | 0.8922 |
| 0.9059 | 510 | 0.0059 | - | - |
| 0.9236 | 520 | 0.0045 | - | - |
| 0.9414 | 530 | 0.0033 | - | - |
| 0.9591 | 540 | 0.0058 | - | - |
| 0.9769 | 550 | 0.0056 | - | - |
| 0.9947 | 560 | 0.0046 | - | - |
| 1.0124 | 570 | 0.003 | - | - |
| 1.0302 | 580 | 0.0039 | - | - |
| 1.0480 | 590 | 0.0032 | - | - |
| 1.0657 | 600 | 0.0031 | 0.0029 | 0.8931 |
| 1.0835 | 610 | 0.0046 | - | - |
| 1.1012 | 620 | 0.003 | - | - |
| 1.1190 | 630 | 0.0021 | - | - |
| 1.1368 | 640 | 0.0031 | - | - |
| 1.1545 | 650 | 0.0035 | - | - |
| 1.1723 | 660 | 0.0033 | - | - |
| 1.1901 | 670 | 0.0024 | - | - |
| 1.2078 | 680 | 0.0012 | - | - |
| 1.2256 | 690 | 0.0075 | - | - |
| 1.2433 | 700 | 0.0028 | 0.0036 | 0.8945 |
| 1.2611 | 710 | 0.0033 | - | - |
| 1.2789 | 720 | 0.0023 | - | - |
| 1.2966 | 730 | 0.0034 | - | - |
| 1.3144 | 740 | 0.0018 | - | - |
| 1.3321 | 750 | 0.0016 | - | - |
| 1.3499 | 760 | 0.0025 | - | - |
| 1.3677 | 770 | 0.002 | - | - |
| 1.3854 | 780 | 0.0016 | - | - |
| 1.4032 | 790 | 0.0018 | - | - |
| 1.4210 | 800 | 0.003 | 0.0027 | 0.8944 |
| 1.4387 | 810 | 0.0018 | - | - |
| 1.4565 | 820 | 0.0008 | - | - |
| 1.4742 | 830 | 0.0014 | - | - |
| 1.4920 | 840 | 0.0025 | - | - |
| 1.5098 | 850 | 0.0026 | - | - |
| 1.5275 | 860 | 0.0012 | - | - |
| 1.5453 | 870 | 0.001 | - | - |
| 1.5631 | 880 | 0.001 | - | - |
| 1.5808 | 890 | 0.0012 | - | - |
| 1.5986 | 900 | 0.0021 | 0.0021 | 0.8952 |
| 1.6163 | 910 | 0.0016 | - | - |
| 1.6341 | 920 | 0.0008 | - | - |
| 1.6519 | 930 | 0.0008 | - | - |
| 1.6696 | 940 | 0.0009 | - | - |
| 1.6874 | 950 | 0.0004 | - | - |
| 1.7052 | 960 | 0.0003 | - | - |
| 1.7229 | 970 | 0.0007 | - | - |
| 1.7407 | 980 | 0.0007 | - | - |
| 1.7584 | 990 | 0.0011 | - | - |
| 1.7762 | 1000 | 0.0007 | 0.0029 | 0.8952 |
| 1.7940 | 1010 | 0.0008 | - | - |
| 1.8117 | 1020 | 0.001 | - | - |
| 1.8295 | 1030 | 0.0006 | - | - |
| 1.8472 | 1040 | 0.0006 | - | - |
| 1.8650 | 1050 | 0.0015 | - | - |
| 1.8828 | 1060 | 0.0009 | - | - |
| 1.9005 | 1070 | 0.0005 | - | - |
| 1.9183 | 1080 | 0.0006 | - | - |
| 1.9361 | 1090 | 0.0021 | - | - |
| 1.9538 | 1100 | 0.0009 | 0.0023 | 0.8943 |
| 1.9716 | 1110 | 0.0007 | - | - |
| 1.9893 | 1120 | 0.0003 | - | - |
@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",
}
Base model
dbourget/pb-ds1-48K