Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions nemo_retriever/src/nemo_retriever/llm/clients/judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ def judge(self, query: str, reference: str, candidate: str) -> JudgeResult:
def _parse_judge_response(raw: str) -> JudgeResult:
"""Parse the judge's JSON response into a JudgeResult."""
text = raw.strip()
# Reasoning models can emit a <think>...</think> block before the final JSON.
text = re.sub(r"<think>.*?</think>", "", text, flags=re.DOTALL).strip()

text = re.sub(r"^```(?:json)?\s*", "", text, flags=re.MULTILINE)
text = re.sub(r"\s*```$", "", text, flags=re.MULTILINE)
Expand Down
11 changes: 10 additions & 1 deletion nemo_retriever/src/nemo_retriever/retriever_graph_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,20 @@ def hits_lists_to_rerank_dataframe(
query_texts: list[str],
hits_per_query: list[list[dict[str, Any]]],
) -> pd.DataFrame:
"""One row per (query, hit) with payload to rebuild hits after reranking."""
"""One row per (query, hit) with payload to rebuild hits after reranking.

Returns a DataFrame with the columns ``query``, ``text``, ``_hit`` even when
there are no hits — ``pd.DataFrame([])`` yields a column-less DataFrame,
which crashes the downstream rerank actor with ``KeyError: 'query'`` on a
legitimate empty-results path (empty/unmatched corpus, freshly-ingested
table, etc.).
"""
rows: list[dict[str, Any]] = []
for q, hits in zip(query_texts, hits_per_query):
for h in hits:
rows.append({"query": q, "text": str(h.get("text", "")), "_hit": dict(h)})
if not rows:
return pd.DataFrame(columns=["query", "text", "_hit"])
return pd.DataFrame(rows)


Expand Down
Loading
Loading