Build your own RAG pipeline
The answer-span oracle·4 min

The answer-span oracle

0 / 1

Here's the trick the whole course hinges on. Because the gold answer is a verbatim span of its paragraph, "the assembled context could answer this" reduces to context.includes(goldAnswer) — a boolean. No model judges it. The metric is hit-rate@k: the fraction of questions where at least one retrieved top-k chunk contains the gold span.

Worked example
goldAnswer: "1887"
top-5 chunk texts include: "...Construction ... began in 1887 and was completed in 1889..."
  -> the span "1887" is present  ->  HIT
Normalize before you match

Substring matching needs normalization or the United States vs the United States misses. The spec pins it: text.toLowerCase().replace(/\s+/g, " ").trim() on both sides before includes. Use the provided normalize.