Skip to content

fix(generation): ground v1 exercises in the module that teaches them - #79

Merged
JoseEstevez520 merged 1 commit into
mainfrom
hotfix/grounded-exercises
Oct 14, 2026
Merged

JoseEstevez520 merged 1 commit into
mainfrom
hotfix/grounded-exercises

Conversation

@JoseEstevez520

Copy link
Copy Markdown
Collaborator

Testers reported exercises that don't match the module's lessons: a question about a fact the module never explained.

Two causes, both in v1 generation:

  • Every module was handed the whole source document. _module_context loaded all chunks and then ran a similarity search that could add nothing, since each hit was already in the map. A module could write a question about any section. It now retrieves chunks for its own title and summary, and only falls back to the full document if embeddings are unavailable.
  • Neither the generator nor the reviewer prompt asked for the question to be answerable from the lessons. Both now say so, and an unexplained question counts as critical in review.

I also drop exercises whose answer key can't be graded (correct index out of range, blank count that doesn't match, an order that isn't a permutation). An unpassable exercise blocks the whole course, so dropping it is the lesser failure. It logs a warning.

Testing:

  • 16 new tests, and the unit suite passes (4354 passed). test_llm_client.py::test_a_model_whose_thinking_is_opt_in_is_left_alone fails the same way on main.
  • Generated one course from a six-section document with deepseek-chat on main and on this branch, and had the same model check each exercise against its module's lessons. Both came out at 0 unanswerable (30 and 34 exercises). That document is short and goes through the full-text path, so it doesn't exercise the per-module retrieval. I couldn't test that path: it needs a real embedding model.

Backport to develop after release.

The v1 generator and reviewer only anchored questions to the source,
so an exercise could quote any fact of the document whatever the
module covered. Add an alignment rule to both prompts, scope each
module's context to its own material instead of the whole document,
and drop exercises whose answer key cannot be graded (out-of-range
correct, mismatched blanks, non-permutation order) so an unpassable
exercise never ships.
@JoseEstevez520
JoseEstevez520 merged commit cf2fa52 into main Oct 14, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant