Model reference · open weights

MedCPT-Query-Encoder

Embeddings ncbi Embeddings 1 build Its own licence terms 130k dl/mo

MedCPT-Query-Encoder is an open-weight embedding model from ncbi. MedCPT-Query-Encoder (FP32) weighs 219 MB; the smallest configuration that runs it is RTX 3060 12 GB.

For self-hosting, compare this build's requirements below with the GPU you plan to rent.

  • MedCPT-Query-Encoder is a 109M parameter feature-extraction model developed by NCBI for generating embeddings of short biomedical texts.
  • It is designed for semantic search, query clustering, and query-to-query retrieval tasks.
  • The model supports a context length of 512 tokens and is distributed under an other licence.

Summary of the ncbi/MedCPT-Query-Encoder model card, 2026-10-01

What it is

Released byncbi
Released2023-10-24
Parameters109M
VRAM219 MB for the weights

What it runs on

Memory and cards for MedCPT-Query-Encoder (FP32)

219 MBweights, file size
1.1 GBruntime overhead
CardRunsMemory
RTX 3060 12 GBfits11.6 GB
RTX 4060 Ti 16 GBfits15.4 GB
RTX 3090 24 GBfits23.4 GB
RTX 4090 24 GBfits23.4 GB
RTX 5090 32 GBfits31.0 GB
L40S 48 GBfits44.0 GB
A100 80 GBfits78.2 GB
H100 80 GBfits78.1 GB
RTX PRO 6000 Blackwell 96 GBfits93.8 GB
DGX Spark (GB10) 128 GB unifiedfits107 GB
H200 141 GBfits138 GB
B200 180 GBfits176 GB

From the model card

What ncbi says about MedCPT-Query-Encoder

Read the model card

MedCPT generates embeddings of biomedical texts that can be used for semantic search (dense retrieval). The model contains two encoders:

This repo contains the MedCPT Query Encoder.

MedCPT has been pre-trained by an unprecedented scale of 255M query-article pairs from PubMed search logs, and has been shown to achieve state-of-the-art performance on several zero-shot biomedical IR datasets. In general, there are three use cases:

  1. Query-to-article search with both encoders.
  2. Query representation for clustering or query-to-query search with the query encoder.
  3. Article representation for clustering or article-to-article search with the article encoder.

For more details, please check out our paper (Bioinformatics, 2023). Please note that the released version is slightly different from the version reported in the paper.

Case 1. Using the MedCPT Query Encoder

import torch
from transformers import AutoTokenizer, AutoModel

model = AutoModel.from_pretrained("ncbi/MedCPT-Query-Encoder")
tokenizer = AutoTokenizer.from_pretrained("ncbi/MedCPT-Query-Encoder")

queries = [
	"diabetes treatment",
	"How to treat diabetes?",
	"A 45-year-old man presents with increased thirst and frequent urination over the past 3 months.",
]

with torch.no_grad():
	# tokenize the queries
	encoded = tokenizer(
		queries,
		truncation=True,
		padding=True,
		return_tensors='pt',
		max_length=64,
	)

	# encode the queries (use the [CLS] last hidden states as the representations)
	embeds = model(**encoded).last_hidden_state[:, 0, :]

	print(embeds)
	print(embeds.size())

The output will be:

tensor([[ 0.0413,  0.0084, -0.0491,  ..., -0.4963, -0.3830, -0.3593],
        [ 0.0801,  0.1193, -0.0905,  ..., -0.5380, -0.5059, -0.2944],
        [-0.3412,  0.1521, -0.0946,  ...,  0.0952,  0.1660, -0.0902]])
torch.Size([3, 768])

These embeddings are also in the same space as those generated by the MedCPT article encoder.

Case 2. Semantically searching PubMed with your query

We have provided the embeddings of all PubMed articles generated by the MedCPT article encoder at https://ftp.ncbi.nlm.nih.gov/pub/lu/MedCPT/pubmed_embeddings/. You can simply download these embeddings to search PubMed with your query.

Acknowledgments

This work was supported by the Intramural Research Programs of the National Institutes of Health, National Library of Medicine.

Disclaimer

This tool shows the results of research conducted in the Computational Biology Branch, NCBI/NLM. The information produced on this website is not intended for direct diagnostic use or medical decision-making without review and oversight by a clinical professional. Individuals should not change their health behavior solely on the basis of information produced on this website. NIH does not independently verify the validity or utility of the information produced by this tool. If you have questions about the information produced on this website, please see a health care professional. More information about NCBI's disclaimer policy is available.

Citation

If you find this repo helpful, please cite MedCPT by:

@article{jin2023medcpt,
  title={MedCPT: Contrastive Pre-trained Transformers with large-scale PubMed search logs for zero-shot biomedical information retrieval},
  author={Jin, Qiao and Kim, Won and Chen, Qingyu and Comeau, Donald C and Yeganova, Lana and Wilbur, W John and Lu, Zhiyong},
  journal={Bioinformatics},
  volume={39},
  number={11},
  pages={btad651},
  year={2023},
  publisher={Oxford University Press}
}

Quoted from the model card on Hugging Face. The full card is behind the Hugging Face link above.

© 2026 AxForge · EU-hosted AI infrastructure Pricing Docs Trust Privacy Terms