WRITE · TRACE · UNDERSTAND
Stop token decoding across chunk boundaries
chunks and stops are lists of nonnegative integer-token lists; stop sequences cannot be empty.
Read lesson: Stop token decoding across chunk boundaries →
Your experiment
chunks and stops are lists of nonnegative integer-token lists; stop sequences cannot be empty. Consume chunks incrementally, retaining output across chunk boundaries. After each token, first check complete stop suffixes and remove the longest matching stop; otherwise stop when output length reaches integer max_tokens>=0. Return tokens, reason (stop,budget,eof), consumed. Stop tokens count as consumed. A hard budget may expose an incomplete stop prefix; this contract does not promise prefix buffering.
Python runs in your browser. Your draft stays on this device.
What to look for
Review overlapping stops, chunk splitting, budget precedence and incomplete prefixes. Token identities are fixtures; no model tokenizer or network stream is claimed to run here.
Watch your code work
Ready to experimentWrite a solution or load the worked answer, then choose Trace & check.
Step through arrays, variables and training curves produced by your own Python.
