Skip to content

feat(rag): constrain groundedness judgments with response schemas #1629

Closed as not planned

Description

@planetf1

Problem

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.

Activity

  1. Akshat977 commented on Sep 23, 2026

    @Akshat977
    Contributor

    @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?

  2. self-assigned this
    on Sep 23, 2026
  3. planetf1 commented on Sep 23, 2026

    @planetf1
    ContributorAuthor

    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

  4. planetf1 commented on Sep 24, 2026

    @planetf1
    ContributorAuthor

    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.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions