基础模型:
- Qwen/Qwen2.5-0.5B
数据集:
- jhu-clsp/rank1-training-data
语言:
- en
许可证: mit
管道标签: text-ranking
标签:
- 重排序器
- 检索
库名称: transformers
rank1-0.5b: 信息检索重排序中的测试时计算
📄 论文 | 🚀 GitHub仓库
rank1是一款"思考"后再做相关性判断的推理重排序模型。这个5亿参数模型基于Qwen2.5-0.5B基础模型训练,利用测试时计算在判断文档与查询相关性前生成推理链。
模型描述
rank1通过在做相关性判断前生成显式推理链,为信息检索引入了新方法。与传统直接输出分数的重排序器不同,rank1:
- 接收查询和文档对
- 在
<think>...</think>
部分生成推理链
- 做出二元相关性判断(
true
或false
)
- 基于true/false标记的对数概率返回置信度分数
这种方法帮助模型将复杂的相关性决策分解为逻辑步骤,提升了多样化检索任务的性能。
模型系列
量化版本
相关数据与资源
使用说明
官方使用说明请见Github仓库,其中考虑了边缘情况。但对于简单用例,下面的最小示例即可工作。
点击展开:使用vLLM的最小示例
from vllm import LLM, SamplingParams
import math
model = LLM(
model="jhu-clsp/rank1-0.5b",
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 (
"判断以下段落是否与查询相关。"
"仅回答'true'或'false'。\n"
f"查询: {query}\n"
f"段落: {document}\n"
"<think>"
)
query = "气候变化有哪些影响?"
document = "气候变化导致海平面上升、极端天气事件和生态系统紊乱。这些影响是由人类活动导致大气中温室气体浓度增加引起的。"
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-0.5b")
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"推理链: {text}")
print(f"相关性分数: {relevance_score}")
性能表现
rank1-0.5b在检索基准测试中展现出强劲性能,特别是在需要复杂推理的任务上。模型"逐步思考"相关性决策的能力使其在处理微妙主题时尤为有效。
具体基准测试结果及与其他模型的比较,请参阅论文和官方GitHub仓库。
安装
详细安装说明请见Github仓库。
MTEB集成
rank1兼容MTEB基准测试框架:
from mteb import MTEB
from rank1 import rank1
model = rank1(
model_name_or_path="jhu-clsp/rank1-0.5b",
num_gpus=1,
device="cuda"
)
evaluation = MTEB(tasks=["NevIR"])
results = evaluation.run(model)
引用
如果您在研究中使用了rank1,请引用我们的工作:
@misc{weller2025rank1testtimecomputereranking,
title={Rank1: 信息检索重排序中的测试时计算},
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},
}
许可证
MIT许可证