Decoding & Sampling

stop sequences

A stop sequence is a string you nominate that tells generation to halt the instant the model produces it. The text up to that trigger is returned and the trigger itself is usually trimmed off. It is the punctuation mark of an API call: a way to say 'stop here' without relying on the model to know where 'here' is. Common choices are a newline, a closing tag, or a role marker like the name that begins the next speaker's turn in a chat transcript.

Stop sequences keep a model from rambling past the answer, prevent it from hallucinating both sides of a dialogue, and carve clean boundaries in structured formats. They work in tandem with the model's own end-of-sequence token, which signals a natural finish; a stop sequence is the external, application-defined cut. The pitfalls are mostly about choosing the trigger badly — too common a string and you sever output mid-thought; pick one the model legitimately needs to write and it can never produce it.

Also called
stop tokensstop strings