Skip to main content
All CollectionsAI Providers & ModelsParameters of GPT Models
Stop Sequence: Understanding & Setting It Correctly
Stop Sequence: Understanding & Setting It Correctly

Learn what Stop Sequences are and how you can use them to generate the perfect output from your prompt.

Promptitude Team avatar
Written by Promptitude Team
Updated over a week ago

When creating prompts using GPT models, stop sequences are a nice trick to guide the model with one or several examples.

In this article, we'll explain what the stop sequences parameter is and how you can set it correctly to get the best results from your GPT model.

Ready? Let's dive in!

What are Stop Sequences?

Stop sequences are specific words, phrases, or characters that signal the model to stop generating text.

The primary purpose of using stop sequences is to control the output length and prevent the model from generating irrelevant or repetitive text.

Think of stop sequences as the brakes for your GPT model: When it encounters a stop sequence, it knows it's time to stop and not generate any more text.

This can be especially helpful when you want your model to generate content within a specific word count or to stop at a logical endpoint.

How to Set the Stop Sequences Parameter Correctly

Now that you understand the purpose of stop sequences, let's discuss how to set this parameter correctly. Here are some simple steps to follow:

1️⃣ Identify the Stop Sequences

First, you need to determine which words or phrases should act as the stop sequences for your GPT model. This will depend on the context and purpose of the text you want to generate.

For example, if you're using the GPT model to generate answers to frequently asked questions, you might want to set the stop sequences as common phrases like "I hope this helps" or "Let me know if you have any more questions".

2️⃣ Input the Stop Sequence

Once you've identified the appropriate stop sequences for your use case, you'll need to input them into the GPT model.

3️⃣ Test and Adjust

After setting your stop sequences, it's essential to test the GPT prompt to make sure it's generating the desired output.

If the model is stopping too soon or not stopping at the appropriate points, you may need to adjust your stop sequences or add more options to the list.

This might require some trial and error, but it's essential to find the right balance to get the best results from your model.

Understanding and setting the stop sequences parameter in GPT models can significantly improve the quality and relevance of the generated text.

By identifying the right stop sequences and inputting them correctly, you can control the output length and ensure your model stops generating text at logical endpoints.

Remember to test and adjust your stop sequences as needed to get the best results.

Happy experimenting!

Did this answer your question?