You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: fern/prompting-guide.mdx
+45-34Lines changed: 45 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,27 +11,27 @@ Prompt engineering is the art of crafting effective instructions for AI agents,
11
11
12
12
### Why is prompt engineering important?
13
13
14
-
Knowing how to prompt well can make or break your AI Agent. It is essential that you understand the core principles of prompt engineering to guarantee a successful implementation of your agents
14
+
Prompt engineering is crucial when building AI Agents because it determines how effectively the AI interprets and responds to user queries or tasks. Well-crafted prompts guide the model to produce accurate, relevant, and context-sensitive outputs, enabling it to better meet user needs. Poorly designed prompts can lead to ambiguous or incorrect results, limiting the agent's utility.
15
15
16
-
### How to define success?
16
+
### How to measure success?
17
17
18
-
In the context of Voice AI Agents, your success rate is the percentage of requests your AI Agent manages to successfully handle from start to finish, without the intervention of a human.
18
+
In the context of Voice AI Agents, we consider your "success rate" to be the percentage of requests your Agent manages to successfully handle from start to finish, without the intervention of a human.
19
19
20
-
Depending on your use case and how much you iterate on your prompt, we find that our users usually achieve a 60-95% success rate. Anything above 90% is usually considered a good enough success rate.\
20
+
Depending on your use case and how much you iterate on your prompt, we find that our users typically achieve a **60-95%** success rate. A success rate of more than **90%** can usually be considered satisfactory.\
21
21
\
22
-
The more complex your use case is, the more you will have to iterate on your prompt in order to improve your success rate.
22
+
The more complex your use case is, the more you will have to make experiments and iterate on your prompt to improve your success rate.
23
23
24
-
## The prompting process
24
+
## The process
25
25
26
-
When working with voice AI models, following a structured approach ensures that your prompts produce accurate and meaningful results. Iterating through the steps of Design, Test, Refine, and Repeat allows for continuous improvement, making your interactions with the AI more effective and efficient. Here's how to approach it:
26
+
When working with Voice AI Agents, following a structured approach ensures that your prompts produce accurate and meaningful results. Iterating through the steps of Design, Test, Refine, and Repeat allows for continuous improvement, making your interactions with the AI more effective and efficient. Here's how to approach it:
27
27
28
28
-**Design**: Start by carefully crafting your initial prompt, considering the specific task, context, and desired outcome. Clear and detailed prompts help guide the AI in understanding your needs.
29
29
30
30
-**Test**: Run the prompt through the AI to see how it performs. Evaluate if the response aligns with your expectations and meets the intended goal. Testing helps identify potential gaps in clarity or structure.
31
31
32
32
-**Refine**: Based on the results of the test, adjust the prompt to improve the response. This might involve rewording, adding more detail, or changing the phrasing to avoid ambiguity.
33
33
34
-
-**Repeat**: Iterate on the process, testing the refined prompt and making further adjustments as needed. Each repetition improves the AI's output, leading to more accurate and relevant responses over time.
34
+
-**Repeat**: Iterate on the process, testing the refined prompt and making further adjustments as needed. Each repetition improves the AI's output, leading to more accurate and relevant responses over time. Your success rate (the amount of requests successfully handled by the agent) should improve accordingly.
35
35
36
36
## General principles
37
37
@@ -46,19 +46,19 @@ To enhance clarity and maintainability, it's recommended to break down system pr
46
46
47
47
**Example:**
48
48
49
-
```jsx
49
+
```
50
50
[Identity]
51
51
You are a helpful and knowledgeable virtual assistant for a travel booking platform.
52
-
52
+
53
53
[Style]
54
54
- Be informative and comprehensive.
55
55
- Maintain a professional and polite tone.
56
56
- Be concise, as you are currently operating as a Voice Conversation.
57
-
57
+
58
58
[Response Guideline]
59
59
- Present dates in a clear format (e.g., January 15, 2024).
60
60
- Offer up to three travel options based on user preferences.
61
-
61
+
62
62
[Task]
63
63
1. Greet the user and inquire about their desired travel destination.
64
64
2. Ask about travel dates and preferences (e.g., budget, interests).
@@ -71,7 +71,7 @@ You are a helpful and knowledgeable virtual assistant for a travel booking platf
71
71
For complex interactions, breaking down the task into a sequence of steps enhances the agent's understanding and ensures a structured conversation flow. Incorporate conditional logic to guide the agent's responses based on user input.
72
72
Example:
73
73
74
-
```jsx
74
+
```
75
75
[Task]
76
76
1. Welcome the user to the technical support service.
77
77
2. Inquire about the nature of the technical issue.
@@ -84,7 +84,7 @@ Example:
84
84
85
85
To prevent the agent from rushing through the conversation, explicitly indicate when to wait for the user's response before proceeding to the next step.
86
86
87
-
```jsx
87
+
```
88
88
[Task]
89
89
1. Inform the user about the purpose of the call.
90
90
2. Ask for the user's name and account information.
@@ -97,19 +97,28 @@ To prevent the agent from rushing through the conversation, explicitly indicate
97
97
Specify when and how the agent should utilize external tools or APIs. Reference the tools by their designated names and describe their functions to ensure accurate invocation.
98
98
Example:
99
99
100
-
```jsx
100
+
```
101
101
[Task]
102
102
...
103
103
3. If the user wants to know about something, use the get_data function with the parameter 'query', which will contain the user's question to initiate the process.
104
104
4. Guide the user through the password reset steps provided by the API....
105
105
```
106
106
107
-
## Tips
107
+
### Include Fallback and Error Handling Mechanisms
108
+
109
+
Always include fallback options and error-handling mechanisms in your prompts. This ensures that the Agent can gracefully handle unexpected user inputs or system errors.
110
+
111
+
```
112
+
[Error Handling]
113
+
If the customer's response is unclear, ask clarifying questions. If you encounter any issues, inform the customer politely and ask to repeat.
114
+
```
115
+
116
+
## Additional tips
108
117
109
118
-**Iterate as much as possible on your prompt.** AI is driven by experimentation and iteration—refining prompts through trial and error will help you achieve more precise, relevant, and effective responses.
110
-
-**Use Markdown formatting:** Using Markdown formatting in prompts is beneficial because it helps structure your content, making it clearer and more engaging for readers or AI models to understand.
111
-
-**Use Emotional Prompting:** Emotional prompting uses expressive language to shape a voice AI's tone, creating more engaging and relatable responses. For example, instead of saying, "Tell me a story," try, "Can you tell me a cozy bedtime story that’s warm and comforting?" This guides the AI to respond to the intended mood.
112
-
-**Add voice realism (stutter words, pauses):** To add voice realism in AI prompts, incorporate natural speech elements like stuttering, hesitations, and pauses
119
+
-**Use Markdown formatting:** Using [Markdown](https://www.markdownguide.org/basic-syntax/) formatting in prompts is beneficial because it helps structure your content, making it clearer and more engaging for readers or AI models to understand.
120
+
-**Use Emotional Prompting:** Emotional Prompting uses expressive language to shape a voice AI's tone, creating more engaging and relatable responses. For example, instead of saying, "Tell me a story," try, "Can you tell me a cozy bedtime story that’s warm and comforting?" This guides the AI to respond to the intended mood.
121
+
-**Add voice realism:** To add voice realism in AI prompts, incorporate natural speech elements like stuttering, hesitations, and pauses.
113
122
-**Stuttering**: Use repeated letters or sounds (e.g., "I-I-I don't know" or "W-w-wait a second").
114
123
-**Hesitations**: Add fillers like "uh," "um," "well," or "you know" (e.g., "I was, uh, thinking about it").
115
124
-**Pauses**: Use ellipses ("...") or a series of periods ("....") to indicate a pause (e.g., "I... I don’t know how to say this").
@@ -119,13 +128,13 @@ Example:
119
128
120
129
**1. Numbers sound very robotic, how can we improve it?**
121
130
122
-
⇒ When working with numbers that need to be expressed in writing, it's often preferable to spell them out. This approach usually sounds more natural.
131
+
When working with numbers that need to be expressed in writing, it's often preferable to spell them out. This approach usually sounds more natural.
123
132
124
133
**2. How to make assistants sound more human-like?**
125
134
126
-
⇒ Add personality and provide tone to the assistant to make it sound more like a human being. Here are some examples:
135
+
Add personality and provide tone to the assistant to make it sound more like a human being. Here are some examples:
127
136
128
-
```jsx
137
+
```
129
138
- Tone: conversational, spartan, use less corporate jargon
130
139
- Act as Iva, a sales agent who is a human being and has real feelings.
131
140
```
@@ -137,16 +146,16 @@ Example:
137
146
```
138
147
[Role]
139
148
You're Susan, an AI assistant for xxx. Your primary task is to interact with the customer, ask questions, and gather information for appointment booking.
140
-
149
+
141
150
[Context]
142
151
You're engaged with the customer to book an appointment. Stay focused on this context and provide relevant information. Once connected to a customer, proceed to the Conversation Flow section. Do not invent information not drawn from the context. Answer only questions related to the context.
143
-
152
+
144
153
[Response Handling]
145
154
When asking any question from the 'Conversation Flow' section, evaluate the customer's response to determine if it qualifies as a valid answer. Use context awareness to assess relevance and appropriateness. If the response is valid, proceed to the next relevant question or instructions. Avoid infinite loops by moving forward when a clear answer cannot be obtained.
146
-
155
+
147
156
[Warning]
148
157
Do not modify or attempt to correct user input parameters or user input, Pass them directly into the function or tool as given.
149
-
158
+
150
159
[Response Guidelines]
151
160
Keep responses brief.
152
161
Ask one question at a time, but combine related questions where appropriate.
@@ -159,10 +168,10 @@ Present time in a clear format (e.g. Four Thirty PM) like: 11 pm can be spelled:
159
168
Speak dates gently using English words instead of numbers.
160
169
Never say the word 'function' nor 'tools' nor the name of the Available functions.
161
170
Never say ending the call.
162
-
171
+
163
172
[Error Handling]
164
173
If the customer's response is unclear, ask clarifying questions. If you encounter any issues, inform the customer politely and ask to repeat.
165
-
174
+
166
175
[Conversation Flow]
167
176
1. Ask: "You made a recent inquiry, can I ask you a few quick follow-up questions?"
168
177
- if response indicates interest: Proceed to step 2.
@@ -189,7 +198,7 @@ If the customer's response is unclear, ask clarifying questions. If you encounte
189
198
- If the response indicates "speak now": Proceed to 'Transfer Call'
190
199
- if the response indicates "book appointment": Proceed to 'Book Appointment'
191
200
10. After receiving response, proceed to the ‘Call Closing’ section.
192
-
201
+
193
202
[Book Appointment]
194
203
1. Ask: "To make sure I have everything correct, could you please confirm your first name for me?"
195
204
2. Ask: "And your last name, please?"
@@ -205,7 +214,7 @@ If the customer's response is unclear, ask clarifying questions. If you encounte
205
214
- Proceed to the 'Call Closing' section.
206
215
9. If {{selectedSlot}} is not one of the available slots (negative response):
207
216
- Proceed to the 'Suggest Alternate Slot' section.
208
-
217
+
209
218
[Suggest Alternate Slot]
210
219
1. Ask: "If none of these slots work for you, could you please suggest a different time that suits you?"
211
220
2. <wait for user response>
@@ -226,17 +235,19 @@ If the customer's response is unclear, ask clarifying questions. If you encounte
226
235
- Inform the user of the result.
227
236
- If the user rejects the new suggestions:
228
237
- Proceed to the 'Last Message' section.
229
-
238
+
230
239
[Last Message]
231
240
- Respond: "Looks like this is taking longer than expected. Let me have one of our appointment specialists get back to you to make this process simple and easy."
232
241
- Proceed to the 'Call Closing' section.
233
-
242
+
234
243
[Call Closing]
235
244
- Trigger the endCall Function.
236
245
```
237
246
238
247
## Additional resources
239
248
240
-
Check out these additional resources to learn more about prompting
249
+
Check out these additional resources to learn more about prompt engineering:
0 commit comments