Data & Systems50 minutes

Document Chunker

Repair and extend a document chunker.

Python

Task

Documents are losing their final paragraph when they are prepared for retrieval. Repair the token windows first, add sentence-aware packing, then check that the implementation scales without repeatedly tokenizing the same text. The exact contract and the order of work are in docs/contract.md.

Requirements

  1. Return chunks from chunk_document(text, options), preserving exact character offsets and the original text inside every chunk. Tokens are whitespace-separated spans, not model tokenizer tokens.
  2. Stage 1: keep the final partial token window and reject invalid budgets or overlap. Stop when a window reaches the end.
  3. Stage 2: pack whole sentences greedily. Split a sentence only when it exceeds max_tokens; sentence mode requires zero overlap. Follow the sentence rule in docs/contract.md.
  4. Stage 3: tokenize each region once and keep a running count. Check a large document as well as tiny examples.
  5. Use Python standard-library code in chunker/split.py. Do not change the supplied check cases or rely on network calls.
How you are graded
  • Decomposition 15%
  • Prompting the assistant 15%
  • Verification 20%
  • Judgment about AI output 15%
  • Correctness 25%
  • Communication 10%

Scores use evidence from your session. A short or incomplete session may not provide enough evidence for every skill. See a sample scorecard

Interview guidance

I will ask you to repair the missing text, build sentence packing, and explain its cost. Use the AI assistant, but verify its offsets on the original document.

  • AI is allowed and expected: your own Claude, OpenAI or Gemini key, or the free in-browser model.
  • You are graded on how you drive and check the AI, not on how much you prompt.
  • Run the checks; read what fails.
  • A new requirement will arrive partway through.
  • Too little AI use is reported as “not enough to grade”, never as a fail.
You will answer 7 debrief questions at the end
  • What did you delegate to the AI, and why?
  • Name one AI suggestion you rejected or changed, and why.
  • Choose one block the AI helped write. Explain what each line does and which test verifies it.
  • What is still risky, and what would you test or ship next?
  • How did you check that every chunk points back to the original text?
  • Which operation made the first sentence-packing approach scale poorly?
  • Explain the loop that decides whether a sentence belongs in the current chunk.