You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(rag): constrain groundedness judgments with response schemas #1629
Groundedness necessity and support judgments are generated as unconstrained JSON and then repaired defensively. This has required repeated parser hardening for malformed field types, labels, and identifiers.
Proposed approach
Define strict Pydantic response schemas for citation-necessity and citation-support judgment arrays.
Pass the schemas through format= in both judgment calls.
Add LocalHF/llguidance coverage for constrained decoding and unit coverage that both calls pass the expected format.
Retain fail-closed parser behaviour for malformed or unsupported responses, and retain conservative handling for duplicate span identifiers.
Acceptance criteria
Both judgment calls use explicit response schemas.
The LocalHF structured-output path is covered.
Existing parser safety behaviour remains covered for malformed output and duplicate span IDs.
@planetf1 I'd like to take this one. Checked main: _identify_citation_necessity and _assess_citation_support in mellea/stdlib/requirements/rag.py don't pass format= yet, so the defensive parsers are still the only guard. Plan: Pydantic schemas for both judgment arrays passed via format=, LocalHF/llguidance coverage for the constrained path, unit tests that both calls pass the expected schema, and the existing parsers kept as the fail-closed fallback for backends without structured output. One open question — for span identifiers, would you prefer a static schema, or building it per call so IDs are restricted to the spans actually present?
Thanks @Akshat977 - I took an initial look again at what is specced out above, and it needs some refinements/rework. I'll aim to post an update with clarifications by tomorrow
Closing this in favour of #1669, which removes the two prompts rather than constraining their
output.
The premise here was that the judgment parsers have needed repeated hardening, with response
schemas as the fix. Two things changed on review.
The recurring defect is not malformed shape as such. It is that an unreadable judgment becomes
a confident "not grounded" verdict in silence, which the repair loop then feeds back to the
model, so a correct answer gets rewritten. Schemas would narrow one route into that state and
leave the silence intact. Also, one of the three fixes cited here, #1614, I found by reading
code rather than from a failing run, so the "repeated hardening" premise was weaker than it
read.
More to the point, the two judgments do not need a prompt at all. The published hallucination_detection adapter answers both of them in one call: its output enum is faithful, partial, unfaithful, NA, where the first three map onto our three support
levels and NA ("does not contain factual claims that require grounding") is the citation
necessity judgment. Verified from io.yaml at the revision the catalogue pins, identical
across granite-4.0-micro, 4.1-3b, 4.1-8b and 4.1-30b. mellea already wraps it as flag_hallucinated_content and never calls it.
So the prompts and parsers a schema change would have hardened are the code #1669 deletes.
Nothing from the analysis here is lost: #1669 carries the silent-verdict problem, the
fail-closed reporting, and the coverage check that stops an incomplete adapter answer being
filled in with defaults.
Activity
Akshat977 commentedon Sep 23, 2026
@planetf1 I'd like to take this one. Checked main:
_identify_citation_necessityand_assess_citation_supportinmellea/stdlib/requirements/rag.pydon't passformat=yet, so the defensive parsers are still the only guard. Plan: Pydantic schemas for both judgment arrays passed viaformat=, LocalHF/llguidance coverage for the constrained path, unit tests that both calls pass the expected schema, and the existing parsers kept as the fail-closed fallback for backends without structured output. One open question — for span identifiers, would you prefer a static schema, or building it per call so IDs are restricted to the spans actually present?planetf1 commentedon Sep 23, 2026
Thanks @Akshat977 - I took an initial look again at what is specced out above, and it needs some refinements/rework. I'll aim to post an update with clarifications by tomorrow
planetf1 commentedon Sep 24, 2026
Closing this in favour of #1669, which removes the two prompts rather than constraining their
output.
The premise here was that the judgment parsers have needed repeated hardening, with response
schemas as the fix. Two things changed on review.
The recurring defect is not malformed shape as such. It is that an unreadable judgment becomes
a confident "not grounded" verdict in silence, which the repair loop then feeds back to the
model, so a correct answer gets rewritten. Schemas would narrow one route into that state and
leave the silence intact. Also, one of the three fixes cited here, #1614, I found by reading
code rather than from a failing run, so the "repeated hardening" premise was weaker than it
read.
More to the point, the two judgments do not need a prompt at all. The published
hallucination_detectionadapter answers both of them in one call: its output enum isfaithful,partial,unfaithful,NA, where the first three map onto our three supportlevels and
NA("does not contain factual claims that require grounding") is the citationnecessity judgment. Verified from
io.yamlat the revision the catalogue pins, identicalacross granite-4.0-micro, 4.1-3b, 4.1-8b and 4.1-30b. mellea already wraps it as
flag_hallucinated_contentand never calls it.So the prompts and parsers a schema change would have hardened are the code #1669 deletes.
Nothing from the analysis here is lost: #1669 carries the silent-verdict problem, the
fail-closed reporting, and the coverage check that stops an incomplete adapter answer being
filled in with defaults.