Rewrite & re-measure
# grade this stage (from your course directory)
npx theinference test --stage rewrite-recall --watchImplement the deterministic rewrite and re-measure. Embed the rewritten queries, recompute recall@5, and confirm it does not drop versus the raw question — the honest, measurable version of "does rewriting help?"
What to build
Implement rewriteQuery
Implement rewriteQuery(question): normalize, strip punctuation, drop stopwords (the shipped stopword list), and join the remaining content words with single spaces. The rewrite-recall <k> command retrieves with both the raw and rewritten queries and prints {rawRecall, rewrittenRecall}.
export function rewriteQuery(question: string): string {
// normalize -> strip non-alphanumeric -> split on spaces
// -> drop STOPWORDS and empties -> join with " "
}
./your_program.sh rewrite-recall 5
# -> { rawRecall, rewrittenRecall } (rewritten >= raw)
process mode, stdout_json_match. Both recall numbers must match the frozen reference exactly. The rewritten-query recall must not regress below the raw-query recall — that's the measurable claim.
Your rewriteQuery must produce the exact reference string (the stopword list and normalization are shipped) so its embedding matches. A free-form rewrite would be ungradeable — that's the whole reason we don't use an LLM here.