To get a high-quality response from a model, provide clear and specific instructions. This page contains examples that show you how to write effective prompts. Giving the model instructions on what to do is an effective and efficient way to customize model
behavior. Be clear, concise, and direct in the instructions, providing the needed context and
outlining the desired output. Instructions can be as simple as a list of step-by-step instructions
or as complex as mapping out a user's experience and mindset. Effective instructions apply the following principles: For example, suppose you own a cheeseburger restaurant and you want to use a model to help you
learn about which menu items are the most popular. You want the model to format transcripts of
customer orders in JSON so that you can quickly identify menu items. The following tables
demonstrate the different responses the model provides when given generic instructions and specific
instructions that follow the instruction principles: By applying the instruction principles, this example went from a response that contained too
much data to one that contained exactly the data required for this use case. Instructions that use
the instruction princples can help you guide the model to deliver the most helpful response for
your use case.How to write effective instructions
Example
In the example, generic instructions lead to a response with more JSON fields than what
you need to identify the menu items customers are ordering. Improve the instructions by making more
specific output constraints, as demonstrated in the following table:
Generic instructions
Extract the transcript in JSON.
Transcript:
Speaker 1 (Customer): Hi, can I get a cheeseburger and large fries, please?
Speaker 2 (Restaurant employee): Coming right up! Anything else you'd like to add to your order?
Speaker 1: Hmmm, maybe a small orange juice. And could I get the fries with ketchup on the side?
Speaker 2: No problem, one cheeseburger, one large fries with ketchup on the side, and a small
orange juice. That'll be $5.87. Drive through to the next window please.
{
"speakers": [
{
"speaker": "Customer",
"utterances": [
"Hi, can I get a cheeseburger and large fries, please?"
]
},
{
"speaker": "Restaurant Employee",
"utterances": [
"Coming right up! Anything else you'd like to add to your order?"
]
},
{
"speaker": "Customer",
"utterances": [
"Hmm, maybe a small orange juice. And could I get the fries with ketchup on the
side?"
]
},
{
"speaker": "Restaurant Employee",
"utterances": [
"No problem, one cheeseburger, one large fries with ketchup on the side, and a
small orange juice. That'll be $5.87. Drive through to the next window please."
]
}
]
}
Specific instructions
Extract the items from this transcript in JSON and separate drinks from food.
Transcript:
Speaker 1 (Customer): Hi, can I get a cheeseburger and large fries, please?
Speaker 2 (Restaurant employee): Coming right up! Anything else you'd like to add to your order?
Speaker 1: Hmmm, maybe a small orange juice. And could I get the fries with ketchup on the side?
Speaker 2: No problem, one cheeseburger, one large fries with ketchup on the side, and a small
orange juice. That'll be $5.87. Drive through to the next window please.
{
"drinks": [
"orange juice"
],
"food": [
"cheeseburger",
"large fries"
]
}
What's next
Give clear and specific instructions
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-15 UTC.