In this session, we will explore the next prompt engineering technique known as ‘few-shot prompting’. This technique revolves around providing examples (or shots) to guide the model to respond in a specific way.
In the few-shot prompting paradigm, we provide the model with multiple examples (or shots) so that the model can generalise and generate the desired output.
In the following video, Kshitij will provide a detailed explanation of the few-shot prompting technique. The prompt used in the video can be accessed here.
In the video, you observed the example of an AI tutor that uses few-shot prompts to guide the model. The few shots serve as references for the model to generate outputs that are highly task-specific. In this case, the task assigned to the model is that of an AI tutor. Note that the model has no prior recollection of how to act as an AI tutor and we specify its role, task, context, guidelines and output format through system messages in the form of prompts. By leveraging the few-shot examples, we ensure that the model understands the underlying context and engages in more targeted and contextually aware conversations. Few-shot prompting techniques offer flexibility to new tasks, making them valuable in generative AI applications.
In the next video, Kshitij will showcase the benchmark comparison between a standard prompt and a prompt that uses few-shot examples.
As mentioned in the video, few-shot prompting technique’s ability to generalise from the few-shot examples provided to the model makes it a powerful prompting technique, particularly when zero-shot technique fails. The usefulness of the few-shot prompting technique lies in its ability to enable rapid adaptation and application of pre-trained models to various specific tasks, without the need for explicit fine-tuning (you will learn more about fine-tuning in the upcoming weeks.). We also saw the performance improvements that can be gained by combining few-shot technique with the chain-of-thought technique.
The few-shot-chain-of-thought prompting technique builds upon the concept of few-shot learning, where models learn from a limited set of examples. However, it takes the capability further by incorporating contextual coherence into the learning process. This technique equips models with the ability to generate text that flows naturally, maintaining logical and coherent chains of thought.
By leveraging a series of interconnected prompts, the technique empowers models to understand and produce text that flows naturally, mimicking human-like communication and sound logic.
Prompt engineering is a rapidly evolving field that is still in its early stages of research and development. As language models are constantly updated and trained on more data, researchers are gaining insights into the underlying behaviours of language models, leading to the emergence of new prompting techniques such as program-aided language modelling, tree of thoughts, retrieval augmented generation and more. Therefore, it is important to stay updated with the latest advancements in prompt engineering and large language models.
In the upcoming module, we’ll look at a few more advanced prompt engineering techniques such as self-consistency and ReAct techniques.
Additional Readings:
- In this article, the author explains the various in-context learning techniques that can improve the LLMs performance: In-Context Learning Approaches in Language Models |Towards Data Science.
- In this highly technical paper, the authors demonstrate how few-shot examples can provide contextual information to an LLM that can generate outputs that are comparable against models that have been explicitly fine-tuned for the tasks: Language Models are Few-Shot Learners.