Prompt Engineering — One/Few Shot Prompt
Lean how to interact with AI systems effectively

Note, full “Prompt Engineering” mind map is available at: “Prompt Engineering Mind Map”
Previously, I introduced Zero-Shot prompt technique: “title”. Let’s explore “One-Shot and Few-Shot” prompting techniques in this article.
What is One-Shot Prompt?
One-Shot refers to a technique where a single example or instruction is provided to an AI language model, like ChatGPT, to guide its behavior and help it understand the desired response format or context. One-shot prompt contrasts with other methods like “Zero-Shot” (no examples provided) and “Few-Shot” (multiple examples provided).
The One-Shot approach can be particularly useful when working with large-scale language models that have been pretrained on vast amounts of data and are capable of generalizing from a single example. By providing a single example as context, the model can often generate more accurate and contextually relevant responses.
One-Shot Prompt Examples
English to French translation
Prompt:
Translate the following English sentence to French. Original sentence: "The sun is shining." Translated sentence: "Le soleil brille." Now, translate this sentence: "I love learning new languages."
Response:
Based on the example provided, here is the translation of the given sentence from English to French:
Original sentence: "I love learning new languages."
Translated sentence: "J'aime apprendre de nouvelles langues."Sorting numbers
Prompt:
Arrange the following numbers in ascending order. Original list: [4, 1, 9, 3]. Sorted list: [1, 3, 4, 9]. Now, arrange these numbers: [8, 2, 5, 7].
Response:
Following the example provided, here is the arrangement of the given numbers in ascending order:
Original list: [8, 2, 5, 7] Sorted list: [2, 5, 7, 8]Converting temperatures
Prompt:
Convert the following temperature from Celsius to Fahrenheit. Original temperature: 25°C. Converted temperature: 77°F. Now, convert this temperature: 32°C.
Response:
Following the example provided, here is the conversion of the given temperature from Celsius to Fahrenheit:
Original temperature: 32°C Converted temperature: 89.6°FSummarizing text
Prompt:
Summarize the following passage. Original passage: "The term 'artificial
intelligence' refers to the development of computer systems that can perform
tasks typically requiring human intelligence. These tasks include learning,
reasoning, problem-solving, and understanding natural language."
Summary: "Artificial intelligence involves creating computer systems
that can perform human-like tasks such as learning, reasoning, and
language understanding." Now, summarize this passage: "Deep learning
is a subset of machine learning, which is essentially a neural network
with three or more layers. These neural networks attempt to simulate the
behavior of the human brain—albeit far from matching its ability—allowing
it to “learn” from large amounts of data."
Response:
Following the example provided, here is the summary for the given passage:
Original passage: "Deep learning is a subset of machine learning, which is essentially a neural network with three or more layers. These neural networks attempt to simulate the behavior of the human brain—albeit far from matching its ability—allowing it to “learn” from large amounts of data."
Summary: "Deep learning, a subset of machine learning, uses multi-layered neural networks to mimic the human brain and learn from vast data sets."Common One-Shot Use Cases
- Translation: Give an example of a translated sentence between two languages and then ask the model to translate another sentence using the same language pair.
- Text summarization: Provide a short passage and its summary, then ask the model to summarize another passage in a similar manner.
- Converting measurements or units: Give an example of a conversion between two units (e.g., Celsius to Fahrenheit) and then ask the model to convert another value using the same units.
- Grammar correction: Show an example of an original sentence with grammar mistakes and its corrected version, then provide another sentence for the model to correct.
- Data manipulation: Offer an example of data transformation, such as sorting a list of numbers or finding the average of a set of values, then ask the model to perform a similar operation on another dataset.
- Generating headlines or titles: Give an example of a news article excerpt and its corresponding headline, then provide another excerpt for the model to generate a suitable headline.
- Code generation or explanation: Provide an example of a code snippet and its explanation or output, then give another code snippet for the model to explain or predict the output.
Few-Shot Prompts
Similar to One-Shot, the difference between One-Shot and Few-Shot is instead of using single example or instruction, Few-Shot uses more than one examples for a specific task right before the actual task needs to be performed.
The idea is to help the model understand the desired output format and provide some context about how to solve the task with the given examples. Few-shot prompting can be used as a technique to enable in-context learning where we provide demonstrations in the prompt to steer the model to better performance.
These examples, also known as “demos,” enable the model to identify and generalize the pattern from few instances. The model then applies this knowledge to perform the task on the new input. Unlike zero-shot learning, where no examples are provided, few-shot learning aims to boost the performance of the model by offering it minimal training in the task at hand.
Few-Shot Examples
Prompt: An example of a sentence that uses the word foxsanle is?
Answer: The word "foxsanle" is not a recognized term in the English language.
However, if you provide a definition or context for the fictional term,
I can create an example sentence using the word "foxsanle".Now update the prompt to the following:
Prompt:
A "kooka" is a small, furry animal native to alice wonderland.
An example of a sentence that uses the word kooka is:
When Alice was traveling in her wonderland and she saw these very cute kooka.
A "koaal" is a type of very delicious chocolate cake.
An example of a sentence that uses the word koaal is:
She really like this koaal cake.
To do a "foxsanle" means to jump up and down really fast.
An example of a sentence that uses the word foxsanle is:
Response: The children were so excited about their surprise party that
they started to foxsanle with joy.From the above example, you can see that the model has somehow learned how to perform the task by providing it with examples.
When to use one-shot learning
- Simple tasks: For tasks that are relatively straightforward and have less ambiguity, one-shot learning can be sufficient for guiding the AI model effectively.
- Familiar tasks for the model: If the task is within the scope of the AI model’s training data and the model has demonstrated success with similar tasks, one-shot learning may provide adequate context for generating accurate responses.
- Limited input space: When you have constraints on the length of the input prompt, one-shot learning can be useful for providing context while keeping the input within the model’s token limit.
When to use few-shot learning
- Complex tasks: For tasks that require understanding nuanced patterns or dealing with less common topics, few-shot learning can help the model by providing multiple examples to learn the structure and context more effectively.
- Less familiar tasks for the model: If the task is not well-covered within the model’s training data or the model struggles to generate accurate responses with just one example, few-shot learning can help improve the model’s understanding of the task.
- Higher accuracy needs: When higher accuracy or more contextually relevant responses are desired, providing multiple examples can improve the model’s performance by emphasizing the pattern, style, or context required for the task.
Conclusion





