CoolFace
Modelpublic

wwydmanski/specter2_pubmed-v0.7-full

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes89downloads
Model Card

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 <!-- at revision 3447645e1def9117997203454fa4495937bfbd83 -->
  • —Maximum Sequence Length: 512 tokens
  • —Output Dimensionality: 768 dimensions
  • —Similarity Function: Cosine Similarity
  • —Training Dataset:
  • —json <!-- - Language: Unknown --> <!-- - License: Unknown -->

Model Sources

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:

bash
pip install -U sentence-transformers

Then you can load this model and run inference.

python
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]

<!--

Direct Usage (Transformers)

<details><summary>Click to see the direct usage in Transformers</summary>

</details> -->

<!--

Downstream Usage (Sentence Transformers)

You can finetune this model on your own dataset.

<details><summary>Click to expand</summary>

</details> -->

<!--

Out-of-Scope Use

List how the model may foreseeably be misused and address what users ought not to do with the model. -->

Evaluation

Metrics

Information Retrieval
MetricNanoNQNanoMSMARCO
cosine_accuracy@10.020.12
cosine_accuracy@30.060.3
cosine_accuracy@50.080.34
cosine_accuracy@100.220.44
cosine_precision@10.020.12
cosine_precision@30.020.1
cosine_precision@50.0160.068
cosine_precision@100.0220.044
cosine_recall@10.010.12
cosine_recall@30.050.3
cosine_recall@50.070.34
cosine_recall@100.190.44
cosine_ndcg@100.08360.2718
cosine_mrr@100.060.2189
cosine_map@1000.0570.2299
Nano BEIR
MetricValue
cosine_accuracy@10.07
cosine_accuracy@30.18
cosine_accuracy@50.21
cosine_accuracy@100.33
cosine_precision@10.07
cosine_precision@30.06
cosine_precision@50.042
cosine_precision@100.033
cosine_recall@10.065
cosine_recall@30.175
cosine_recall@50.205
cosine_recall@100.315
cosine_ndcg@100.1777
cosine_mrr@100.1395
cosine_map@1000.1435

<!--

Bias, Risks and Limitations

What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model. -->

<!--

Recommendations

What are recommendations with respect to the foreseeable issues? For example, filtering explicit content. -->

Training Details

Training Dataset

json
  • —Dataset: json
  • —Size: 57,306 training samples
  • —Columns: <code>anchor</code>, <code>positive</code>, and <code>negative</code>
  • —Approximate statistics based on the first 1000 samples: | | anchor | positive | negative | |:--------|:---------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------| | type | string | string | string | | details | <ul><li>min: 4 tokens</li><li>mean: 7.57 tokens</li><li>max: 25 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 20.36 tokens</li><li>max: 78 tokens</li></ul> | <ul><li>min: 3 tokens</li><li>mean: 12.38 tokens</li><li>max: 49 tokens</li></ul> |
  • —Samples: | anchor | positive | negative | |:-----------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------| | <code>Intramedullary Hemangioblastoma</code> | <code>Hydrocephalus: a rare initial manifestation of sporadic intramedullary hemangioblastoma : Intramedullary hemangioblastoma presenting as hydrocephalus. </code> | <code>Intramedullary capillary haemangioma. </code> | | <code>Density-based load estimation algorithm</code> | <code>A contact algorithm for density-based load estimation. </code> | <code>Density propagation based adaptive multi-density clustering algorithm. </code> | | <code>Herbicide Adjuvant Efficacy</code> | <code>The efficiency of adjuvants combined with flupyrsulfuron-methyl plus metsulfuron-methyl (Lexus XPE) on weed control. </code> | <code>Are herbicides a once in a century method of weed control? </code> |
  • —Loss: <code>MultipleNegativesRankingLoss</code> with these parameters:
json
  {
      "scale": 20.0,
      "similarity_fct": "cos_sim"
  }

Training Hyperparameters

Non-Default Hyperparameters
  • —eval_strategy: steps
  • —per_device_train_batch_size: 64
  • —per_device_eval_batch_size: 64
  • —gradient_accumulation_steps: 4
  • —learning_rate: 2e-07
  • —num_train_epochs: 1
  • —lr_scheduler_type: cosinewithrestarts
  • —warmup_ratio: 0.1
  • —bf16: True
  • —batch_sampler: no_duplicates
All Hyperparameters

<details><summary>Click to expand</summary>

  • —overwrite_output_dir: False
  • —do_predict: False
  • —eval_strategy: steps
  • —prediction_loss_only: True
  • —per_device_train_batch_size: 64
  • —per_device_eval_batch_size: 64
  • —per_gpu_train_batch_size: None
  • —per_gpu_eval_batch_size: None
  • —gradient_accumulation_steps: 4
  • —eval_accumulation_steps: None
  • —torch_empty_cache_steps: None
  • —learning_rate: 2e-07
  • —weight_decay: 0.0
  • —adam_beta1: 0.9
  • —adam_beta2: 0.999
  • —adam_epsilon: 1e-08
  • —max_grad_norm: 1.0
  • —num_train_epochs: 1
  • —max_steps: -1
  • —lr_scheduler_type: cosinewithrestarts
  • —lr_scheduler_kwargs: {}
  • —warmup_ratio: 0.1
  • —warmup_steps: 0
  • —log_level: passive
  • —log_level_replica: warning
  • —log_on_each_node: True
  • —logging_nan_inf_filter: True
  • —save_safetensors: True
  • —save_on_each_node: False
  • —save_only_model: False
  • —restore_callback_states_from_checkpoint: False
  • —no_cuda: False
  • —use_cpu: False
  • —use_mps_device: False
  • —seed: 42
  • —data_seed: None
  • —jit_mode_eval: False
  • —use_ipex: False
  • —bf16: True
  • —fp16: False
  • —fp16_opt_level: O1
  • —half_precision_backend: auto
  • —bf16_full_eval: False
  • —fp16_full_eval: False
  • —tf32: None
  • —local_rank: 0
  • —ddp_backend: None
  • —tpu_num_cores: None
  • —tpu_metrics_debug: False
  • —debug: []
  • —dataloader_drop_last: False
  • —dataloader_num_workers: 0
  • —dataloader_prefetch_factor: None
  • —past_index: -1
  • —disable_tqdm: False
  • —remove_unused_columns: True
  • —label_names: None
  • —load_best_model_at_end: False
  • —ignore_data_skip: False
  • —fsdp: []
  • —fsdp_min_num_params: 0
  • —fsdp_config: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • —fsdp_transformer_layer_cls_to_wrap: None
  • —accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}
  • —deepspeed: None
  • —label_smoothing_factor: 0.0
  • —optim: adamw_torch
  • —optim_args: None
  • —adafactor: False
  • —group_by_length: False
  • —length_column_name: length
  • —ddp_find_unused_parameters: None
  • —ddp_bucket_cap_mb: None
  • —ddp_broadcast_buffers: False
  • —dataloader_pin_memory: True
  • —dataloader_persistent_workers: False
  • —skip_memory_metrics: True
  • —use_legacy_prediction_loop: False
  • —push_to_hub: False
  • —resume_from_checkpoint: None
  • —hub_model_id: None
  • —hub_strategy: every_save
  • —hub_private_repo: None
  • —hub_always_push: False
  • —gradient_checkpointing: False
  • —gradient_checkpointing_kwargs: None
  • —include_inputs_for_metrics: False
  • —include_for_metrics: []
  • —eval_do_concat_batches: True
  • —fp16_backend: auto
  • —push_to_hub_model_id: None
  • —push_to_hub_organization: None
  • —mp_parameters:
  • —auto_find_batch_size: False
  • —full_determinism: False
  • —torchdynamo: None
  • —ray_scope: last
  • —ddp_timeout: 1800
  • —torch_compile: False
  • —torch_compile_backend: None
  • —torch_compile_mode: None
  • —dispatch_batches: None
  • —split_batches: None
  • —include_tokens_per_second: False
  • —include_num_input_tokens_seen: False
  • —neftune_noise_alpha: None
  • —optim_target_modules: None
  • —batch_eval_metrics: False
  • —eval_on_start: False
  • —use_liger_kernel: False
  • —eval_use_gather_object: False
  • —average_tokens_across_devices: False
  • —prompts: None
  • —batch_sampler: no_duplicates
  • —multi_dataset_batch_sampler: proportional

</details>

Training Logs

EpochStepTraining LossNanoNQ_cosine_ndcg@10NanoMSMARCO_cosine_ndcg@10NanoBEIR_mean_cosine_ndcg@10
00-0.06820.25600.1621
0.0134114.8664---
0.0268214.6017---
0.0401314.8474---
0.0535414.7156---
0.0669514.5967---
0.0803614.8373---
0.0936714.7819---
0.1070814.5891---
0.1204914.5531---
0.13381014.5441---
0.14721114.5516---
0.16051214.5739---
0.17391314.5974---
0.18731414.4102---
0.20071514.3615---
0.21401614.2877---
0.22741714.2774---
0.24081814.4985---
0.25421914.2307---
0.26762014.3657---
0.28092114.3261---
0.29432214.2946---
0.30772314.2311---
0.32112414.0789---
0.33442513.93920.07640.26520.1708
0.34782614.0972---
0.36122714.0966---
0.37462813.9205---
0.38802913.8919---
0.40133014.1233---
0.41473114.1351---
0.42813214.1106---
0.44153314.166---
0.45483413.7817---
0.46823514.0178---
0.48163613.8457---
0.49503714.074---
0.50843813.9665---
0.52173913.9726---
0.53514013.8546---
0.54854113.9037---
0.56194213.6977---
0.57534314.0445---
0.58864413.93---
0.60204513.7835---
0.61544613.819---
0.62884713.6248---
0.64214813.846---
0.65554913.6079---
0.66895013.68480.08360.27240.1780
0.68235113.668---
0.69575213.5784---
0.70905313.7519---
0.72245413.6455---
0.73585513.6757---
0.74925613.5647---
0.76255713.7072---
0.77595813.5603---
0.78935913.6437---
0.80276013.6656---
0.81616113.479---
0.82946213.5965---
0.84286313.6793---
0.85626413.6121---
0.86966513.841---
0.88296613.4793---
0.89636713.5875---
0.90976813.4063---
0.92316913.6365---
0.93657013.4696---
0.94987113.5018---
0.96327213.5956---
0.97667313.3945---
0.99007413.56840.08360.27180.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
bibtex
@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
bibtex
@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}
}

<!--

Glossary

Clearly define terms in order to be accessible across audiences. -->

<!--

Model Card Authors

Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction. -->

<!--

Model Card Contact

Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors. -->