01. Prompt Engineering Technique: Few-Shot
Explanation
Few-shot prompting is a technique where you provide a sequence of examples to "prime" the LLM for a specific task format.
By showing the model 2-5 pairs of inputs and outputs, you establish a pattern that it can follow for new, unseen data.
This is significantly more effective than "Zero-Shot" (no examples) for tasks involving complex formatting or jargon.
The examples help the model understand the tone, the level of detail, and the structural constraints of the desired response.
It reduces the variability of the output and ensures the AI adheres to the specific style requirements of your application.
Mastering this pattern allows you to fine-tune the behavior of a general-purpose model for highly specialized business needs.
Example
Text: This product is amazing! Sentiment: Positive Text: I am very disappointed with the service. Sentiment: Negative Text: It's okay, nothing special. Sentiment: Neutral
Exercise Task
In the editor below, you'll find a template. Your task is to craft a few-shot prompt that converts informal slang into professional business English. Provide at least 2 examples in the prompt.
script.js
1
2
3
4
5
6
7
8
9
10
const prompt = `
Input: "I'm gonna be late for the
meeting, sorry."
Professional: "Please accept my
apologies; I will be late for the
meeting."
Input: "Yo, can you check this code?"
Professional: "Could you please review
this code at your earliest convenience?"
Input: "Tell the team the plan is a go."
Professional: [Your Answer Here]
`;
Console
Click "Run" to execute your code...