# MedCPT: Contrastive Pre-trained Transformers with large-scale PubMed search logs for zero-shot biomedical information retrieval (Bioinformatics, 2023) \ zero-shot retriever \ :paperclip: https://arxiv.org/ftp/arxiv/papers/2307/2307.00589.pdf \ 在沒有大量查詢文章的標注情況下,如何++改進++生物醫學中的Information Retrieval ## :pushpin: Introduction - 第一個通過 contrastive learning 整合 <font color="#5C1AEB">retriever and re-ranker</font> 的生物醫學IR模型. - MedCPT re-ranker trained with <font color="#5C1AEB">negative distribution</font> sampled from pre-trained MedCPT retriever. - 對各種生物醫學IR任務進行 <font color="#5C1AEB">Zero-shot</font> 評估。 - Applicable to various biomedical applications like document searching, similar sentence retrieval, article recommendation, and domain-specific retrieval-augmentation for large language models. ## :pushpin: Materials and methods ### Data Collection - 從 PubMed search logs 收集三年(2020年至2022年)匿名的查詢–文章點擊 - 過濾 navigational queries(搜尋作者和期刊標題),保留 informational queries,得到 87M informational queries and 17M articles - 根據用戶點擊生成 255M relevant query–article pairs ,用於訓練 <font color="#5C1AEB">MedCPT retriever</font> - 有些查詢較困難(在搜索引擎後的排名較高的文章中,有些文章可能是負面例子/不相關的文章,所以 re-ranker 需要語義理解能力,區別在外觀上相關但實際上與查詢無關的文章),需要對文本的語義進行更深入分析才能將點擊的文章進行配對,所以使用 ++difficult subset++ 子集來訓練 <font color="#5C1AEB">MedCPT re-ranker</font> - difficult subset:過濾出了79M個 keyword queries(只有一個單詞,或點擊的文章都包含了完全配對的整個輸入查詢)。最終有7.7M個 non-keyword 查詢和5.2M篇文章,並生成18.3M個 relevant query–article pairs。 ![image](https://hackmd.io/_uploads/HkzHdhWn6.png) ### MedCPT architecture ![image](https://hackmd.io/_uploads/SkdFF4Dnp.png) MedCPT 的兩個階段(皆是 Transformer (Trm) encoders initialized by PubMedBERT): - **++Retriever++** - 包括 query(QEnc)和 document encoder(DEnc) - bi-encoder 結構可以在 offline 下對文章編碼,real-time inference 期間,只需要對 query 進行編碼計算和一次 nearest neighbor search - Training Process - query q & document d Encoder ![image](https://hackmd.io/_uploads/BkkFHXD26.png =300x) ![image](https://hackmd.io/_uploads/B1CoBQPnp.png =350x) - relevance of q&d,內積運算 ![image](https://hackmd.io/_uploads/SyWKv7D2a.png =200x) - query q 、a clicked document d 、點擊次數 c 、每個 mini-batch 包含|B|個實例 ![image](https://hackmd.io/_uploads/r15kA7Pha.png =100x) :::info e.g. $$[q_i, d_i ,c_i]^\left|3 \right |_{i=1}=\left [\begin{matrix}q_1, d_1 ,c_1\\q_2, d_2 ,c_2\\q_3, d_3 ,c_3\end{matrix} \right ] $$ - 計算 ++query-to-document loss++ & ++document-to-query loss++: ![image](https://hackmd.io/_uploads/SkNGRrP2T.png =250x) ![image](https://hackmd.io/_uploads/H1HYCBP3T.png =270x) :::info 1. qi 和 di 內積,在計算 Probability ,指數函數exp(x)(表示e的x次方) 2. 計算qi 和每個文檔dm之間的相似度 3. exp(x)能夠將相似性大值轉換為更接近1的概率值,同時將相似性小值轉換為接近0的Probability,這有助於強調較高相似性的文檔,同時減弱較低相似性的文檔 4. 對數函數將 Probability 映射到了一個更小的範圍內,有助於避免極端大或極端小對模型訓練的影響 - 通過每個訓練實例的點擊數來計算 instance-level losses 的權重(考慮每個訓練實例的貢獻),final loss LB 通過梯度下降優化 ![image](https://hackmd.io/_uploads/BkPXSIwha.png =300x) - **++Re-ranker++** - Cross-Encoder(CrossEnc) - 在 query 和 article tokens 之間的 cross-attention 計算(僅在retriever 返回的排名前面文章) - 使用 single CrossEnc 預測 q 和 d 之間的相關性,為線性模型 ![image](https://hackmd.io/_uploads/BkZJo8vhT.png =400x) - Training Process - 每個實例包含,qi、di+(a clicked document)、M 個不相關(未點擊)document 的列表 ![image](https://hackmd.io/_uploads/r1VcnUD3a.png =180x) - 使用 local negative documents,retriever 計算最大內積們後,從排名在 e 到排名在 f 的 d 中抽樣這些 negatives ![image](https://hackmd.io/_uploads/rk-BeDP26.png =350x) ## :pushpin: Results 省略 :::success **Compared methods** 1. Sparse retrievers 3. Dense retrievers 4. Large language model retrievers ::: ## :pushpin: Discussions 1. MedCPT 從PubMed使用者日誌中的查詢-文章點擊訓練,在 BEIR 的表現達到 SOTA 2. This shows that the contrastive objective can train not only a dense retriever, but can also train the individual query and DEncs to perform tasks related to information-seeking behaviors. 3. 不如 sparse retrievers 的 controllable or explainable,因此未來可能的一個方向是開發能夠兼顧兩種方法優勢的 dense-sparse retrieval systems https://medium.com/@amanatulla1606/medcpt-revolutionizing-biomedical-information-retrieval-rag-with-contrastive-pre-training-78edf9b89b6d