Add grounded information extraction rewards for GRPO#722
Open
ALI-AL-MARJANI wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
GRPO's reward machinery is domain-agnostic — there's no reason to limit it to math. This
PR adds 5 composable reward functions for hallucination-free information extraction via
GRPO.
Core idea: instead of rewarding correct math answers, reward the model for verbatim
citations. Every
extracted_quotemust be an exact substring of the source context. Thiseradicates factual hallucinations at training time.
Output format
{ "reasoning_path": "<chain-of-thought>", "is_context_sufficient": true, "final_answer": "<answer>", "extracted_quotes": [ {"chunk_id": "doc_0", "exact_quote": "<verbatim substring from context>"} ] } New reward functions Reward: grounded_format Signal: Additive JSON schema check — valid JSON → keys → types → quote structure ──────────────────────────────────────── Reward: quote_grounding Signal: exact_quote ∈ context_raw — core anti-hallucination signal ──────────────────────────────────────── Reward: chunk_routing Signal: Quote must come from the correct gold chunk, not a distractor ──────────────────────────────────────── Reward: answer_faithfulness Signal: Token overlap between final_answer and extracted quotes ──────────────────────────────────────── Reward: reasoning_quality Signal: Encourages substantive CoT All functions register in REWARD_FUNCS_REGISTRY. Activate via reward_funcs: [grounded_format, quote_grounding, ...] in any GRPO recipe YAML — zero changes to the training loop. Tests 42 tests, all passing. Covers hallucination detection, correct abstention, partial grounding, batch processing, multi-chunk routing.