Stop Sequences
Last updated
What is Stop Sequences?
Stop sequences are specific strings that signal the LLM to stop generating text when encountered, providing precise control over output length and format. Common examples include newlines, periods, or custom markers like "###" or "END". This parameter is particularly useful for structured outputs, preventing models from generating beyond intended boundaries. Stop sequences are essential for ReAct prompting and other scenarios where you need clean, precisely bounded responses. They offer more control than max tokens by stopping at logical breakpoints rather than arbitrary token limits.
Free resources to learn Stop Sequences
- Official docsHandling Stop Reasons - Anthropic
- ArticleStop Sequence - LLM Parameter Guide - Vellum
More in stage 4: Structured Outputs
Stop Sequences: common questions
Can I learn Stop Sequences in Hindi?
This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain Stop Sequences in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.
Is this Stop Sequences tutorial for beginners?
It is lesson 27 of 46 in the free Prompt Engineering roadmap, in stage 4, Structured Outputs. If you are new to Prompt Engineering, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.