CoolFace
Modelpublic

wwydmanski/specter2_pubmed-v0.7

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes72downloads
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: PeftModelForFeatureExtraction 
  (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 = [
    'Content validity assessment',
    'Establishing content-validity of a disease-specific health-related quality of life instrument for patients with chronic hypersensitivity pneumonitis. ',
    'Content validity is naught. ',
]
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.040.2
cosine_accuracy@30.20.36
cosine_accuracy@50.220.42
cosine_accuracy@100.30.52
cosine_precision@10.040.2
cosine_precision@30.06670.12
cosine_precision@50.0440.084
cosine_precision@100.030.052
cosine_recall@10.030.2
cosine_recall@30.180.36
cosine_recall@50.20.42
cosine_recall@100.270.52
cosine_ndcg@100.15740.3538
cosine_mrr@100.13190.3014
cosine_map@1000.13090.3161
Nano BEIR
MetricValue
cosine_accuracy@10.12
cosine_accuracy@30.28
cosine_accuracy@50.32
cosine_accuracy@100.41
cosine_precision@10.12
cosine_precision@30.0933
cosine_precision@50.064
cosine_precision@100.041
cosine_recall@10.115
cosine_recall@30.27
cosine_recall@50.31
cosine_recall@100.395
cosine_ndcg@100.2556
cosine_mrr@100.2167
cosine_map@1000.2235

<!--

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,566 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: 3 tokens</li><li>mean: 7.4 tokens</li><li>max: 27 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 19.98 tokens</li><li>max: 78 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 12.3 tokens</li><li>max: 46 tokens</li></ul> |
  • —Samples: | anchor | positive | negative | |:------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------| | <code>neutron camera autofocus</code> | <code>The autofocusing system of the IMAT neutron camera. </code> | <code>Robust autofocusing in microscopy. </code> | | <code>Melanophore-stimulating hormone-melatonin antagonism</code> | <code>Melanophore-stimulating hormone-melatonin antagonism in relation to colour change in Xenopus laevis. </code> | <code>Melanin-concentrating hormone, melanocortin receptors and regulation of luteinizing hormone release. </code> | | <code>Healthcare Reform Criticism</code> | <code>Experts critique doctors' ideas for reforming health care. </code> | <code>Healthcare reform? </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
  • —gradient_accumulation_steps: 8
  • —learning_rate: 3e-05
  • —weight_decay: 0.01
  • —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: 8
  • —per_gpu_train_batch_size: None
  • —per_gpu_eval_batch_size: None
  • —gradient_accumulation_steps: 8
  • —eval_accumulation_steps: None
  • —torch_empty_cache_steps: None
  • —learning_rate: 3e-05
  • —weight_decay: 0.01
  • —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

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

EpochStepTraining LossNanoNQ_cosine_ndcg@10NanoMSMARCO_cosine_ndcg@10NanoBEIR_mean_cosine_ndcg@10
00-0.06330.26400.1636
0.0089122.3889---
0.0178222.1875---
0.0267321.4657---
0.0356421.7306---
0.0444521.3965---
0.0533621.5539---
0.0622721.5853---
0.0711821.6282---
0.08921.2169---
0.08891021.1228---
0.09781120.7026---
0.10671221.2562---
0.11561321.1227---
0.12441420.6465---
0.13331520.5888---
0.14221620.2334---
0.15111720.6545---
0.161820.2517---
0.16891919.6825---
0.17782019.9251---
0.18672119.6937---
0.19562219.2779---
0.20442319.2927---
0.21332419.2895---
0.22222518.98540.10850.29780.2032
0.23112618.5096---
0.242718.3789---
0.24892818.2159---
0.25782917.8306---
0.26673017.5964---
0.27563117.2527---
0.28443217.2274---
0.29333317.557---
0.30223417.4682---
0.31113516.9115---
0.323616.9938---
0.32893716.1648---
0.33783816.2908---
0.34673916.7883---
0.35564016.5278---
0.36444115.4466---
0.37334215.3954---
0.38224316.1363---
0.39114414.8857---
0.44515.5596---
0.40894615.6978---
0.41784714.6959---
0.42674815.0677---
0.43564914.4375---
0.44445015.09010.13480.32900.2319
0.45335113.813---
0.46225214.3135---
0.47115314.9517---
0.485414.0599---
0.48895513.8699---
0.49785614.6277---
0.50675713.3742---
0.51565813.7985---
0.52445913.2972---
0.53336012.9836---
0.54226113.2035---
0.55116213.399---
0.566312.8694---
0.56896412.9775---
0.57786513.5685---
0.58676612.5359---
0.59566712.7989---
0.60446812.2337---
0.61336912.9103---
0.62227012.6319---
0.63117112.3662---
0.647212.4788---
0.64897312.7665---
0.65787412.7189---
0.66677511.69180.15580.36190.2588
0.67567612.0761---
0.68447712.0588---
0.69337812.1507---
0.70227911.7982---
0.71118012.6278---
0.728112.1629---
0.72898211.9421---
0.73788312.1184---
0.74678411.9142---
0.75568512.1162---
0.76448612.2741---
0.77338711.8835---
0.78228811.8583---
0.79118911.74---
0.89012.0793---
0.80899111.6838---
0.81789211.6922---
0.82679311.9418---
0.83569412.2899---
0.84449512.0957---
0.85339612.0643---
0.86229712.3496---
0.87119812.3521---
0.889911.7082---
0.888910011.60850.15740.35380.2556
0.897810111.7018---
0.906710211.8227---
0.915610312.5774---
0.924410411.465---
0.933310511.303---
0.942210611.8521---
0.951110711.6083---
0.9610812.3972---
0.968910911.6962---
0.977811011.1335---
0.986711112.1325---
0.995611211.7444---

</details>

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. -->