Open
【11月贡献大赛-缺陷修复】fix/docs: deduplicate Recall@k hits in eval_retrieval.py (#4106) #7331
Sophie LeeAdd on 4 hours ago
【11月贡献大赛-缺陷修复】fix/docs: deduplicate Recall@k hits in eval_retrieval.py (#4106) #7331
Open
Merge blocked
ascend-robot
4 hours ago Comments:
4 hours ago Comments:
Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
PR Approval Progress
⚠️ This PR does not yet meet the following requirements:lgtm (requires ≥ 2 person(s) per module)、approve (requires ≥ 1 person(s) per module)
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| sig-model-agent | ❌ (0/2)(You can also ask: 顾梦沁, 林泽毅, 刘磊, shaos-governance, 花新宇) | ❌ (0/1)(You can also ask: 焦泽昱, 陈少宏, 顾梦沁, 刘磊, 王岩) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
DoubleCore, thanks for your pull request. All authors of the commits have signed the CLA. 👍


Sophie Lee
4 hours ago Comments:
4 hours ago Comments:
/label add bug


4 hours ago Added label: ascend-cla/yes
Sophie Lee
4 hours ago Comments:
4 hours ago Comments:
/label add fix


Sophie Lee
4 hours ago Comments:
4 hours ago Comments:
/label add document


Sophie Lee
4 hours ago Comments:
4 hours ago Comments:
/check-cla


4 hours ago Removed label: ascend-cla/yes
4 hours ago Added label: ascend-cla/yes
ascend-robot
4 hours ago Comments:
4 hours ago Comments:
CLA检查已通过,详情可参考这里


Fixes #4106
问题与根因
skills/deployment/npu-embedding-retrieval/scripts/eval_retrieval.py中evaluate()使用列表推导hits = [doc for doc in ranked if doc in rel_set]统计前k名命中的相关文档,当排名结果中同一相关文档 ID 重复出现时(如多路召回合并或同文档多片段切分场景),len(hits)会重复计数而分母len(rel_set)按唯一相关文档数计算,导致recall@k超过1.0(例如单相关文档重复出现时输出2.0)。改动说明
skills/deployment/npu-embedding-retrieval/scripts/eval_retrieval.py:evaluate()中改用集合推导hits = {doc for doc in ranked if doc in rel_set}对前k名命中文档按 ID 去重;ranked = (runs.get(q) or [])[:k]的原始切片口径,重复项占据的原始名次保留、k以外的命中不向前补位,且同时兼容缺失/None排名输入;MRR、Hit Rate@k语义及输出格式保持不变。skills/deployment/npu-embedding-retrieval/references/retrieval_eval_guide.md:Recall@k前k名去重及不补位口径说明。skills/deployment/npu-embedding-retrieval/tests/test_eval_retrieval.py:本地验证结果
在
G:\openatom\wt-agy-4106(CPU 离线环境,纯 Python 标准库)执行:python -m pytest -v skills/deployment/npu-embedding-retrieval/tests/test_eval_retrieval.py->6 passed in 2.54spython -m unittest -v skills/deployment/npu-embedding-retrieval/tests/test_eval_retrieval.py->Ran 6 tests in 2.844s (OK)['d', 'x']与['d', 'd']在k=2下均输出recall@k: 1.0, mrr: 1.0, hit_rate@k: 1.0。