A practice prompt we wrote. No company or candidate report names it, so it carries no company tag.
How to answer
The easy chunker splits every N characters and patches structure afterward. This question asks for the reverse: parse the structure first, and let size decide only where structure allows a cut. Say that in the first minute.
- Pin the contract. “Input is Markdown. Output is chunks, each with its heading path and text, under a size limit measured in the model’s tokens. A table is never cut. A heading never ends a chunk and never gets separated from the text under it.” Ask what should happen when one table alone is over the limit; that answer changes the code.
- Parse into blocks before any sizing. Headings, fenced code, tables, paragraphs. Fences come first, because a
#inside a code block is a comment, not a heading. A table is a pipe row followed by a delimiter row such as| --- |. - Pack blocks greedily, section by section. A heading closes the current chunk and updates the path. Within a section, add blocks until the next one would overflow, then start a new chunk.
- Handle the oversize cases on purpose. A long paragraph gets split into overlapping word windows. A table or code block over the limit goes out whole, alone, and flagged, so someone can see it rather than have it silently cut.
- Say where overlap is allowed. Overlap repeats the tail of a paragraph, never a table, and never crosses a heading.
The trap is overlap and size logic written before structure. Those produce chunks that pass a length test and retrieve badly. The structure-aware chunker drill runs this against hidden tests.
Follow-ups
What the interviewer may ask next, once your first answer is on the table.
- One table is bigger than the whole limit. What do you emit, and who finds out?
- How do you measure size so it matches what the embedding model will see?
- Why does the heading path go into the chunk text instead of only into metadata?
- The customer’s documents are PDFs, not Markdown. Which part of your code survives?
Where answers go wrong
- Splitting on character count first and patching structure in afterward, so a table row lands in two chunks and a heading ends up as the last line of the chunk before its section.
- Treating a line that starts with a hash inside a code block as a heading.
- Adding overlap by repeating the tail of the previous chunk even when that tail is half a table.
Answer this in two minutes
Write the answer you would say out loud. The clock starts with your first word.
Model answer
“I’ll parse Markdown into blocks, then pack blocks into chunks under a limit. Size is a function I pass in: word count while I write it, the embedding model’s tokenizer in production, because that is the limit that matters.