Few-Shot Example Formatter
Two columns of examples in, correctly formatted few-shot prompts out as chat messages, XML, labelled text or markdown — with the per-request token cost of carrying them.
Every example is re-sent with every request that uses this prompt, so the count below is a per-request cost, not a one-off.
- Average characters per example
- 36
- Estimated tokens per example
- ≈ 9
- Formatted block, characters
- 746
- Estimated tokens for the whole block
- ≈ 187
Few-shot examples are the cheapest reliable way to pin down a format. They are also the most expensive part of a prompt to leave lying around, because unlike an instruction they scale: ten examples of two hundred characters each is two thousand characters on every single request, forever, whether or not the model needed the tenth one.
Format follows the model
A chat model has been trained on alternating turns, so examples given as real user and assistant messages tend to be followed more closely than the same examples pasted into one block. A completion-style model has not, and does better with labelled plain text it can continue. XML-tagged blocks sit in the middle and have the advantage of being unambiguous about where an example ends — worth it when your inputs are multi-line.
Balance is a real problem
Order and proportion both leak into the output. If every example you show has the same label, expect that label; if your examples run easy-to-hard, expect the model to weight the last ones. The check above catches only the crudest version of this — every answer identical — but it is the version that actually happens when someone pastes the first twenty rows of a sorted spreadsheet.