Skip to content

fix: NameError 'has_reranker' in e2e-rag single-shot result display - #2667

Open
Anai-Guo wants to merge 1 commit into
mlcommons:masterfrom
Anai-Guo:fix-e2e-rag-has-reranker
Open

fix: NameError 'has_reranker' in e2e-rag single-shot result display#2667
Anai-Guo wants to merge 1 commit into
mlcommons:masterfrom
Anai-Guo:fix-e2e-rag-has-reranker

Conversation

@Anai-Guo

@Anai-Guo Anai-Guo commented Sep 9, 2026

Copy link
Copy Markdown

Problem

evaluate_retrieval_query() in e2e-rag/evaluation.py references an undefined
name has_reranker when displaying results:

# Show reranked results if reranker is available and reranking was used
if not no_rerank and has_reranker:   # <-- has_reranker is never defined

has_reranker is not defined anywhere in the function. This branch is guarded by
if print_results:, and single_shot_retrieval.py calls the function with
print_results=True and the default no_rerank=False:

eval_output = evaluate_retrieval_query(
    rag_db, args.query, expected_urls=[],
    ...
    no_rerank=getattr(args, 'no_rerank', False),
    ...
    print_results=True,
    ...
)

So any single-query lookup that runs with reranking enabled raises
NameError: name 'has_reranker' is not defined right where it should be printing
the reranked results.

Fix

Reuse the exact reranker-availability check the same function already performs
earlier (Step 2, ~line 144):

if not no_rerank and hasattr(rag_db, '_reranker_model') and rag_db._reranker_model is not None:

One-line change, no behavior change beyond removing the crash.

🤖 Generated with Claude Code

evaluate_retrieval_query() references an undefined name has_reranker when
print_results=True. single_shot_retrieval.py calls it with print_results=True
and the default no_rerank=False, so any single-query lookup with reranking
enabled raises NameError before printing reranked results.

Use the same reranker-availability check already used earlier in the same
function (around line 144) instead of the undefined variable.

Signed-off-by: Tai An <antai12232931@outlook.com>
@Anai-Guo
Anai-Guo requested review from a team as code owners September 9, 2026 13:04
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

MLCommons CLA bot:
Thank you very much for your submission; we really appreciate it. Before we can accept your contribution,
we ask that you sign the MLCommons CLA (Apache 2). Please submit your GitHub ID to our onboarding form to initiate
authorization. If you are from a MLCommons member organization, we will request that you be added to the CLA.
If you are not from a member organization, we will email you a CLA to sign. For any questions, please contact
support@mlcommons.org.
0 out of 1 committers have signed the MLCommons CLA.
@Anai-Guo
You can retrigger this bot by commenting recheck in this Pull Request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant