What is few-shot prompting?
Few-shot prompting is a way of guiding a language model by including a small number of worked examples of the task in the prompt, before the new input it should handle.
Also called: few-shot learning, k-shot prompting
How it works
The prompt shows the model a few pairs of input and correct output, then gives a new input. The model infers the pattern and applies it. This relies on in-context learning, so no training is needed.
Good examples are short, correct and varied. They should cover the tricky cases, not just the easy ones, and they should use the exact output format you want back.
Why it matters for fraud and risk
Few-shot prompts are a quick way to build classifiers for text that rules handle badly: dispute reasons, support tickets, seller descriptions or chat messages. When a new scam script appears, adding one or two examples can help the model recognize it.
Balance matters. If most examples show fraud, the model may over-label fraud. Including clear legitimate examples helps limit false positives.
Tips for better results
- Use real, de-identified examples that look like production data.
- Include at least one example for each label, including the hard edge cases.
- Keep a fixed output format, such as a single label and a short reason.
- Test the prompt on a held-out labeled set and track accuracy over time.
Example
A hypothetical lender wants to flag loan applications whose stated purpose looks copied from a template. The prompt shows two template-like purposes labeled suspicious and three genuine ones labeled normal. The model then labels new applications, and reviewers check a sample each week.
Related terms
- In-context learningIn-context learning is a language model's ability to pick up a task from instructions and examples placed in the prompt, without any change to the model's weights.
- Zero-shot learningZero-shot learning is when a model performs a task it was given only instructions for, with no examples of that task in the prompt or in task-specific training.
- Prompt engineeringPrompt engineering is the practice of writing and testing the instructions, context and examples given to an AI model so that it produces accurate, useful and consistent output.
- Fine-tuningFine-tuning is further training of an existing model on a smaller, task-specific dataset so it performs better on that task or follows a particular style or format.
- False positiveIn fraud prevention, a false positive is a genuine customer or event that a system wrongly flags as fraud, leading to a decline, block, extra check or unneeded review.