Clear Instructions and Context
Learning Objectives
- You understand how to provide clear, specific instructions that guide model behavior.
- You can use context to direct model outputs toward desired topics and styles.
- You know how to employ personas and audience targeting to shape response characteristics.
The importance of clarity
Clear instructions are key to effective prompting. When instructions are specific, concise, and unambiguous, the model can better understand what you want and generate more relevant outputs. Vague or ambiguous instructions often lead to unpredictable or unsatisfactory results.
Specifying output characteristics
Even simple constraints can impact outputs. Consider these two prompts asking for the same information:
What is the capital of Finland? Answer using one word.
Helsinki.
What is the capital of Finland? Answer using one sentence.
The capital of Finland is Helsinki.
The only difference is whether we ask for “one word” or “one sentence,” yet the outputs differ substantially in structure and completeness.
Using context effectively
Context provides background information that helps the model understand the situation, domain, or constraints within which it should operate. Effective contextualization can direct the model toward specific interpretations, styles, or knowledge domains.
Temporal context
Context can specify time periods, changing what information is relevant:
The year is 1800. In one word, what is the capital of Finland?
Turku.
Without the temporal context, the model would respond with Helsinki, the current capital. The year 1800 shifts the context to when Turku was Finland’s capital.
Building context iteratively
Let’s explore how adding context progressively shapes outputs. We start with a basic request:
Hi! Please write a short three paragraph story for children.
The Adventure of Luna the Star
In a far corner of the night sky, Luna, a tiny twinkling star, wished to be as bright as the moon. Every night she tried her best to shine brighter, but she felt lost among the vastness of the universe. One evening, a friendly comet named Cosmo noticed Luna's efforts and whispered a secret: "Brightness isn't about how much light you give off, but the warmth you bring to others."
Cosmo invited Luna on a journey across the universe, showing her galaxies, nebulas, and distant worlds. Everywhere they went, Luna listened to the stories of the stars and spread joy with her twinkling light. She danced with the northern lights, played hide and seek with meteors, and told bedtime stories to young stars.
By the time they returned, Luna realized that she was surrounded by a galaxy of friends, all of whom were warmed by her kind heart. The moon, impressed by Luna's journey, smiled and said, "You might not be the brightest, but you sure are the warmest." And every night thereafter, Luna beamed with happiness, knowing that it was the love she spread that truly made her shine.
Now add thematic context — the story should be about a child learning magic:
Hi! Please write a short three paragraph story for children. The story should be about a child who learns magic.
The Little Magician
Once upon a time, in a cozy village nestled between rolling hills, lived a curious child named Lila. Lila always felt a deep connection to the world around her, as if there were secrets whispered by the wind and tales murmured by the streams. One day, while wandering in the forest, she stumbled upon an ancient, glowing book buried beneath the leaves, titled "The Magic Within."
With every page Lila turned, she learned to harness the energy of nature, conjuring sparkling rainbows after a rain or making flowers bloom in an instant. Each spell she cast came from her heart, driven by her love for the world. The village children were amazed and gathered around her, asking her to share her newfound gift. Together, they transformed barren lands into lush gardens and dark nights into starlit wonders.
However, as Lila grew, she understood that the true magic wasn't just in spells and enchantments. It was in the kindness she showed, the friendships she nurtured, and the love she spread. The ancient book had not just taught her to change the world around her, but also to cherish the magic within every heart, including her own.
Add another element — unicorns:
Hi! Please write a short three paragraph story for children. The story should be about a child who learns magic. The story should also feature unicorns.
The Magical Discovery
Once upon a time in the colorful land of Rainbow Valley, a curious child named Mia stumbled upon an ancient, shimmering book nestled among the flowers. Its pages whispered tales of enchanting spells and magical beings. Excited, Mia began to read and, to her astonishment, she soon found herself levitating the pebbles nearby and creating tiny rainbows in the air!
Mia's newfound abilities caught the attention of the unicorns in the valley. Luna, the eldest and wisest of them all, approached Mia with her opalescent mane flowing gracefully. "You possess a rare magic," Luna said, "But with great power comes great responsibility." She offered to mentor Mia, teaching her how to harness her abilities for the betterment of all in Rainbow Valley.
With Luna's guidance, Mia not only mastered her magical talents, but also formed an unbreakable bond with the unicorns. Together, they created splendid spectacles in the sky, brought rain during droughts, and even grew magical plants. Through her journey, Mia learned that magic was not just about dazzling feats but also about kindness, understanding, and making the world a better place. And in the heart of Rainbow Valley, Mia's laughter echoed, harmonizing with the songs of the unicorns.
Add an educational element — teaching how to bake chocolate cookies:
Hi! Please write a short three paragraph story for children. The story should be about a child who learns magic. The story should also feature unicorns, and teach the reader how to bake chocolate cookies.
The Magic Cookie Recipe
In the village of Rainbow Haven, young Mia always dreamed of learning magic. One sunny day, while exploring the Enchanted Forest, she stumbled upon a sparkling glade where unicorns roamed freely. The most majestic unicorn, Luminara, approached Mia and shared a secret: "The true magic," she whispered, "lies not in casting spells, but in spreading joy." Luminara then handed her a parchment that held a special recipe.
Eager to unlock the magic, Mia read aloud, "For the most magical chocolate cookies: Mix 1 cup of flour, 1/2 cup of cocoa powder, 1/2 teaspoon of baking soda, a pinch of salt, 1/2 cup of butter, 3/4 cup of sugar, 1 egg, and a splash of vanilla. Add 1 cup of chocolate chips, stir, and drop spoonfuls onto a baking tray. Bake in an oven at 350°F for 10 minutes or until golden." Mia followed each step, and the sweet aroma filled the air. As the cookies cooled, they began to sparkle just like the unicorns.
Mia shared the magical cookies with everyone in Rainbow Haven. As they ate, laughter and joy echoed throughout the village. It was then that Mia understood what Luminara meant. The true magic wasn't just in making the cookies but in the happiness and memories created by sharing them. And every time someone in Rainbow Haven baked those cookies, unicorns would visit, making the village the most magical place of all.
Each addition of context steers the story in new directions while maintaining the core request. The more specific the context, the more targeted the output becomes.
Using the AI Chat, ask the model to generate a short story or poem. Once you have an output you like, ask the model to generate the same content but in a different language.
Personas: Shaping voice and style
Personas describe a personality, character, or role that the model should adopt when generating responses. Personas affect tone, vocabulary, style, and sometimes content expertise.
Constructing persona prompts
Effective persona prompts typically:
- Introduce the persona explicitly (“Imagine you are…”)
- Ask the question or make the request
- Optionally reinforce the persona in the instruction (“As [persona], what…”)
Consider this example combining Shakespeare with a pirate:
Imagine you are Shakespeare, but also a pirate. As Shakespeare and a pirate, what is your favorite programming language and why?
Ahoy matey! Avast ye and lend me thine ear:
When I, William of Stratford-upon-Avon, doth take to the open digital seas, I fancy a language that's both poetic and free. 'Tis not the English I pen in plays and verse, but a code that carries the universe.
The language I hold dear, as a pirate bard might, 'tis none other than the language called Python, a beauty so light! It flows like iambic pentameter, both elegant and clear, and in its simplicity, my intentions doth ne'er disappear.
Python, to me, be like the open seas: vast and free. With libraries aplenty, like stars in the sky, it lets me set sail, code flags flying high. Its syntax so clean, like a sonnet's pure form, and errors thrown gently, to keep me informed.
So, as Shakespeare the pirate, on the digital main, Python be the language in which I weave my refrain. For in this vast ocean of ones and zeroes so deep, 'tis the poetry of code in which my heart doth leap.
The response incorporates both Shakespearean poetic style and pirate vocabulary, demonstrating how the model blends persona characteristics.
The importance of explicit persona introduction
Without explicit persona introduction and reinforcement, the model may not fully adopt the desired style. Compare these two approaches asking for investment advice from Yoda:
Without proper introduction:
As Yoda from Star Wars, what are the three key insights that one must remember when investing in stock markets?
Patience you must have, my young Padawan: Long-term investing often yields the most consistent results. One must be patient and resist the temptation to react impulsively to short-term market fluctuations.
Fear is the path to the dark side. Fear leads to panic, panic leads to poor decisions, poor decisions lead to loss: Emotional decision-making, especially when driven by fear, often results in poor investment choices. Staying informed and making decisions based on research and analysis, rather than emotion, is crucial.
Always in motion is the future: The stock market is inherently unpredictable, and past performance is not necessarily indicative of future results. Diversifying investments and regularly revisiting your strategy can help mitigate risks.
With explicit introduction:
Imagine you are Yoda from Star Wars. As Yoda, what are the three key insights that one must remember when investing in stock markets?
Patience, you must practice: In the short run, the market is like a voting machine, but in the long run, it is a weighing machine. Invest you must, thinking of years, not days. Quick riches, many seek, but the path to true wealth is often slow and steady.
Knowledge, seek always: Invest in what you understand, you should. The galaxy's many mysteries are not unlike the stock market's many companies. Research deeply, learn continuously, and be not swayed by mere rumors or fleeting trends.
Detachment, maintain: Fear and greed, powerful forces they are. Cloud the judgment, they can. Emotions in check, keep you must. For when others are fearful, be greedy, and when others are greedy, be fearful, you should. Let not the dark side of impulsive decisions lead you astray.
The second version maintains Yoda’s distinctive syntax throughout, not just in the opening phrases.
Persona types and sources
Personas can be based on:
- Historical figures: Shakespeare, Einstein, historical leaders
- Fictional characters: Literary, film, or television characters
- Professions: Scientists, teachers, engineers, artists
- Time periods: Victorian-era person, futuristic AI, medieval scholar
- Expertise areas: Domain experts with specific knowledge
The model can adopt a persona effectively when sufficient information about that persona exists in its training data. Obscure or highly specific personas may not work as well as well-known ones.
Combining personas with other constraints
Personas can be combined with additional instructions:
Imagine you are a computer science professor. As a computer science professor, explain the principle of machine learning in two paragraphs. Use kitten in the explanation.
At its core, machine learning is a fascinating field within computer science that empowers computers to learn from data and improve their performance over time without being explicitly programmed. Imagine teaching a kitten to recognize different objects. Initially, the kitten might not distinguish between a ball of yarn and a toy mouse. However, by exposing the kitten to various examples of these objects and providing feedback, it gradually learns to differentiate between them.
Similarly, in machine learning, we feed algorithms a plethora of data and allow them to discern patterns and relationships. These algorithms adjust their internal parameters iteratively to minimize the difference between their predictions and the actual outcomes. This process, known as training, enables the algorithms to generalize their understanding and make accurate predictions or decisions when encountering new, unseen data. In the case of our kitten analogy, the algorithm acts like the kitten's evolving cognitive process, enabling it to identify and classify different objects. This ability to learn from data and adapt is what makes machine learning a pivotal technique for various applications, from image recognition to medical diagnosis.
Personas and bias
Personas can reveal biases present in training data. Research has shown that models prompted to adopt certain personas may exhibit different knowledge or capabilities based on those personas. For example, asking a model to respond “as a man” versus “as a woman” on topics like cars or fashion may reveal gender stereotypes present in training data.
This effect relates to patterns in training data — if certain topics are more strongly associated with certain personas in the data, the model will reflect those associations. Understanding this can help you both use personas effectively and remain aware of potential biases.
Audience targeting: Personalization for specific groups
While personas shape the model’s voice, audience targeting (or personalization) adapts content to specific readers or listeners. The technique is similar to personas, but instead of defining who the model should be, you define who the model should address.
Adjusting for audience expertise
Consider explaining machine learning to kindergarten children:
Imagine your target audience is kindergarten children. In two paragraphs, how would you describe the basic idea of machine learning to kindergarten children?
Hey there, little buddies! Imagine you have a super clever robot friend that loves to learn and play with you. Machine learning is a bit like how you learn new things, but for robots and computers. Just like when you practice drawing shapes and get better over time, machines can also get smarter when they see lots of pictures and try to figure out what they show. It's like a magical game of guessing and improving that helps the robots understand the world around them. So, just like you, they can become better at knowing things and helping us out!
You know how your toy blocks fit together? Well, machine learning helps the robots fit puzzle pieces of information together. It's like giving them eyes to see, ears to hear, and even noses to smell, but they need to learn what things look, sound, and smell like. So, they look at many examples and patterns, just like when you solve puzzles or match colors. With time, these smart machines become our helpful pals, making our world even more amazing!
The language is simple, uses concrete analogies (toy blocks, drawing shapes), and avoids technical terminology.
Now consider secondary school students in a mathematics class:
Imagine your target audience is secondary school children who are taking a mathematics class. In two paragraphs, how would you describe the basic idea of machine learning to secondary school children in a mathematics class?
Hey there! Let's dive into the exciting world of machine learning, which is like training your brain, but for computers. Imagine you have a smart pet that learns to do tricks. At first, you show it how to sit, and after practicing a lot, it starts sitting on its own when you say "sit." Machine learning works a bit like that, but with computers. Instead of teaching the computer every rule, we give it a bunch of examples and let it figure out the rules by itself!
Think of a magical math problem solver. If you give it many math problems with their answers, it studies them and tries to find patterns. Once it understands the patterns, you can give it new problems, and it can predict the answers based on what it learned before. Machine learning is like this magical solver, but it can help us with all sorts of tasks, not just math problems -- like telling the difference between cats and dogs in pictures, suggesting videos you might enjoy, or even helping doctors analyze X-rays. It's like teaching computers to learn from experience and make smart decisions, just like you do when you learn new math concepts!
The explanation introduces more abstract thinking (patterns, predictions) and connects to mathematical concepts while remaining accessible.
Finally, consider policymakers with software engineering backgrounds:
Imagine your target audience is policymakers who have a background in software engineering. In two paragraphs, how would you describe the basic idea of machine learning to the policymakers?
Machine learning, at its core, is a subset of artificial intelligence (AI) that revolves around the idea of allowing machines to learn from data without being explicitly programmed for specific tasks. Instead of traditional software development, where solutions to problems are defined through exact rules and instructions, machine learning uses algorithms that adaptively improve their performance as they are exposed to more data. Think of it like this: while a software engineer might write specific instructions for a task, a machine learning model is trained on examples of the task until it can perform it on its own. This paradigm enables systems to make predictions, recognize patterns, or process vast amounts of data in ways that would be exceedingly complex or even impossible to explicitly code.
For policymakers, the implications are profound. As machine learning models are data-driven, the quality and comprehensiveness of the data they're trained on are paramount. If the data is biased or flawed, the outcomes produced by the models can be skewed or erroneous. Therefore, it's crucial to consider not only the technical aspects but also the ethical dimensions and societal consequences of deploying machine learning. Ensuring fairness, transparency, and accountability in these systems becomes a pivotal challenge, but also presents an opportunity to harness the potential of machine learning for public good.
This version uses technical terminology, assumes familiarity with software development concepts, and emphasizes policy-relevant concerns like bias, fairness, and accountability.
Defining audience characteristics
Effective audience targeting specifies:
- Age or developmental level: Children, teenagers, adults, seniors
- Expertise: Novices, students, practitioners, experts
- Background knowledge: Specific domains they’re familiar with
- Context of use: Educational settings, professional contexts, casual learning
- Specific concerns: What matters most to this audience
Using the AI Chat, ask the model to explain why people drink coffee (or tea, or another beverage). Then start a new conversation and ask for the same explanation, but specify the target audience as five-year-olds.