Few-shot builder
Goal
Choose and write examples that show a model what you want better than a description does. The set is small, varied and consistent with the written rules, and it is kept apart from the data used to test the prompt.
When to use
- A prompt describes a format or style but the model keeps missing it.
- A classification, extraction or rewriting task needs a stable pattern.
- The user has real data to turn into examples.
- For judging the prompt after adding examples, use
use_skillwithprompt-eval-set. - For the surrounding prompt text, use
use_skillwithprompt-rewriter.
Steps
- Ask with
ask_userfor the task, the current prompt, a sample of real inputs and the output the user wants for some of them. Look at files withread_fileif the data is on disk. - List the dimensions that vary in the inputs: length, topic, tone, language, quality, missing fields, ambiguous cases. Your examples must cover the main ones.
- Decide how many. Start with three to five. Add more only if tests show a gap, because each example costs context and can pull the output towards itself.
- Pick examples from real data where possible. Include at least one typical case, one edge case (empty, very short, noisy, or odd format) and one case where the right answer is "none" or "cannot tell" if that is allowed.
- Write the outputs by hand with care. They must follow every rule in the prompt exactly, because the model copies details such as spacing, capitalisation, field order and length.
- Vary the surface. If all examples start the same way, are the same length or use the same label, the model will copy that accident. Shuffle the order and check the label balance, so one answer is not over-represented.
- Format each example the same way, with clear delimiters between input and output and between examples. State in the prompt that the examples show format and are not content to reuse.
- Check for contradictions between examples and rules. If an example breaks a rule, fix the example or the rule.
- Keep a held-out set of other cases for testing. Never test with the same items used as examples. Save the examples with
create_fileand give the user the assembled prompt block.
Gotchas
- Examples are stronger than rules. A wrong detail in an example beats a right sentence.
- Real personal data in examples can leak into outputs. Use made-up or cleaned data.
- Too many similar examples teach a narrow pattern and hurt new inputs.
- Order can matter. The last example often has more pull, so do not end on an odd one.
- If outputs vary legitimately, show that range instead of one fixed style.
- Do not claim a number of examples works for every task. Test.
Output
- The example block and the dimensions it covers.
- Which cases were left out on purpose, and the held-out set path.
- Checks done for consistency with the rules.
- Suggested test steps.
