An essential concept in prompt engineering is
in-context learning. When prompting an LLM, users can include new information outside the modelβs static training dataβsuch as step-by-step demonstrationsβallowing the LLM to learn how to perform a task within that specific conversation.
For example, an LLM can be provided with a few demonstrations of how to perform text classification:
In-context learning is typically characterized by the number of examples provided prior to the target query:
Zero-shot learning does not involve providing any concrete examples of solved tasks. Instead, it directly prompts the LLM to address a problem using its baseline training.
One-shot learning expands on this approach by supplying a single demonstration of the desired task, allowing the model to learn from the provided example:
One-Shot Grammar Prompt.
You are a helpful assistant, and are great at grammar correction. You will be provided with a sentence in English. The task is to output the correct sentence.
Input: There is many reasons to celebrate.
Output: There are many reasons to celebrate.
Input: She donβt like going to the park.
Few-shot learning provides multiple demonstrations to establish a clear pattern mapping inputs to outputs, which the model follows to generate its prediction:
Few-Shot Grammar Prompt.
You are a helpful assistant, and are great at grammar correction. You will be provided with a sentence in English. The task is to output the correct sentence.
Input: There is many reasons to celebrate.
Output: There are many reasons to celebrate.
Input: Me and my friend goes to the gym every day.
Output: My friend and I go to the gym every day.
Input: She donβt like going to the park.