L03

W03–W04 · 7 hours · complete online handout

Retrieval & reranking sandbox

Research question

Which stage changes when retrieval quality changes?
Download offline package
01

Contract

What this lab must demonstrate

  • Run or inspect sparse, dense, hybrid, and rerank stages.
  • Compute Recall@k and NDCG@k.
  • Produce topic-level error analysis and a bounded ablation.

Prerequisites

  • W03–W04 bridge notes.
  • Python 3.10+ for the core script; supplied outputs support analysis-only completion.
Equivalent low-compute route

Use supplied TREC run files and complete all metric, ablation, and error-analysis work without a model download.

02

Milestones

Four reviewable checkpoints

The windows are planning budgets, not hidden grading criteria. Pause at every gate; do not compress a failed check into the final submission.

  1. 01

    Verify the retrieval fixture

    Work
    Check corpus rights, hashes, topics, qrels, frozen dense-run metadata, environment, and metric cutoffs before running.
    Checkpoint evidence
    Validated input manifest and declared numerical tolerance.
    Advance only when
    Stop if rights, qrel provenance, or train/test separation are unknown.
  2. 02

    Reproduce four stages

    Work
    Run or inspect BM25, frozen dense, normalized hybrid, and fixed-candidate reranking while keeping candidate generation, ordering, and packing distinct.
    Checkpoint evidence
    Four run files and a stage-boundary record.
    Advance only when
    The reranker introduces no document outside the frozen candidate set.
  3. 03

    Measure and ablate

    Work
    Compute topic-level and macro Recall@k/NDCG@k, reproduce fixtures within tolerance, then alter exactly one declared factor.
    Checkpoint evidence
    Metrics table, deltas, and single-factor ablation.
    Advance only when
    Negative metric changes are retained rather than tuned away.
  4. 04

    Diagnose and bound

    Work
    Inspect at least five topic failures and classify candidate misses, ordering errors, incomplete judgments, or representation mismatch.
    Checkpoint evidence
    Error taxonomy, accessible chart/table, and bounded interpretation.
    Advance only when
    Retrieval gains are not described as citation, answer-quality, absorption, referral, or production-visibility gains.
03

Validation

Checks, pass gate, and assessment

Run-file format and topic coverage pass.

Metrics match fixtures within tolerance.

Candidate and reranking stages remain distinguishable.

The ablation changes one named factor.

Every chart has source data and a text alternative.

Pass gate

Metrics reproduce within declared tolerance and candidate-generation effects are never described as generation or citation effects.

L03 Rubric — 100 points

Rendered from the canonical package rubric. Source SHA-256: 38f4dbaecee8f66f6c5f83d759ef93f28bc582edae28b2dd3bba94cdffa19c40.

L03 canonical 100-point assessment rubric
CriterionPointsFull-credit evidence
Frozen task and provenance15Corpus, topics, qrels, run provenance, licenses, versions, and hashes are explicit.
Baseline reproduction20BM25 and supplied-run metrics reproduce within the declared tolerance.
Hybrid and reranking design20Normalization is documented; reranking uses an invariant candidate set; parameters are logged.
Metric correctness15Recall/NDCG denominators and treatment of unjudged records are correct and explicit.
Topic-level error analysis20At least one ablation and individual failures, including negative deltas, are explained by stage.
Boundary and ethics10Retrieval claims are not inflated into generation or production effects; rights and held-out rules are respected.

Hard fail pending remediation: qrel/topic changes after result inspection, hidden model/API use, copyrighted corpus redistribution without permission, held-out leakage, or a retrieval score reported as a citation/generation/visibility effect.

Pass threshold: 70/100 and no hard-fail condition.

04

Handout

Complete browser-readable lab handout

Generated from the same controlled README shipped in the offline package. Source SHA-256: 0da5072fe24091bbb34245dc7e61ce1cdcad950f7ea5d389887687f8dc32e750.

On this page 10 sections

Linked course weeks: W03–W04
Expected effort for the full assignment: 7 hours
Core path: offline, deterministic, Python standard library only

Research question

Which stage changes when retrieval quality changes—and which downstream claims remain untested?

Learning objectives

You will learn to:

  1. distinguish first-stage candidate generation, score fusion, fixed-set reranking, context selection, and generation;
  2. reproduce BM25, frozen-run, hybrid, and reranked lists over one immutable corpus;
  3. compute topic-level and macro Recall@k and NDCG@k with explicit qrels;
  4. diagnose missed relevant documents and non-monotonic metric changes; and
  5. state why retrieval results do not establish citation, answer quality, absorption, referral, or production visibility.

Input contract

  • data/corpus.jsonl: ten synthetic documents following ../shared/schemas/document.schema.json.
  • data/topics.jsonl: stable topic_id and exact query text.
  • data/qrels.tsv: topic_id, doc_id, and integer relevance >= 0; unlisted pairs are unjudged/treated as zero only inside this closed fixture.
  • data/frozen_dense_run.tsv: frozen topic_id, doc_id, and score records.
  • data/frozen_dense_run_metadata.json: declares that the supplied run is a synthetic, opaque teaching fixture. It is not evidence from a named embedding model.

All fixtures are CC0 synthetic. Do not replace them with scraped documents unless license, redistribution, privacy, and temporal provenance have been reviewed.

Run

python3 scripts/run_sandbox.py \
  --corpus data/corpus.jsonl \
  --topics data/topics.jsonl \
  --qrels data/qrels.tsv \
  --dense-run data/frozen_dense_run.tsv \
  --dense-metadata data/frozen_dense_run_metadata.json \
  --output /tmp/geo-l03 \
  --k 3 --candidate-depth 5 --hybrid-alpha 0.55 --rerank-weight 0.25

BM25 uses k1=1.2, b=0.75, lowercase English-oriented tokenization, and Robertson-style IDF. Hybrid scores are per-topic min–max normalized before interpolation. The transparent reranker rewards query-token and adjacent-token coverage only inside the fixed hybrid top five. It is a teaching function, not a learned production reranker.

Output contract

Table from the controlled L03 lab handout
ArtifactContract
runs/*.tsvranked lists for bm25, frozen_dense, hybrid, and reranked
metrics.jsonper-topic and macro Recall@k/NDCG@k, with denominator policy
topic_error_analysis.csvrelevant, retrieved-relevant, and missed IDs for every topic/method
metric_deltas.csvchange relative to BM25; negative values are retained
stage_boundary.jsonstages manipulated, held fixed, and not evaluated
run_manifest.jsonhashes, parameters, and deterministic/offline flags

A successful run may show that a method gets worse. Never alter qrels, topics, or the held-out split after observing a metric.

Full assignment procedure

  1. Verify corpus license, snapshot date, topic set, qrels, and environment before running.
  2. Reproduce all supplied baseline metrics within a declared numerical tolerance.
  3. Compare topic-level lists before reading the macro score.
  4. Build a hybrid run only after documenting score normalization.
  5. Rerank a fixed candidate set and prove no new document entered it.
  6. Run one ablation: remove dense scores, change fusion weight, or remove the reranker feature.
  7. Classify each error as candidate miss, ordering error, incomplete judgment, or representation mismatch.
  8. Submit run files, environment record, metric table, ablation chart, and bounded interpretation.

Low-compute and no-network route

Use the supplied frozen dense scores and analyze them without downloading a model. BM25 and all metrics run in milliseconds on one CPU. An optional real dense route belongs in a separate environment lock and must preserve the same corpus/topics/qrels; it is not required for core completion.

Negative results and interpretation

  • A lower NDCG after reranking is a valid result and should trigger topic-level diagnosis.
  • Higher Recall@k with lower NDCG@k can mean more relevant candidates but worse ordering.
  • Missing qrels make unjudged documents ambiguous; this closed fixture simplifies them to zero and records that policy.
  • The opaque frozen run cannot support a claim about any named encoder or current product.
  • Retrieval metrics do not measure whether answer text cites, entails, absorbs, or sends traffic to a source.

Ethics and stop conditions

Do not redistribute copyrighted corpora, infer personal interests from query logs, or issue automated live-product requests. Stop if corpus rights, qrel provenance, or train/test separation are unknown. Never optimize against a held-out topic after inspecting its results.

Acceptance

python3 scripts/run_sandbox.py --corpus data/corpus.jsonl --topics data/topics.jsonl --qrels data/qrels.tsv --dense-run data/frozen_dense_run.tsv --dense-metadata data/frozen_dense_run_metadata.json --output /tmp/geo-l03 --k 3 --candidate-depth 5 --hybrid-alpha 0.55 --rerank-weight 0.25
python3 -c 'import json; m=json.load(open("/tmp/geo-l03/metrics.json")); assert set(m["methods"]) == {"bm25","frozen_dense","hybrid","reranked"}'

See RUBRIC.md.

05

Execute

Use one source of executable truth

Ethics and stop condition

Use the licensed synthetic corpus only; do not scrape or redistribute restricted sources.

Optional extension

Pin and run one Pyserini or BEIR route, recording commit, dataset license, environment, cost, and deviations.

The page is the complete reading and planning surface. The versioned package README and scripts remain authoritative for exact local commands, filenames, fixtures, and validation behavior.