Bmretriever 7B
模型概述
該模型基於論文《BMRetriever:將大語言模型調優為更優的生物醫學文本檢索器》所述方法進行微調,旨在提升生物醫學領域的信息檢索效率和質量。
模型特點
生物醫學領域優化
專門針對醫學和生物學領域的文本檢索任務進行微調,提升相關領域的檢索效果。
大語言模型支持
基於70億參數的大語言模型,具備強大的語義理解能力。
多源數據訓練
使用包括醫學教材、PubMed文獻、StatPearls醫學百科等多種生物醫學數據源進行訓練。
模型能力
生物醫學文本檢索
醫學文獻相關性評估
科學論斷支持性文獻查找
使用案例
醫學研究
醫學論斷驗證
檢索支持或反駁特定醫學論斷的相關文獻
高效找到相關性高的支持或反駁證據
生物醫學信息檢索
專業文獻檢索
在大量生物醫學文獻中快速找到相關內容
提高研究人員獲取相關文獻的效率
🚀 BMRetriever-7B模型
本模型是按照論文《BMRetriever: Tuning Large Language Models as Better Biomedical Text Retrievers》中描述的方法進行微調的。相關的GitHub倉庫可在 此處 查看。
該模型擁有70億個參數,詳細信息請參閱論文 鏈接。
🚀 快速開始
本模型可通過HuggingFace的transformers庫加載預訓練模型,以下是詳細的使用步驟。
📦 安裝指南
使用前請確保已安裝HuggingFace的transformers庫,若未安裝,可使用以下命令進行安裝:
pip install transformers
💻 使用示例
基礎用法
通過HuggingFace的transformers庫加載預訓練模型:
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained("BMRetriever/BMRetriever-7B")
tokenizer = AutoTokenizer.from_pretrained("BMRetriever/BMRetriever-7B")
高級用法
獲取不同句子的嵌入表示,並計算句子之間的相似度得分:
import torch
import torch.nn.functional as F
from torch import Tensor
from transformers import AutoTokenizer, AutoModel
def last_token_pool(last_hidden_states: Tensor,
attention_mask: Tensor) -> Tensor:
last_hidden = last_hidden_states.masked_fill(~attention_mask[..., None].bool(), 0.0)
left_padding = (attention_mask[:, -1].sum() == attention_mask.shape[0])
if left_padding:
embedding = last_hidden[:, -1]
else:
sequence_lengths = attention_mask.sum(dim=1) - 1
batch_size = last_hidden.shape[0]
embedding = last_hidden[torch.arange(batch_size, device=last_hidden.device), sequence_lengths]
return embedding
def get_detailed_instruct_query(task_description: str, query: str) -> str:
return f'{task_description}\nQuery: {query}'
def get_detailed_instruct_passage(passage: str) -> str:
return f'Represent this passage\npassage: {passage}'
# Each query must come with a one-sentence instruction that describes the task
task = 'Given a scientific claim, retrieve documents that support or refute the claim'
queries = [
get_detailed_instruct_query(task, 'Cis-acting lncRNAs control the expression of genes that are positioned in the vicinity of their transcription sites.'),
get_detailed_instruct_query(task, 'Forkhead 0 (fox0) transcription factors are involved in apoptosis.')
]
# No need to add instruction for retrieval documents
documents = [
get_detailed_instruct_passage("Gene regulation by the act of long non-coding RNA transcription Long non-protein-coding RNAs (lncRNAs) are proposed to be the largest transcript class in the mouse and human transcriptomes. Two important questions are whether all lncRNAs are functional and how they could exert a function. Several lncRNAs have been shown to function through their product, but this is not the only possible mode of action. In this review we focus on a role for the process of lncRNA transcription, independent of the lncRNA product, in regulating protein-coding-gene activity in cis. We discuss examples where lncRNA transcription leads to gene silencing or activation, and describe strategies to determine if the lncRNA product or its transcription causes the regulatory effect."),
get_detailed_instruct_passage("Noncoding transcription at enhancers: general principles and functional models. Mammalian genomes are extensively transcribed outside the borders of protein-coding genes. Genome-wide studies recently demonstrated that cis-regulatory genomic elements implicated in transcriptional control, such as enhancers and locus-control regions, represent major sites of extragenic noncoding transcription. Enhancer-templated transcripts provide a quantitatively small contribution to the total amount of cellular nonribosomal RNA; nevertheless, the possibility that enhancer transcription and the resulting enhancer RNAs may, in some cases, have functional roles, rather than represent mere transcriptional noise at accessible genomic regions, is supported by an increasing amount of experimental data. In this article we review the current knowledge on enhancer transcription and its functional implications.")
]
input_texts = queries + documents
max_length = 512
# Tokenize the input texts
batch_dict = tokenizer(input_texts, max_length=max_length-1, padding=True, truncation=True, return_tensors='pt')
# Important! Adding EOS token at the end
batch_dict['input_ids'] = [input_ids + [tokenizer.eos_token_id] for input_ids in batch_dict['input_ids']]
batch_dict = tokenizer.pad(batch_dict, padding=True, return_attention_mask=True, return_tensors='pt').to("cuda")
model.eval()
with torch.no_grad():
outputs = model(**batch_dict)
embeddings = last_token_pool(outputs.last_hidden_state, batch_dict['attention_mask'])
scores = (embeddings[:2] @ embeddings[2:].T)
print(scores.tolist())
📄 許可證
本項目採用MIT許可證。
📚 引用
如果您覺得本倉庫對您有幫助,請考慮引用相應的論文,感謝!
@misc{xu2024bmretriever,
title={BMRetriever: Tuning Large Language Models as Better Biomedical Text Retrievers},
author={Ran Xu and Wenqi Shi and Yue Yu and Yuchen Zhuang and Yanqiao Zhu and May D. Wang and Joyce C. Ho and Chao Zhang and Carl Yang},
year={2024},
eprint={2404.18443},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
📋 數據集
本模型使用了以下數據集進行訓練:
數據集 |
---|
MedRAG/textbooks |
MedRAG/pubmed |
MedRAG/statpearls |
mteb/raw_biorxiv |
mteb/raw_medrxiv |
ms_marco |
BMRetriever/biomed_retrieval_dataset |
Phi 2 GGUF
其他
Phi-2是微軟開發的一個小型但強大的語言模型,具有27億參數,專注於高效推理和高質量文本生成。
大型語言模型 支持多種語言
P
TheBloke
41.5M
205
Roberta Large
MIT
基於掩碼語言建模目標預訓練的大型英語語言模型,採用改進的BERT訓練方法
大型語言模型 英語
R
FacebookAI
19.4M
212
Distilbert Base Uncased
Apache-2.0
DistilBERT是BERT基礎模型的蒸餾版本,在保持相近性能的同時更輕量高效,適用於序列分類、標記分類等自然語言處理任務。
大型語言模型 英語
D
distilbert
11.1M
669
Llama 3.1 8B Instruct GGUF
Meta Llama 3.1 8B Instruct 是一個多語言大語言模型,針對多語言對話用例進行了優化,在常見的行業基準測試中表現優異。
大型語言模型 英語
L
modularai
9.7M
4
Xlm Roberta Base
MIT
XLM-RoBERTa是基於100種語言的2.5TB過濾CommonCrawl數據預訓練的多語言模型,採用掩碼語言建模目標進行訓練。
大型語言模型 支持多種語言
X
FacebookAI
9.6M
664
Roberta Base
MIT
基於Transformer架構的英語預訓練模型,通過掩碼語言建模目標在海量文本上訓練,支持文本特徵提取和下游任務微調
大型語言模型 英語
R
FacebookAI
9.3M
488
Opt 125m
其他
OPT是由Meta AI發佈的開放預訓練Transformer語言模型套件,參數量從1.25億到1750億,旨在對標GPT-3系列性能,同時促進大規模語言模型的開放研究。
大型語言模型 英語
O
facebook
6.3M
198
1
基於transformers庫的預訓練模型,適用於多種NLP任務
大型語言模型
Transformers

1
unslothai
6.2M
1
Llama 3.1 8B Instruct
Llama 3.1是Meta推出的多語言大語言模型系列,包含8B、70B和405B參數規模,支持8種語言和代碼生成,優化了多語言對話場景。
大型語言模型
Transformers 支持多種語言

L
meta-llama
5.7M
3,898
T5 Base
Apache-2.0
T5基礎版是由Google開發的文本到文本轉換Transformer模型,參數規模2.2億,支持多語言NLP任務。
大型語言模型 支持多種語言
T
google-t5
5.4M
702
精選推薦AI模型
Llama 3 Typhoon V1.5x 8b Instruct
專為泰語設計的80億參數指令模型,性能媲美GPT-3.5-turbo,優化了應用場景、檢索增強生成、受限生成和推理任務
大型語言模型
Transformers 支持多種語言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一個基於SODA數據集訓練的超小型對話模型,專為邊緣設備推理設計,體積僅為Cosmo-3B模型的2%左右。
對話系統
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基於RoBERTa架構的中文抽取式問答模型,適用於從給定文本中提取答案的任務。
問答系統 中文
R
uer
2,694
98