🚀 FremyCompany/BioLORD-2023-C
本模型旨在解決臨床句子和生物醫學概念的有意義表示問題,通過新的預訓練策略BioLORD進行訓練,能在臨床句子和生物醫學概念的文本相似度任務上達到新的最優效果。
🚀 快速開始
本模型是一個基於sentence-transformers
的模型,它可以將句子和段落映射到768維的密集向量空間,可用於聚類或語義搜索等任務。該模型針對生物醫學領域進行了微調,在處理醫學文檔(如電子健康記錄或臨床筆記)時會更有用。
安裝依賴
pip install -U sentence-transformers
代碼示例
from sentence_transformers import SentenceTransformer
sentences = ["Cat scratch injury", "Cat scratch disease", "Bartonellosis"]
model = SentenceTransformer('FremyCompany/BioLORD-2023-C')
embeddings = model.encode(sentences)
print(embeddings)
✨ 主要特性
- 創新預訓練策略:使用BioLORD預訓練策略,利用定義和多關係知識圖譜中的簡短描述來構建概念表示,克服了傳統方法可能產生非語義表示的問題。
- 語義匹配度高:生成的概念表示更具語義性,能更好地匹配本體的層次結構。
- 領域針對性強:針對生物醫學領域進行微調,在處理醫學文檔時表現更優。
📦 安裝指南
若要使用此模型,需安裝sentence-transformers
庫:
pip install -U sentence-transformers
💻 使用示例
基礎用法
from sentence_transformers import SentenceTransformer
sentences = ["Cat scratch injury", "Cat scratch disease", "Bartonellosis"]
model = SentenceTransformer('FremyCompany/BioLORD-2023-C')
embeddings = model.encode(sentences)
print(embeddings)
高級用法
若不使用sentence-transformers
庫,可按以下方式使用模型:
from transformers import AutoTokenizer, AutoModel
import torch
import torch.nn.functional as F
def mean_pooling(model_output, attention_mask):
token_embeddings = model_output[0]
input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
sentences = ["Cat scratch injury", "Cat scratch disease", "Bartonellosis"]
tokenizer = AutoTokenizer.from_pretrained('FremyCompany/BioLORD-2023-C')
model = AutoModel.from_pretrained('FremyCompany/BioLORD-2023-C')
encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
with torch.no_grad():
model_output = model(**encoded_input)
sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
sentence_embeddings = F.normalize(sentence_embeddings, p=2, dim=1)
print("Sentence embeddings:")
print(sentence_embeddings)
📚 詳細文檔
模型背景
當前最先進的方法通過最大化指代同一概念的名稱表示的相似性,並通過對比學習防止崩潰。但由於生物醫學名稱並非總是自解釋的,有時會導致非語義表示。BioLORD通過使用定義以及從由生物醫學本體組成的多關係知識圖譜中提取的簡短描述來構建其概念表示,克服了這一問題。
相關模型
本模型是BioLORD - 2023系列的一部分,該系列的其他模型如下:
你還可以查看去年的模型和論文:
訓練策略
三階段概述

對比階段詳情

自蒸餾階段詳情

引用信息
本模型伴隨論文BioLORD - 2023: Learning Ontological Representations from Definitions。使用此模型時,請按以下方式引用原文:
@article{remy-etal-2023-biolord,
author = {Remy, François and Demuynck, Kris and Demeester, Thomas},
title = "{BioLORD-2023: semantic textual representations fusing large language models and clinical knowledge graph insights}",
journal = {Journal of the American Medical Informatics Association},
pages = {ocae029},
year = {2024},
month = {02},
issn = {1527-974X},
doi = {10.1093/jamia/ocae029},
url = {https://doi.org/10.1093/jamia/ocae029},
eprint = {https://academic.oup.com/jamia/advance-article-pdf/doi/10.1093/jamia/ocae029/56772025/ocae029.pdf},
}
🔧 技術細節
本模型基於sentence - transformers/all - mpnet - base - v2,並在BioLORD - Dataset和來自Automatic Glossary of Clinical Terminology (AGCT)的大語言模型生成的定義上進行了進一步微調。
📄 許可證
本模型的個人貢獻部分遵循MIT許可證。然而,由於訓練此模型使用的數據源自UMLS和SnomedCT,在使用此模型之前,你需要確保擁有UMLS和SnomedCT的適當許可證。UMLS和SnomedCT在大多數國家都是免費的,但你可能需要創建一個賬戶並每年報告數據使用情況以保持有效許可證。
屬性 |
詳情 |
模型類型 |
基於sentence - transformers的生物醫學微調模型 |
訓練數據 |
BioLORD - Dataset、Automatic Glossary of Clinical Terminology (AGCT) |
⚠️ 重要提示
由於訓練數據源自UMLS和SnomedCT,使用此模型前需確保擁有UMLS和SnomedCT的適當許可證。
💡 使用建議
若要處理醫學文檔(如電子健康記錄或臨床筆記),使用此模型會更有幫助。同時,安裝sentence - transformers
庫可更方便地使用該模型。