In the previous post we saw an introduction to how to use Semantic Kernel within our C# applications and how easy Sematic Kernel makes it. Now its time to do a deep dive into how we can use prompts effectively and get more complex tasks done. We can start with an introduction into various types and examples.
Prompts
Prompts are how you communicate with the model what you want it to do. While creating prompts you need to make it clear and context rich instructions so that the model can generate a desired response.
Zero-shot Learning
Zero-shot prompts will contain instructions but not the verbatim completion examples. These type of prompts are useful when you want the bot to perform a straightforward task.
string prompt = $"""
Instructions: What is the intent of this request?
If you don't know the intent, don't guess; instead respond with "Unknown".
Choices: PayBill, ViewBill, SubmitReading, ViewReading, Unknown.
User Input: {request}
Intent:
""";
Few shot learning
In this case you include verbatim completion along with the instructions. This helps the guide the model’s response. Typically one to five examples are provided. These examples can represent the structure, style or type of the response you want from the model.
string prompt = $"""
Instructions: What is the intent of this request?
If you don't know the intent, don't guess; instead respond with "Unknown".
Choices: PayBill, ViewBill, SubmitReading, ViewReading, Unknown.
User Input: Can I see the latest bill?
Intent: ViewBill
User Input: I want to pay my bill?
Intent: SendEmail
User Input: I want to submit a reading?
Intent: SendEmail
User Input: {request}
Intent:
""";
Personas in prompts
One way to adjust tone of the response is by assigning personas in prompts.
string prompt = $"""
You are a highly experienced software engineer. Explain the concept of asynchronous programming to a beginner.
""";

Chain of thought prompting
With this type of prompting you can ask the model to present each step and its result in order. This helps with prompt engineering and makes it easier to isolate problems.
string prompt = $"""
You buy a ticket for a show for 100 GBP. How much should you sell to get a 20% profit?
Instructions: Explain your reasoning step by step before providing the answer.
""";

Points to pay attention while crafting prompts
- Clear and specific prompts
- Iterate and experiment with prompts
- Context is important
- Avoid ambiguity
- Find the optimal balance for prompt length

Leave a comment