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