Back to Glossary

Zero-Shot and Few-Shot Prompting

Prompting techniques where you give the AI zero or a few examples of the desired output before asking it to perform a task.

Zero-shot prompting means asking the AI to do something without providing any examples. You rely entirely on the model's training to produce the right output. "Translate this to French: Hello, how are you?" is zero-shot: you give the task, not an example.

Few-shot prompting means including a few examples of the desired input/output pattern before your actual request. "Convert these to snake_case: firstName -> first_name, lastName -> last_name. Now convert: userName ->" The examples show the pattern; the AI continues it.

Few-shot prompting is surprisingly powerful for code generation. Showing the AI two or three examples of how you want functions structured, how you name variables, or how you format API responses produces much more consistent output than describing the convention in words.

Related Courses

Links open the course details directly on the Courses page.