🚀 SapBERT - 生物医学实体表示预训练模型
SapBERT是一种用于生物医学实体表示的预训练模型,能够准确捕捉生物医学领域的细粒度语义关系,在生物医学实体链接等任务中表现出色。它基于特定的预训练方案,利用大规模生物医学本体数据进行训练,为生物医学研究提供了强大的支持。
🚀 快速开始
SapBERT可用于将生物医学实体名称转换为嵌入向量,在生物医学实体链接等任务中发挥重要作用。以下是一个简单的使用示例,展示了如何从SapBERT中提取嵌入向量。
✨ 主要特性
- 跨语言扩展:SapBERT有跨语言扩展版本,将在ACL 2021主会议中亮相。
- 多会议展示:SapBERT将出现在NAACL 2021会议论文集中。
- 精准语义捕捉:能够准确捕捉生物医学领域的细粒度语义关系。
- 高效实体链接:为医学实体链接问题提供了优雅的一体化解决方案,在多个基准数据集上达到了新的最优水平。
📦 安装指南
暂未提供具体安装步骤,可参考SapBERT github仓库获取更多信息。
💻 使用示例
基础用法
以下脚本将字符串列表(实体名称)转换为嵌入向量:
import numpy as np
import torch
from tqdm.auto import tqdm
from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained("cambridgeltl/SapBERT-from-PubMedBERT-fulltext")
model = AutoModel.from_pretrained("cambridgeltl/SapBERT-from-PubMedBERT-fulltext").cuda()
all_names = ["covid-19", "Coronavirus infection", "high fever", "Tumor of posterior wall of oropharynx"]
bs = 128
all_embs = []
for i in tqdm(np.arange(0, len(all_names), bs)):
toks = tokenizer.batch_encode_plus(all_names[i:i+bs],
padding="max_length",
max_length=25,
truncation=True,
return_tensors="pt")
toks_cuda = {}
for k,v in toks.items():
toks_cuda[k] = v.cuda()
cls_rep = model(**toks_cuda)[0][:,0,:]
all_embs.append(cls_rep.cpu().detach().numpy())
all_embs = np.concatenate(all_embs, axis=0)
📚 详细文档
SapBERT - PubMedBERT
SapBERT由Liu等人(2020)提出。使用UMLS 2020AA(仅英文)进行训练,以microsoft/BiomedNLP - PubMedBERT - base - uncased - abstract - fulltext为基础模型。
预期输入和输出
输入应为生物医学实体名称的字符串,例如“covid infection”或“Hydroxychloroquine”。最后一层的[CLS]嵌入被视为输出。
数据集
新闻动态
- [新闻] SapBERT的跨语言扩展版本将出现在ACL 2021主会议中!
- [新闻] SapBERT将出现在NAACL 2021会议论文集中!
🔧 技术细节
尽管通过掩码语言模型(MLM)进行的自监督学习取得了广泛成功,但准确捕捉生物医学领域的细粒度语义关系仍然是一个挑战。这对于实体链接等实体级任务至关重要,因为建模实体关系(尤其是同义词)的能力是关键。为了解决这一挑战,作者提出了SapBERT,这是一种对生物医学实体的表示空间进行自对齐的预训练方案。作者设计了一个可扩展的度量学习框架,该框架可以利用UMLS,这是一个包含400多万个概念的大规模生物医学本体集合。与以前基于流水线的混合系统相比,SapBERT为医学实体链接(MEL)问题提供了一个优雅的一体化解决方案,在六个MEL基准数据集上达到了新的最优水平(SOTA)。在科学领域,即使没有特定任务的监督,作者也达到了SOTA。与BioBERT、SciBERT和PubMedBERT等各种特定领域的预训练MLM相比,作者的预训练方案被证明既有效又稳健。
📄 许可证
本项目采用Apache - 2.0许可证。
📖 引用
如果您使用了该模型,请引用以下论文:
@inproceedings{liu-etal-2021-self,
title = "Self-Alignment Pretraining for Biomedical Entity Representations",
author = "Liu, Fangyu and
Shareghi, Ehsan and
Meng, Zaiqiao and
Basaldella, Marco and
Collier, Nigel",
booktitle = "Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies",
month = jun,
year = "2021",
address = "Online",
publisher = "Association for Computational Linguistics",
url = "https://www.aclweb.org/anthology/2021.naacl-main.334",
pages = "4228--4238",
abstract = "Despite the widespread success of self-supervised learning via masked language models (MLM), accurately capturing fine-grained semantic relationships in the biomedical domain remains a challenge. This is of paramount importance for entity-level tasks such as entity linking where the ability to model entity relations (especially synonymy) is pivotal. To address this challenge, we propose SapBERT, a pretraining scheme that self-aligns the representation space of biomedical entities. We design a scalable metric learning framework that can leverage UMLS, a massive collection of biomedical ontologies with 4M+ concepts. In contrast with previous pipeline-based hybrid systems, SapBERT offers an elegant one-model-for-all solution to the problem of medical entity linking (MEL), achieving a new state-of-the-art (SOTA) on six MEL benchmarking datasets. In the scientific domain, we achieve SOTA even without task-specific supervision. With substantial improvement over various domain-specific pretrained MLMs such as BioBERT, SciBERTand and PubMedBERT, our pretraining scheme proves to be both effective and robust.",
}