Introduction
Once you master the basics, you can use advanced techniques to tackle complex reasoning tasks and dramatically reduce hallucinations.
Few-Shot Prompting
Instead of just asking the model to do something (zero-shot), you provide a few examples of the input-output pairs you expect. This "trains" the model in-context.
Extract the names of cities from the text.
Text: I visited Paris last summer.
Cities: Paris
Text: She moved from Tokyo to New York.
Cities: Tokyo, New York
Text: We are flying to Berlin tomorrow.
Cities:Chain of Thought (CoT)
Adding a phrase like "Let's think step by step" forces the LLM to output its reasoning process before giving the final answer. This drastically improves performance on math and logic puzzles.
Assignment
- Read about Few-Shot Prompting and write a few-shot prompt that classifies the sentiment of customer reviews.
- Read about Chain of Thought (CoT) prompting and test a complex logic puzzle with and without it.