LECTURE RESOURCES: Read this lecture in Team-GPT, it is interactive and contains notes and comments from the author.
Constraints are any instructions that cause the model to follow some rules.
Some call these adjustments, others: rules. Phrasing is not too important.
Table of contents
Introduction to Prompting with Constraints
To get a better idea, two of the most common constraints are:
- Adjusting the length and
- Changing tone of voice
Iโll start by providing an article as context. You can see the whole conversation with ChatGPT here.
Using Constraints for Summarization
The goal would be to summarize this article.
Note that summarization is one of the key use cases of ChatGPT.
But the summary is almost as long as the article!
Letโs add a constraint: make it less than 100 words!
We are constraining it to make the text shorter. We are forcing ChatGPT to do so.
And voila! ChatGPT provides!
Adjusting Tone of Voice with Constraints
Another popular constraint (or adjustment) is the tone of voice.
If this is too serious for your purposes, you can always ask ChatGPT to rephrase in a friendly tone of voice.
You now know how to use two types of constraints: length and tone of voice.
Congrats!
Exploring Other Types of Constraints
In reality, you can pose other constraints, too.
Iโll use one of my favorite ones.
Start each word with the same letter: O.
OpenAI officially opens operations in optimal Dublin, Ireland! Obligations include operations, oversight and so on.
Kind of cool, right?
Note that GPT-3.5 fails miserably at this task, while GPT-4 is almost perfect.
This constraint was first shown by Greg Brockman, co-founder of OpenAI, during the official announcement of GPT-4.
Letโs try the letter G. I think Greg did G as well.
Great news! OpenAI is going global, gearing up to grow in Dublin, Ireland!
This one is much harder and you can see that many of the words start with G but not all of them.
In such cases, it could be worth trying to prompt again.
Letโs be super serious:
Every word should start with G.
This is extremely important.
Rephrase the text so that every word start with G! No words should start with anything other than the letter ‘G’.
Goodness gracious, OpenAI’s going global, galvanizing growth in grand Dublin, Ireland. Group’s goals? Guiding operations, governance,
Not bad.
๐ก This lesson is a part of the ChatGPT for Work course
The course is interactive, if you take it inside the Team-GPT platform.
ChatGPT for Work: The Interactive Course contains:
โข 100+ tried and tested prompts
โข 100+ exercises
โข 100+ extra notes and comments
โข 1000s of use cases
โข PDFs files for later reference
It is also completely FREE.
Start today and become a ChatGPT expert in less than 7 days!
Now โwrite a limerickโ. A limerick is a humorous five-line poem with a rhyme scheme. This is a perfect example of a constraint.
In Dublin, OpenAI took its stand, In Ireland’s tech scene so grand. With AI advancement’s lure, Innovation will endure, As OpenAI and Ireland’s growth go hand in hand.
How about a haiku? A haiku is a Japanese poem of seventeen syllables.
OpenAI takes flight, In Dublin’s tech sphere, shines bright, AI’s future ignites.
Beautiful!
Now do a haiku where every word starts with O.
Imperfect because it is becoming extremely hard. If the constraint is too difficult, donโt blame GPT.
At the end of the day, GPT is not only following your rules, but ALSO ensuring it is still making sense!
Wanna have some fun? You can try the same but with emojis only.
Fun but rather pointless, right?
What other constraints are there?
If you have 5 examples of constraints, can you think of a way to find more constraints?
Youโve seen this already: prompting by example.
Try to do this on your own, or check out reading 6.9. Other Constraints.
Over there I have defined the following context:
- Iโm creating an online course about LLMs
- This video script as context
- The whole constraints chat as context, simply copy-pasted. No formatting is needed.
Iโm pretty sure Iโve provided most of the meaningful context there is.
The Goal? What other constraints are there similar to those in the lecture?
There you have them.
There are numerous other constraints or rules that can be applied to guide the generation of responses by ChatGPT. Here are some examples:
Constraint Type | Examples |
---|---|
Formality Level | Generate the sentence in a formal tone. |
Temporal Constraints | Write a paragraph about technology in the 1980s. |
Lexical Constraints | Write a joke without using the word ‘chicken’. |
Genre or Style Constraints | Write a paragraph in the style of Edgar Allan Poe. |
Vocabulary Constraints | Explain quantum physics using only simple words. |
Audience Constraints | Explain the theory of relativity to a 10-year-old. |
Structural Constraints | Write a six-word memoir. |
Language Constraints | Translate the following sentence to French… |
As usual, you can ask for 20 more and so on.
Please do the reading. You donโt have to remember the constraints but it makes sense to know about them.
Thank you