🚀 DiSCo:用於對話搜索中高效稀疏檢索的大語言模型知識蒸餾
DiSCo模型是對原始SPLADE++ (CoCondenser - EnsembleDistil)模型進行對話搜索適配後的成果。它保留了原始的文檔編碼器,並在QReCC(一個專為多輪對話搜索設計的數據集)上對查詢編碼器進行微調。通過從人工改寫中進行知識蒸餾的方式進行訓練,使模型能夠更好地捕捉對話查詢的語義信息。更多詳細內容請參考原論文:
- DiSCo SPLADE - SIGIR 2025全文:https://arxiv.org/abs/2410.14609
⚠️ 重要提示
這是查詢編碼器。在進行推理時,你還需要對應的文檔編碼器,該文檔編碼器與原始的SPLADE++檢查點保持一致。SPLADE可以使用非對稱架構:為查詢和文檔表示使用單獨的模型。
🚀 快速開始
本模型是對原始 SPLADE++ (CoCondenser-EnsembleDistil) 模型進行對話搜索適配後的版本。它保留了原始的文檔編碼器,並在專為多輪對話搜索設計的 QReCC 數據集上對查詢編碼器進行微調。
訓練通過從人工改寫中進行知識蒸餾來完成,使模型能更好地捕捉對話查詢的語義。更多詳細信息,請參閱原論文:
- DiSCo SPLADE - SIGIR 2025 完整論文:https://arxiv.org/abs/2410.14609
✨ 主要特性
📦 安裝指南
暫未提及安裝相關內容,跳過此章節。
💻 使用示例
基礎用法
請參考 DiSCo 的 GitHub 倉庫以獲取完整的使用說明 [github]。
以下是一個對對話進行編碼的示例腳本:
輸入格式是對話歷史的扁平化版本。
q_n [SEP] a_{n - 1} [SEP] q_{n - 1} [SEP] ... [SEP] a_0 [SEP] q_0
from transformers import AutoTokenizer, AutoModelForMaskedLM
import torch.nn.functional as F
import torch
model = AutoModelForMaskedLM.from_pretrained("slupart/splade-disco-human")
tokenizer = AutoTokenizer.from_pretrained("slupart/splade-disco-human")
model.eval()
conv = [
("what's the weather like today?", "it's sunny."),
("should I wear sunscreen?", "yes, UV index is high."),
("do I need sunglasses?", "definitely."),
("where can I buy sunglasses?", "try the optician nearby."),
("how much do they cost?", None)
]
parts = [conv[-1][0]] + [x for q, a in reversed(conv[:-1]) for x in (a, q) if x]
text = " [SEP] ".join(parts)
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
logits = model(**inputs).logits
sparse = F.relu(logits).max(1).values.squeeze(0)
scores = [(tokenizer.convert_ids_to_tokens([i.item()])[0], sparse[i].item())
for i in torch.nonzero(sparse).squeeze(1)]
for token, score in sorted(scores, key=lambda x: -x[1]):
print(f"Token: {token:15} | Score: {score:.4f}")
📚 詳細文檔
暫未提及詳細文檔相關內容,跳過此章節。
🔧 技術細節
暫未提及技術細節相關內容,跳過此章節。
📄 許可證
本模型使用的許可證為 CC BY-NC-SA 4.0。
📖 引用
如果您使用了我們的檢查點,請引用我們的工作:
@article{lupart2024disco,
title={DiSCo Meets LLMs: A Unified Approach for Sparse Retrieval and Contextual Distillation in Conversational Search},
author={Lupart, Simon and Aliannejadi, Mohammad and Kanoulas, Evangelos},
journal={arXiv preprint arXiv:2410.14609},
year={2024}
}