Milestone 7 of 8

Inspect, save, and replay the dataset

Decode explicitly selected examples, save arrays and exact plot data, read artifacts back, and replay the dataset in a separate directory.

Saved arrays become useful when another reader can explain a selected row and rebuild the same result without the editor's current state.

Goal

Inspect selected composite identities, save all required artifacts, read them back, and replay the dataset in a separate directory.

Inputs

Use the validated inputs, complete table, group arrays, batches, and the version-matched decoder. Select rows by explicit (document_id, target_position), not by whichever rows happen to be nearby after generation.

For each selected row display document ID, target position, unpadded context tokens, target token, padded IDs, and mask. An <unk> remains <unk>; do not guess source text. Use the decoder only to inspect token strings. The saved IDs and masks are the primary evidence.

Deliverables

Extend src/inspect.py and src/main.py to save:

  • output/examples_metadata.csv and per-group NumPy archives;
  • output/group_summary.csv and output/batch_manifest.json;
  • deterministic selected-example records;
  • example-count, real-context-length, and group/batch-count figures with exact plot data;
  • output/sequence_dataset_manifest.json; and
  • a replay agreement or mismatch record under output/replay/.

The manifest records source, tokenizer, configuration, group-assignment, artifact, and implementation identities. Replay must not overwrite the original output.

Checks

Read every artifact back and check schemas, shapes, dtypes, identities, counts, spans of history, masks, groups, batches, and plot data. Replay from saved configuration and source identity in a distinct directory and compare the complete table, group indexes, arrays, batches, and figures.

Deliberately change one source identity, context width, group assignment, vocabulary ID, or batch policy and check that replay reports the first mismatch. Confirm the original output remains unchanged. Check selected unknown-containing rows are visibly unknown and not reconstructed as invented text.

Workspace

Keep original artifacts under output/ and replay artifacts under output/replay/. Keep the manifest and dataset card at stable project paths.

Hints

HintReplay in contract order
Compare identity, documents, examples, groups, arrays, batches, and figures in that order.
HintPlot data is evidence
A plot must point to saved counts and identities, not perform an undocumented second data pass.

Review

Open one original and replayed selected row side by side. State what exact agreement establishes for this corpus and configuration, and what it cannot establish about training or model quality.

How to check your work

Checks compare manifest fields, read-back schemas, selected rows, and replay results with the supplied fixture. A mismatch must remain visible.