Concept Beginner · 3 min read

What is zero-shot prompting

Quick answer
Zero-shot prompting is a technique where a language model is given a task instruction without any examples and is expected to generate the correct output based solely on the prompt. It leverages the model's pre-trained knowledge to perform tasks without fine-tuning or few-shot demonstrations.
Zero-shot prompting is a prompt engineering technique that instructs a language model to perform a task without any example inputs or outputs, relying solely on the task description.

How it works

Zero-shot prompting works by providing the language model with a clear and explicit instruction describing the task, without any example data. The model uses its extensive pre-trained knowledge to interpret the instruction and generate an appropriate response. Think of it like giving a skilled professional a new assignment with only a verbal description, expecting them to apply their expertise without prior demonstration.

Concrete example

Here is a Python example using the OpenAI SDK to perform zero-shot prompting with the gpt-4o model. The prompt instructs the model to translate English to French without any examples:

python
import os
from openai import OpenAI

client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])

prompt = "Translate the following English sentence to French: 'The weather is nice today.'"

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": prompt}]
)

print(response.choices[0].message.content)
output
Le temps est agréable aujourd'hui.

When to use it

Use zero-shot prompting when you want quick task execution without preparing example inputs or outputs. It is ideal for tasks where the model's general knowledge suffices, such as simple translations, summarizations, or answering factual questions. Avoid zero-shot when task complexity requires specific formatting or domain knowledge better conveyed through few-shot examples.

Key terms

TermDefinition
Zero-shot promptingProviding a task instruction without examples for the model to perform.
Few-shot promptingGiving a few input-output examples in the prompt to guide the model.
PromptThe input text or instruction given to the language model.
Language modelA neural network trained to generate or understand text.

Key Takeaways

  • Zero-shot prompting requires only a clear task instruction without examples.
  • It leverages the model's pre-trained knowledge to perform new tasks immediately.
  • Use zero-shot for straightforward tasks where examples are unnecessary.
  • Few-shot prompting is better for complex or domain-specific tasks.
  • Always craft precise instructions to maximize zero-shot performance.
Verified 2026-04 · gpt-4o
Verify ↗