🚀 rank1-3b:信息檢索重排序的測試時計算模型
rank1是一個推理重排序模型,它在進行相關性判斷之前會進行“思考”。這個具有30億參數的模型基於Qwen2.5 - 3B基礎模型進行訓練,並利用測試時計算在判斷文檔與查詢是否相關之前生成推理鏈。
🚀 快速開始
rank1是一個推理重排序模型,在信息檢索領域有著獨特的應用。它能在做出相關性判斷前生成明確的推理鏈,將複雜的相關性決策分解為邏輯步驟,從而提升在各種檢索任務中的性能。
📄 論文 | 🚀 GitHub倉庫
✨ 主要特性
- 創新的推理機制:rank1在進行相關性判斷之前會生成明確的推理鏈,與傳統直接輸出分數的重排序器不同,它將複雜的相關性決策分解為邏輯步驟,有助於提高在各種檢索任務中的性能。
- 多模型變體:提供了從0.5B到32B不同參數規模的模型變體,以及基於不同基礎模型(如Qwen2.5、Mistral、Llama 3.1)訓練的模型,還包括量化版本,滿足不同場景的需求。
- 豐富的關聯資源:有相關的訓練數據、預計算的運行文件以及官方GitHub倉庫等資源,方便用戶使用和進一步開發。
- MTEB兼容性:與MTEB基準測試框架兼容,便於進行模型評估。
📦 安裝指南
詳細的安裝說明請參考GitHub倉庫。
💻 使用示例
基礎用法
注意,官方使用方法可在GitHub上找到,其中考慮了各種邊緣情況。但對於簡單用例,以下最小示例即可。
點擊展開:使用vLLM的最小示例
from vllm import LLM, SamplingParams
import math
model = LLM(
model="jhu-clsp/rank1-3b",
tensor_parallel_size=1,
trust_remote_code=True,
max_model_len=16000,
gpu_memory_utilization=0.9,
dtype="float16",
)
sampling_params = SamplingParams(
temperature=0,
max_tokens=8192,
logprobs=20,
stop=["</think> true", "</think> false"],
skip_special_tokens=False
)
def create_prompt(query, document):
return (
"Determine if the following passage is relevant to the query. "
"Answer only with 'true' or 'false'.\n"
f"Query: {query}\n"
f"Passage: {document}\n"
"<think>"
)
query = "What are the effects of climate change?"
document = "Climate change leads to rising sea levels, extreme weather events, and disruptions to ecosystems. These effects are caused by increasing greenhouse gas concentrations in the atmosphere due to human activities."
prompt = create_prompt(query, document)
outputs = model.generate([prompt], sampling_params)
output = outputs[0].outputs[0]
text = output.text
final_logits = output.logprobs[-1]
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("jhu-clsp/rank1-3b")
true_token = tokenizer(" true", add_special_tokens=False).input_ids[0]
false_token = tokenizer(" false", add_special_tokens=False).input_ids[0]
true_logit = final_logits[true_token].logprob
false_logit = final_logits[false_token].logprob
true_score = math.exp(true_logit)
false_score = math.exp(false_logit)
relevance_score = true_score / (true_score + false_score)
print(f"Reasoning chain: {text}")
print(f"Relevance score: {relevance_score}")
高級用法
from mteb import MTEB
from rank1 import rank1
model = rank1(
model_name_or_path="jhu-clsp/rank1-3b",
num_gpus=1,
device="cuda"
)
evaluation = MTEB(tasks=["NevIR"])
results = evaluation.run(model)
📚 詳細文檔
模型描述
rank1在信息檢索中引入了一種新穎的方法,即在進行相關性判斷之前生成明確的推理鏈。與傳統直接輸出分數的重排序器不同,rank1的工作流程如下:
- 接收查詢和文檔對。
- 在
<think>...</think>
部分生成推理鏈。
- 做出二元相關性判斷(
true
或false
)。
- 根據
true
/false
標記的對數概率返回置信分數。
這種方法有助於模型將複雜的相關性決策分解為邏輯步驟,提高在各種檢索任務中的性能。
模型家族
量化變體
關聯數據和資源
🔧 技術細節
rank1-3b在檢索基準測試中表現出色,尤其在需要複雜推理的任務上。該模型“思考”相關性決策的能力使其在處理細微主題時特別有效。具體的基準測試結果以及與其他模型的比較,請參考論文和官方GitHub倉庫。
📄 許可證
本項目採用MIT許可證。
引用
如果您在研究中使用了rank1,請引用我們的工作:
@misc{weller2025rank1testtimecomputereranking,
title={Rank1: Test-Time Compute for Reranking in Information Retrieval},
author={Orion Weller and Kathryn Ricci and Eugene Yang and Andrew Yates and Dawn Lawrie and Benjamin Van Durme},
year={2025},
eprint={2502.18418},
archivePrefix={arXiv},
primaryClass={cs.IR},
url={https://arxiv.org/abs/2502.18418},
}