🚀 DiSCo:用於對話搜索中高效稀疏檢索的大語言模型知識蒸餾
DiSCo模型是對原始SPLADE++ (CoCondenser-EnsembleDistil)模型進行對話搜索適配後的產物。它保留了原始的文檔編碼器,並在專為多輪對話搜索設計的QReCC數據集上對查詢編碼器進行微調。
訓練過程通過從多個教師模型(人類改寫和Mistral改寫)進行知識蒸餾來完成,這使得模型能夠更好地捕捉對話查詢的語義。更多詳細信息,請參閱原始論文:
- DiSCo SPLADE - SIGIR 2025完整論文:https://arxiv.org/abs/2410.14609
⚠️ 重要提示
這是查詢編碼器。在進行推理時,你還需要對應的文檔編碼器,該文檔編碼器與原始的SPLADE++檢查點保持一致。SPLADE可以使用非對稱架構,即使用單獨的模型來表示查詢和文檔。
🚀 快速開始
本模型是對原始 SPLADE++ (CoCondenser-EnsembleDistil) 模型進行對話搜索適配後的產物。它保留了原始的文檔編碼器,並在專為多輪對話搜索設計的 QReCC 數據集上對查詢編碼器進行微調。
訓練過程通過 從多個教師模型(人類改寫和 Mistral 改寫)進行知識蒸餾 來完成,這使得模型能夠更好地捕捉對話查詢的語義。更多詳細信息,請參閱原始論文:
- DiSCo SPLADE - SIGIR 2025 完整論文:https://arxiv.org/abs/2410.14609
✨ 主要特性
- 對話搜索適配:基於原始 SPLADE++ 模型,針對對話搜索場景進行了優化。
- 知識蒸餾:通過從人類和 Mistral 改寫中進行蒸餾,更好地捕捉對話查詢的語義。
- 非對稱架構:支持使用單獨的模型進行查詢和文檔表示。
💻 使用示例
基礎用法
from transformers import AutoTokenizer, AutoModelForMaskedLM
import torch.nn.functional as F
import torch
model = AutoModelForMaskedLM.from_pretrained("slupart/splade-disco-human-mistral")
tokenizer = AutoTokenizer.from_pretrained("slupart/splade-disco-human-mistral")
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}")
注意事項
請參考 DiSCo 的 GitHub 倉庫以獲取完整的使用說明 [github]。輸入格式是對話歷史的扁平化版本,即 q_n [SEP] a_{n-1} [SEP] q_{n-1} [SEP] ... [SEP] a_0 [SEP] q_0
。
📄 許可證
本模型採用 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}
}