🚀 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.",
}