🚀 文章排名工具
本工具用於根據給定查詢對文章進行排名,能夠幫助用戶快速篩選出與查詢最相關的文章,在生物醫學信息檢索場景中具有重要價值。
🚀 快速開始
安裝依賴
確保你已經安裝了torch
和transformers
庫。如果沒有安裝,可以使用以下命令進行安裝:
pip install torch transformers
代碼示例
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("ncbi/MedCPT-Cross-Encoder")
model = AutoModelForSequenceClassification.from_pretrained("ncbi/MedCPT-Cross-Encoder")
query = "diabetes treatment"
articles = [
"Type 1 and 2 diabetes mellitus: A review on current treatment approach and gene therapy as potential intervention. Type 1 and type 2 diabetes mellitus is a serious and lifelong condition commonly characterised by abnormally elevated blood glucose levels due to a failure in insulin production or a decrease in insulin sensitivity and function. [...]",
"Diabetes mellitus and its chronic complications. Diabetes mellitus is a major cause of morbidity and mortality, and it is a major risk factor for early onset of coronary heart disease. Complications of diabetes are retinopathy, nephropathy, and peripheral neuropathy. [...]",
"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). [...]",
"Impact of Salt Intake on the Pathogenesis and Treatment of Hypertension. Excessive dietary salt (sodium chloride) intake is associated with an increased risk for hypertension, which in turn is especially a major risk factor for stroke and other cardiovascular pathologies, but also kidney diseases. Besides, high salt intake or preference for salty food is discussed to be positive associated with stomach cancer, and according to recent studies probably also obesity risk. [...]"
]
pairs = [[query, article] for article in articles]
with torch.no_grad():
encoded = tokenizer(
pairs,
truncation=True,
padding=True,
return_tensors="pt",
max_length=512,
)
logits = model(**encoded).logits.squeeze(dim=1)
print(logits)
輸出結果
tensor([ 6.9363, -8.2063, -8.7692, -12.3450, -10.4416, -15.8475])
分數越高表示文章與查詢的相關性越高。
📄 許可證
本項目採用公共領域許可證,詳情請見LICENSE。
🙏 致謝
本工作得到了美國國立衛生研究院國家醫學圖書館內部研究項目的支持。
⚠️ 免責聲明
本工具展示了美國國家醫學圖書館(NCBI/NLM)計算生物學部門的研究成果。本網站生成的信息未經臨床專業人員審查和監督,不應用於直接診斷或醫療決策。個人不應僅根據本網站生成的信息改變其健康行為。美國國立衛生研究院(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}
}