Stop sequence
Also called stop token, stop words, stop
A piece of text that tells the AI to stop writing as soon as it produces it.
A stop sequence is a string you give to a model API that ends generation when the model outputs it. If the stop sequence is "</answer>", the model stops the moment it writes those characters, and the API returns everything before them. You can usually set several stop sequences at once.
Stop sequences are a precise way to control where output ends. They are useful when you want exactly one item from a pattern that could repeat, such as one answer in a Q&A format, or when you ask for output inside tags and want nothing after the closing tag. Combined with prefilling, they let you frame a response tightly: you write the opening, the model fills the middle, the stop sequence ends it.
They are less necessary than they once were. Modern instruction-tuned models usually stop on their own when the task is done, and structured output features handle many formatting needs. Stop sequences remain handy for templates, extraction and older completion-style APIs.
Example
A prompt lists questions as "Q:" and answers as "A:". To get only one answer, the developer sets "\nQ:" as a stop sequence. The model writes its answer and stops before inventing a follow-up question.
Common mistake
Choosing a stop sequence that can appear naturally inside the answer. Stopping on "." cuts the reply after the first sentence; stopping on "Note" ends any answer that uses that word. Pick sequences that only appear at the boundary, such as a closing tag.