Few-shot learning guides a model with a small set of examples included in its prompt. It helps a web application adapt responses to a new task without fine-tuning or configuring the model. Unlike a zero-shot request, the model sees examples of the desired behavior; unlike fine-tuning, the examples do not require further training on a dataset. section 5.2
Build the prompt around the behavior users should receive:
- State the model’s role and task, then identify the kinds of requests it must handle. section 5.2.2
- Provide varied example requests paired with suitable responses. Choose examples that demonstrate the tone, content, or format you want. section 5.2.2
- End with an instruction to respond to new requests using those examples. Generate a response, review it, and adjust the prompt if needed. section 5.2.2 section 5.2
Customer support tone
A JavaScript system prompt can assign a customer-support role and show example exchanges for technical support, billing, and general inquiries. For a slow-connection request, the example response acknowledges the problem and asks for speed-test results. For a duplicate-charge request, it acknowledges the concern and offers to investigate. A final directive asks the chatbot to use the appropriate tone and sentiment for the next inquiry. The examples give the model a pattern to follow, not a fixed answer to reuse. section 5.2.1 section 5.2.2
Be precise about the output as well as its style. A programming-language prompt that asks for “some” examples may produce an unexpectedly long list; asking for five makes the requested length clearer. section 5.2.1
Figure 5.5 The step-by-step procedure for few-shot learning, where users provide a few examples to guide the AI model. The process involves compiling these examples into a prompt, generating output using the AI model, and then reviewing and adjusting the output as needed to achieve the desired results.
The workflow diagram shows how examples become a prompt, followed by generation, review, and adjustment. section 5.2

















