🚀 MedCPT介紹
MedCPT能夠生成生物醫學文本的嵌入向量,可用於語義搜索(密集檢索)。該模型包含兩個編碼器:
本倉庫包含MedCPT文章編碼器。
MedCPT通過來自PubMed搜索日誌的前所未有的2.55億個查詢 - 文章對進行了預訓練,並已在多個零樣本生物醫學信息檢索數據集上實現了最先進的性能。一般來說,有三種使用場景:
- 使用兩個編碼器進行查詢到文章的搜索。
- 使用查詢編碼器進行查詢表示,用於聚類或查詢到查詢的搜索。
- 使用文章編碼器進行文章表示,用於聚類或文章到文章的搜索。
更多詳細信息,請查看我們的論文(《Bioinformatics》,2023年)。請注意,發佈版本與論文中報告的版本略有不同。
🚀 快速開始
案例1. 使用MedCPT文章編碼器
import torch
from transformers import AutoTokenizer, AutoModel
model = AutoModel.from_pretrained("ncbi/MedCPT-Article-Encoder")
tokenizer = AutoTokenizer.from_pretrained("ncbi/MedCPT-Article-Encoder")
articles = [
[
"Diagnosis and Management of Central Diabetes Insipidus in Adults",
"Central diabetes insipidus (CDI) is a clinical syndrome which results from loss or impaired function of vasopressinergic neurons in the hypothalamus/posterior pituitary, resulting in impaired synthesis and/or secretion of arginine vasopressin (AVP). [...]",
],
[
"Adipsic diabetes insipidus",
"Adipsic diabetes insipidus (ADI) is a rare but devastating disorder of water balance with significant associated morbidity and mortality. Most patients develop the disease as a result of hypothalamic destruction from a variety of underlying etiologies. [...]",
],
[
"Nephrogenic diabetes insipidus: a comprehensive overview",
"Nephrogenic diabetes insipidus (NDI) is characterized by the inability to concentrate urine that results in polyuria and polydipsia, despite having normal or elevated plasma concentrations of arginine vasopressin (AVP). [...]",
],
]
with torch.no_grad():
encoded = tokenizer(
articles,
truncation=True,
padding=True,
return_tensors='pt',
max_length=512,
)
embeds = model(**encoded).last_hidden_state[:, 0, :]
print(embeds)
print(embeds.size())
輸出結果如下:
tensor([[-0.0189, 0.0115, 0.0988, ..., -0.0655, 0.3155, -0.0357],
[-0.3402, -0.3064, -0.0749, ..., -0.0799, 0.3332, 0.1263],
[-0.2764, -0.0506, -0.0608, ..., 0.0389, 0.2532, 0.1580]])
torch.Size([3, 768])
這些嵌入向量與MedCPT查詢編碼器生成的嵌入向量處於同一空間。
案例2. 使用預計算的嵌入向量
我們已經在https://ftp.ncbi.nlm.nih.gov/pub/lu/MedCPT/pubmed_embeddings/ 提供了由MedCPT文章編碼器生成的所有PubMed文章的嵌入向量。
📄 許可證
本項目採用公共領域許可協議。
🙏 致謝
這項工作得到了美國國立醫學圖書館國立衛生研究院內部研究計劃的支持。
⚠️ 免責聲明
此工具展示了美國國家醫學圖書館(NLM)國家生物技術信息中心(NCBI)計算生物學部門進行的研究結果。本網站生成的信息未經臨床專業人員審核和監督,不應用於直接診斷或醫療決策。個人不應僅根據本網站生成的信息改變其健康行為。美國國立衛生研究院(NIH)不會獨立驗證此工具生成信息的有效性或實用性。如果您對本網站生成的信息有疑問,請諮詢醫療保健專業人員。有關NCBI免責政策的更多信息,請查閱相關內容。
📚 引用
如果您覺得本倉庫有幫助,請按以下方式引用MedCPT:
@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}
}