SentenceTransformer based on allenai/specter2_base
This is a sentence-transformers model finetuned from allenai/specter2_base on the json dataset. 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.
Model Details
Model Description
- Model Type: Sentence Transformer
- Base model: allenai/specter2_base
- Maximum Sequence Length: 512 tokens
- Output Dimensionality: 768 dimensions
- Similarity Function: Cosine Similarity
- Training Dataset:
- json
Model Sources
- Documentation: Sentence Transformers Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Sentence Transformers on Hugging Face
Full Model Architecture
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})
)
Usage
Direct Usage (Sentence Transformers)
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 = [
'Algesimetric study of hypoalgesic effect',
'[Experimental algesimetric study of the hypoalgesic effect of body acupuncture]. ',
'[Pain analysis is basis for correct choice of therapeutic method]. ',
]
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]
Evaluation
Metrics
Information Retrieval
- Datasets:
NanoNQandNanoMSMARCO - Evaluated with
InformationRetrievalEvaluator
| Metric | NanoNQ | NanoMSMARCO |
|---|---|---|
| cosine_accuracy@1 | 0.02 | 0.12 |
| cosine_accuracy@3 | 0.06 | 0.3 |
| cosine_accuracy@5 | 0.08 | 0.34 |
| cosine_accuracy@10 | 0.22 | 0.44 |
| cosine_precision@1 | 0.02 | 0.12 |
| cosine_precision@3 | 0.02 | 0.1 |
| cosine_precision@5 | 0.016 | 0.068 |
| cosine_precision@10 | 0.022 | 0.044 |
| cosine_recall@1 | 0.01 | 0.12 |
| cosine_recall@3 | 0.05 | 0.3 |
| cosine_recall@5 | 0.07 | 0.34 |
| cosine_recall@10 | 0.19 | 0.44 |
| cosine_ndcg@10 | 0.0836 | 0.2718 |
| cosine_mrr@10 | 0.06 | 0.2189 |
| cosine_map@100 | 0.057 | 0.2299 |
Nano BEIR
- Dataset:
NanoBEIR_mean - Evaluated with
NanoBEIREvaluator
| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.07 |
| cosine_accuracy@3 | 0.18 |
| cosine_accuracy@5 | 0.21 |
| cosine_accuracy@10 | 0.33 |
| cosine_precision@1 | 0.07 |
| cosine_precision@3 | 0.06 |
| cosine_precision@5 | 0.042 |
| cosine_precision@10 | 0.033 |
| cosine_recall@1 | 0.065 |
| cosine_recall@3 | 0.175 |
| cosine_recall@5 | 0.205 |
| cosine_recall@10 | 0.315 |
| cosine_ndcg@10 | 0.1777 |
| cosine_mrr@10 | 0.1395 |
| cosine_map@100 | 0.1435 |
Training Details
Training Dataset
json
- Dataset: json
- Size: 57,306 training samples
- Columns:
anchor,positive, andnegative - Approximate statistics based on the first 1000 samples:
anchor positive negative type string string string details - min: 4 tokens
- mean: 7.57 tokens
- max: 25 tokens
- min: 4 tokens
- mean: 20.36 tokens
- max: 78 tokens
- min: 3 tokens
- mean: 12.38 tokens
- max: 49 tokens
- Samples:
anchor positive negative Intramedullary HemangioblastomaHydrocephalus: a rare initial manifestation of sporadic intramedullary hemangioblastoma : Intramedullary hemangioblastoma presenting as hydrocephalus.Intramedullary capillary haemangioma.Density-based load estimation algorithmA contact algorithm for density-based load estimation.Density propagation based adaptive multi-density clustering algorithm.Herbicide Adjuvant EfficacyThe efficiency of adjuvants combined with flupyrsulfuron-methyl plus metsulfuron-methyl (Lexus XPE) on weed control.Are herbicides a once in a century method of weed control? - Loss:
MultipleNegativesRankingLosswith these parameters:{ "scale": 20.0, "similarity_fct": "cos_sim" }
Training Hyperparameters
Non-Default Hyperparameters
eval_strategy: stepsper_device_train_batch_size: 64per_device_eval_batch_size: 64gradient_accumulation_steps: 4learning_rate: 2e-07num_train_epochs: 1lr_scheduler_type: cosine_with_restartswarmup_ratio: 0.1bf16: Truebatch_sampler: no_duplicates
All Hyperparameters
Click to expand
overwrite_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: 4eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 2e-07weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 1max_steps: -1lr_scheduler_type: cosine_with_restartslr_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: 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: no_duplicatesmulti_dataset_batch_sampler: proportional
Training Logs
| Epoch | Step | Training Loss | NanoNQ_cosine_ndcg@10 | NanoMSMARCO_cosine_ndcg@10 | NanoBEIR_mean_cosine_ndcg@10 |
|---|---|---|---|---|---|
| 0 | 0 | - | 0.0682 | 0.2560 | 0.1621 |
| 0.0134 | 1 | 14.8664 | - | - | - |
| 0.0268 | 2 | 14.6017 | - | - | - |
| 0.0401 | 3 | 14.8474 | - | - | - |
| 0.0535 | 4 | 14.7156 | - | - | - |
| 0.0669 | 5 | 14.5967 | - | - | - |
| 0.0803 | 6 | 14.8373 | - | - | - |
| 0.0936 | 7 | 14.7819 | - | - | - |
| 0.1070 | 8 | 14.5891 | - | - | - |
| 0.1204 | 9 | 14.5531 | - | - | - |
| 0.1338 | 10 | 14.5441 | - | - | - |
| 0.1472 | 11 | 14.5516 | - | - | - |
| 0.1605 | 12 | 14.5739 | - | - | - |
| 0.1739 | 13 | 14.5974 | - | - | - |
| 0.1873 | 14 | 14.4102 | - | - | - |
| 0.2007 | 15 | 14.3615 | - | - | - |
| 0.2140 | 16 | 14.2877 | - | - | - |
| 0.2274 | 17 | 14.2774 | - | - | - |
| 0.2408 | 18 | 14.4985 | - | - | - |
| 0.2542 | 19 | 14.2307 | - | - | - |
| 0.2676 | 20 | 14.3657 | - | - | - |
| 0.2809 | 21 | 14.3261 | - | - | - |
| 0.2943 | 22 | 14.2946 | - | - | - |
| 0.3077 | 23 | 14.2311 | - | - | - |
| 0.3211 | 24 | 14.0789 | - | - | - |
| 0.3344 | 25 | 13.9392 | 0.0764 | 0.2652 | 0.1708 |
| 0.3478 | 26 | 14.0972 | - | - | - |
| 0.3612 | 27 | 14.0966 | - | - | - |
| 0.3746 | 28 | 13.9205 | - | - | - |
| 0.3880 | 29 | 13.8919 | - | - | - |
| 0.4013 | 30 | 14.1233 | - | - | - |
| 0.4147 | 31 | 14.1351 | - | - | - |
| 0.4281 | 32 | 14.1106 | - | - | - |
| 0.4415 | 33 | 14.166 | - | - | - |
| 0.4548 | 34 | 13.7817 | - | - | - |
| 0.4682 | 35 | 14.0178 | - | - | - |
| 0.4816 | 36 | 13.8457 | - | - | - |
| 0.4950 | 37 | 14.074 | - | - | - |
| 0.5084 | 38 | 13.9665 | - | - | - |
| 0.5217 | 39 | 13.9726 | - | - | - |
| 0.5351 | 40 | 13.8546 | - | - | - |
| 0.5485 | 41 | 13.9037 | - | - | - |
| 0.5619 | 42 | 13.6977 | - | - | - |
| 0.5753 | 43 | 14.0445 | - | - | - |
| 0.5886 | 44 | 13.93 | - | - | - |
| 0.6020 | 45 | 13.7835 | - | - | - |
| 0.6154 | 46 | 13.819 | - | - | - |
| 0.6288 | 47 | 13.6248 | - | - | - |
| 0.6421 | 48 | 13.846 | - | - | - |
| 0.6555 | 49 | 13.6079 | - | - | - |
| 0.6689 | 50 | 13.6848 | 0.0836 | 0.2724 | 0.1780 |
| 0.6823 | 51 | 13.668 | - | - | - |
| 0.6957 | 52 | 13.5784 | - | - | - |
| 0.7090 | 53 | 13.7519 | - | - | - |
| 0.7224 | 54 | 13.6455 | - | - | - |
| 0.7358 | 55 | 13.6757 | - | - | - |
| 0.7492 | 56 | 13.5647 | - | - | - |
| 0.7625 | 57 | 13.7072 | - | - | - |
| 0.7759 | 58 | 13.5603 | - | - | - |
| 0.7893 | 59 | 13.6437 | - | - | - |
| 0.8027 | 60 | 13.6656 | - | - | - |
| 0.8161 | 61 | 13.479 | - | - | - |
| 0.8294 | 62 | 13.5965 | - | - | - |
| 0.8428 | 63 | 13.6793 | - | - | - |
| 0.8562 | 64 | 13.6121 | - | - | - |
| 0.8696 | 65 | 13.841 | - | - | - |
| 0.8829 | 66 | 13.4793 | - | - | - |
| 0.8963 | 67 | 13.5875 | - | - | - |
| 0.9097 | 68 | 13.4063 | - | - | - |
| 0.9231 | 69 | 13.6365 | - | - | - |
| 0.9365 | 70 | 13.4696 | - | - | - |
| 0.9498 | 71 | 13.5018 | - | - | - |
| 0.9632 | 72 | 13.5956 | - | - | - |
| 0.9766 | 73 | 13.3945 | - | - | - |
| 0.9900 | 74 | 13.5684 | 0.0836 | 0.2718 | 0.1777 |
Framework Versions
- Python: 3.12.3
- Sentence Transformers: 3.3.1
- Transformers: 4.49.0
- PyTorch: 2.5.1
- Accelerate: 1.2.1
- Datasets: 2.19.0
- Tokenizers: 0.21.0
Citation
BibTeX
Sentence Transformers
@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",
}
MultipleNegativesRankingLoss
@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}
}
- Downloads last month
- 2
Model tree for wwydmanski/specter2_pubmed-v0.7-full
Base model
allenai/specter2_baseEvaluation results
- Cosine Accuracy@1 on NanoNQself-reported0.020
- Cosine Accuracy@3 on NanoNQself-reported0.060
- Cosine Accuracy@5 on NanoNQself-reported0.080
- Cosine Accuracy@10 on NanoNQself-reported0.220
- Cosine Precision@1 on NanoNQself-reported0.020
- Cosine Precision@3 on NanoNQself-reported0.020
- Cosine Precision@5 on NanoNQself-reported0.016
- Cosine Precision@10 on NanoNQself-reported0.022
- Cosine Recall@1 on NanoNQself-reported0.010
- Cosine Recall@3 on NanoNQself-reported0.050