Help preserve open and free AI for humanity's future

← All models

NeuML_pubmedbert-base-embeddings

NeuML · View on Hugging Face ↗

Biomedical embeddings from PubMedBERT — similarity and search over medical/scientific text.

✓ verified · rehash-vs-hf-metadata at 2026-08-24T08:10:41Z

apache-2.0836.3 MB (876,888,830 bytes)sentence-transformerspytorchsafetensorsbertfeature-extractionsentence-similaritytransformerstext-embeddings-inferenceendpoints_compatible1 language (en)

Get this model

Download NeuML_pubmedbert-base-embeddings.torrent

Recommended — the .torrent carries the webseed url-list, so your client can fall back to plain HTTPS if the swarm is thin. See/verify for the full download + verification walkthrough.

Model card

The complete upstream card, rendered from this payload's README.md — the same hash-verified bytes the torrent distributes. Images and off-site links are removed; the original card on Hugging Face carries them.


pipeline_tag: sentence-similarity tags:

  • sentence-transformers
  • feature-extraction
  • sentence-similarity
  • transformers base_model: microsoft/BiomedNLP-PubMedBERT-base-uncased-abstract-fulltext language: en license: apache-2.0

PubMedBERT Embeddings

This is a PubMedBERT-base model fined-tuned using sentence-transformers. It maps sentences & paragraphs to a 768 dimensional dense vector space and can be used for tasks like clustering or semantic search. The training dataset was generated using a random sample of PubMed title-abstract pairs along with similar title pairs.

PubMedBERT Embeddings produces higher quality embeddings than generalized models for medical literature. Further fine-tuning for a medical subdomain will result in even better performance.

Usage (txtai)

This model can be used to build embeddings databases with txtai for semantic search and/or as a knowledge source for retrieval augmented generation (RAG).

import txtai

embeddings = txtai.Embeddings(path="neuml/pubmedbert-base-embeddings", content=True)
embeddings.index(documents())

# Run a query
embeddings.search("query to run")

Usage (Sentence-Transformers)

Alternatively, the model can be loaded with sentence-transformers.

from sentence_transformers import SentenceTransformer
sentences = ["This is an example sentence", "Each sentence is converted"]

model = SentenceTransformer("neuml/pubmedbert-base-embeddings")
embeddings = model.encode(sentences)
print(embeddings)

Usage (Hugging Face Transformers)

The model can also be used directly with Transformers.

from transformers import AutoTokenizer, AutoModel
import torch

# Mean Pooling - Take attention mask into account for correct averaging
def meanpooling(output, mask):
    embeddings = output[0] # First element of model_output contains all token embeddings
    mask = mask.unsqueeze(-1).expand(embeddings.size()).float()
    return torch.sum(embeddings * mask, 1) / torch.clamp(mask.sum(1), min=1e-9)

# Sentences we want sentence embeddings for
sentences = ['This is an example sentence', 'Each sentence is converted']

# Load model from HuggingFace Hub
tokenizer = AutoTokenizer.from_pretrained("neuml/pubmedbert-base-embeddings")
model = AutoModel.from_pretrained("neuml/pubmedbert-base-embeddings")

# Tokenize sentences
inputs = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')

# Compute token embeddings
with torch.no_grad():
    output = model(**inputs)

# Perform pooling. In this case, mean pooling.
embeddings = meanpooling(output, inputs['attention_mask'])

print("Sentence embeddings:")
print(embeddings)

Evaluation Results

Performance of this model compared to the top base models on the MTEB leaderboard is shown below. A popular smaller model was also evaluated along with the most downloaded PubMed similarity model on the Hugging Face Hub.

The following datasets were used to evaluate model performance.

  • PubMed QA
    • Subset: pqa_labeled, Split: train, Pair: (question, long_answer)
  • PubMed Subset
    • Split: test, Pair: (title, text)
  • PubMed Summary
    • Subset: pubmed, Split: validation, Pair: (article, abstract)

Evaluation results are shown below. The Pearson correlation coefficient is used as the evaluation metric.

Model PubMed QA PubMed Subset PubMed Summary Average
all-MiniLM-L6-v2 90.40 95.92 94.07 93.46
bge-base-en-v1.5 91.02 95.82 94.49 93.78
gte-base 92.97 96.90 96.24 95.37
pubmedbert-base-embeddings 93.27 97.00 96.58 95.62
S-PubMedBert-MS-MARCO 90.86 93.68 93.54 92.69

Training

The model was trained with the parameters:

DataLoader:

torch.utils.data.dataloader.DataLoader of length 20191 with parameters:

{'batch_size': 24, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}

Loss:

sentence_transformers.losses.MultipleNegativesRankingLoss.MultipleNegativesRankingLoss with parameters:

{'scale': 20.0, 'similarity_fct': 'cos_sim'}

Parameters of the fit() method:

{
    "epochs": 1,
    "evaluation_steps": 500,
    "evaluator": "sentence_transformers.evaluation.EmbeddingSimilarityEvaluator.EmbeddingSimilarityEvaluator",
    "max_grad_norm": 1,
    "optimizer_class": "<class 'torch.optim.adamw.AdamW'>",
    "optimizer_params": {
        "lr": 2e-05
    },
    "scheduler": "WarmupLinear",
    "steps_per_epoch": null,
    "warmup_steps": 10000,
    "weight_decay": 0.01
}

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})
)

More Information

Read more about PubMedBERT Embeddings in this article and this paper.

Magnet link (secondary — no webseeds)

Opens the swarm directly, but carries no webseed url-list. Prefer the.torrent download above — HTTP fallback seeds ride inside it.

magnet:?xt=urn:btih:4c917ceed5614490c5603049ce036500bc7d3817&dn=NeuML_pubmedbert-base-embeddings

Open magnet in torrent client · infohash 4c917ceed5614490c5603049ce036500bc7d3817

Files & hashes

PathSizeMethodHash
1_Pooling/config.json190 B (190 B)sha1-git-blob4e09f293dfe90bba49f87cfe7996271f07be2666
README.md6.2 KB (6,327 B)sha1-git-blobc072f9810141195e949775442eed2c71a9d313a3
added_tokens.json74 B (74 B)sha1-git-blobe97f8f93bfdfff48a98fde37a3cd61007272f226
config.json667 B (667 B)sha1-git-blob57f2c3f2a401cc2458702f3ef56196182059cc77
config_sentence_transformers.json123 B (123 B)sha1-git-blob659ada2a861065243395214e70a751bc290a9789
model.safetensors417.7 MB (437,951,328 B)sha256-lfs929ddc16369bb4ff6f8e92a6ee9f5e0748f2bef33989b5617533dd50beebe4ef
modules.json229 B (229 B)sha1-git-blobf7640f94e81bb7f4f04daf1668850b38763a13d9
pytorch_model.bin417.7 MB (437,995,689 B)sha256-lfs0bdb9787bcb608f0e4dbfa2724821b7d66a66be79508bff915a9d2e3fe1f3853
sentence_bert_config.json53 B (53 B)sha1-git-blobf789d99277496b282d19020415c5ba9ca79ac875
similarity_evaluation_results.csv301 B (301 B)sha1-git-blobbbfcb4417cf2f3c75ea942a1c90a4ecdd6fa75e5
special_tokens_map.json125 B (125 B)sha1-git-bloba8b3208c2884c4efb86e49300fdd3dc877220cdf
tokenizer.json689.7 KB (706,277 B)sha1-git-blobe68fee3b6ebe7cc02f2b5f9753071bdf2c401ecf
tokenizer_config.json1.3 KB (1,297 B)sha1-git-blob9dd776f5174e80e964412f1ff41a2d0f4e795782
vocab.txt220.8 KB (226,150 B)sha1-git-blob9d595d9c20feef7012f174efaaa5eb621910588e

Provenance

Upstream repositoryNeuML/pubmedbert-base-embeddings
Revision (pinned)b79526d6ef3645e0df4530322e266f24c829f5ef
Fetched at2026-08-24T08:10:10Z
License at fetchapache-2.0
Snapshot toolhuggingface · seedbank 0.1.0

Trackers

Webseeds