Repository navigation
fix: GroundedProposer ignores hand-labeled demos (sub-issue 4 of #9938) - #9979
shadowmodder wants to merge 1 commit into
Conversation
gather_examples_from_sets in GenerateModuleInstruction.forward() filtered examples with `if "augmented" in example.keys()`, but the "augmented" key is only set on bootstrapped demos (BootstrapFewShot line 226). Hand-labeled examples from the training set carry no such key, so they were silently skipped. When max_bootstrapped_demos=0 and only labeled demos exist, task_demos always collapsed to "No task demos provided.", giving MIPROv2's instruction proposer zero context about the actual task. Remove the guard so both bootstrapped and labeled demos are yielded. Add a regression test that constructs labeled-only demo_candidates at demo_set_i=1 (bypassing the demo_set_i==0 shortcircuit) and asserts the labeled example text appears in the prompt sent to the proposer LM. Fixes sub-issue 4 of stanfordnlp#9938.
Greptile SummaryThis PR fixes a silent filtering bug in
Confidence Score: 5/5Safe to merge — the change removes a single misguided guard that was silently discarding valid input, and the rest of the forward method is untouched. The fix is a targeted one-line deletion backed by a clear root-cause analysis. The num_demos_in_context cap that previously applied only to bootstrapped examples now applies uniformly, so there is no risk of unbounded context growth. The regression test is well-constructed, properly bypasses the unrelated demo_set_i==0 shortcircuit, and directly asserts both the presence of example text and the absence of the fallback string in the final LM prompt. No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "fix: include hand-labeled demos in Groun..." | Re-trigger Greptile |
|
This still merges cleanly against main and fixes sub-issue 4 of #9938. Could a maintainer take a look when there is time? Happy to rework it if the approach is off. |
Summary
Closes sub-issue 4 of #9938 (MIPROv2 crashes / produces wrong results when
max_bootstrapped_demos=0).The bug
GenerateModuleInstruction.forward()contains a nested helpergather_examples_from_setsthat filters candidate examples with:The
"augmented"key is only ever set on bootstrapped demos (seeBootstrapFewShot._bootstrap_one_example, which doesdspy.Example(augmented=True, ...)). Hand-labeled examples from the training set are appended topredictor.demosas plaindspy.Exampleobjects with no"augmented"key.Concrete consequence: when
max_bootstrapped_demos=0and only labeled demos exist indemo_candidates,gather_examples_from_setsyields nothing,task_demosis an empty string, and the fallback fires:The instruction proposer LM is given zero task context even though the caller explicitly provided labeled examples.
The fix
Remove the
"augmented"guard so the function yields all examples — both bootstrapped and hand-labeled. Both are equally valid as context for instruction proposal. The one-line removal is the entire change to production code.Verification
Added
test_labeled_demos_included_in_task_demosintests/propose/test_grounded_proposer.py:demo_candidatescontaining only labeled examples (no"augmented"key)demo_set_i=1to bypass thedemo_set_i == 0shortcircuitAll 5 tests in
tests/propose/test_grounded_proposer.pypass.Before fix:
gather_examples_from_setsyields 0 examples for labeled-only demo sets.After fix: yields the rendered example string (e.g.
"Question: What is 2+2?\nAnswer: 4").This is one of four sub-issues in #9938; sub-issue 1 (randrange crash) was addressed by #9939.