mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-24 15:52:01 +00:00
重排给足输出预算;失败提示分清是哪种失败
拿真 provider(deepseek-v4-pro,千帆网关)跑了一遍评测集,重排确实有用:
hit@1 hit@5
初筛 88% 100%
重排后 100% 100%
变动的两题都是语义类的,正好是本地哈希向量的短板——BM25 把「权限」的字面
命中排给了「数据导出」(那篇里有「export 权限」),模型读懂了问的是「谁有权
改」。字面类原本就 100%,没有被重排搞坏。
但 16 次里有 2 次退回了初筛顺序。查下来模型回的是**空字符串**,而失败那次的
out_tokens 正好等于 max_tokens——重排的输出只有一行几十字的 JSON,但模型为了
读完 20 条候选要花 800~1600 个输出 token,顶到上限后正文什么都不剩。llm.py
里对同一个现象早有记录:「思考型模型把额度全花在推理上了,正文是空的」。
所以重排改成有自己的预算(至少 4096),不跟节点上那个走。补跑 16/16 全部成功。
顺带纠正一处判断:thinking=off 救不了这个 provider。实测关思考那组照样在
out_tokens=2048 时空手——factory.py 只在 anthropic 分支里读 thinking 字段,
openai_compatible 整条路径不碰它。仍然传 off,因为对 Anthropic 有效、而且打分
任务本来不需要思考模式,但它不是这次的解药,注释里写明了。
失败提示原来四种坏法统一报「解析不出来」,会把人引去查 JSON 格式,而该调的是
token。现在分开说:空回复 → 「把最大输出 token 调大」;找不到 scores → 带上
原文前 80 字;个数不符 → 说明给了几个、候选几个;混了非数字 → 指出是哪个值。
测试里有一条专门断言空回复的提示中不出现「解析」二字。
This commit is contained in:
@@ -383,3 +383,35 @@ async def test_deleting_a_document_takes_its_index_rows() -> None:
|
||||
after = int((await session.execute(select(func.count(ChunkTerm.id)).where(
|
||||
ChunkTerm.collection == "idx_del"))).scalar_one())
|
||||
assert after == 0, f"文档删了但倒排还留着 {after} 行"
|
||||
|
||||
|
||||
async def test_an_empty_reply_is_not_called_a_parse_error() -> None:
|
||||
"""推理型模型把输出预算花光时正文是空的——实测 deepseek-v4-pro 失败那次
|
||||
out_tokens 正好等于 max_tokens。
|
||||
|
||||
报"解析不出来"会把人引去查 JSON 格式,而该调的是最大输出 token。
|
||||
llm.py 里对同一个现象也是这么说的。
|
||||
"""
|
||||
from app.memory.rerank import rerank
|
||||
|
||||
notes: list[str] = []
|
||||
out = await rerank(_Scorer(""), "问题", _hits(3), top_n=3, on_note=notes.append)
|
||||
assert [h["chunk_id"] for h in out] == ["c0", "c1", "c2"]
|
||||
assert "token" in notes[0] and "调大" in notes[0], notes[0]
|
||||
assert "解析" not in notes[0]
|
||||
|
||||
|
||||
async def test_each_kind_of_bad_reply_says_which_kind() -> None:
|
||||
"""四种坏法要分得开,否则排查时只知道"重排没用上"。"""
|
||||
from app.memory.rerank import rerank
|
||||
|
||||
cases = {
|
||||
'': 'token', # 空回复
|
||||
'随便说点什么': 'scores', # 找不到 scores
|
||||
'{"scores": [1, 2]}': '对不上', # 个数不符
|
||||
'{"scores": ["高", "低", "中"]}': '非数字', # 类型不对
|
||||
}
|
||||
for reply, want in cases.items():
|
||||
notes: list[str] = []
|
||||
await rerank(_Scorer(reply), "问题", _hits(3), top_n=3, on_note=notes.append)
|
||||
assert want in notes[0], f"回复 {reply!r} 给的提示是「{notes[0]}」,认不出是哪种坏法"
|
||||
|
||||
Reference in New Issue
Block a user