Skip to content

Prompting Basics

Foundations 4 min read

In Short

A prompt is the text you send to a language model to elicit a response. Well-structured prompts combine a clear instruction, relevant context, optional examples, and an output format spec. The difference between zero-shot and few-shot is whether you include examples; knowing when to use each is the single most practical skill in prompt engineering.

01. What It Is

A prompt is any input you send to a large language model (LLM). In practice it is the full text the model receives before generating a reply: your question, your instructions, any background data you provide, and any examples you include. Everything the model "knows" about your task in that moment comes from the prompt.

Prompt engineering is the practice of designing and refining that input to consistently get accurate, relevant, and usable output. It sits between raw model capability and what actually ships in a product.

02. Why It Matters

LLMs are probabilistic text predictors. They do not "understand" your intent the way a human would. A vague or poorly structured prompt activates a generic probability distribution over tokens; a precise prompt narrows that distribution toward the answer you actually need. The same underlying model can produce wildly different quality results depending solely on how the prompt is written, with no fine-tuning or retraining involved.

For production applications, prompts are code. They determine behavior, shape safety, and affect cost (token length directly maps to API expense).

03. How It Works

When you send a prompt, the model tokenizes it, runs it through its attention layers, and generates a completion one token at a time. Each generated token is conditioned on all prior tokens, including your prompt. This means:

  • Instruction quality shapes what the model attends to.
  • Position matters: instructions near the end of a long context get slightly more weight than instructions buried in the middle.
  • Format signals (headers, bullet points, code fences) are part of the token stream and influence generation style.

Modern instruction-tuned models (GPT, Claude, Gemini) have been trained via RLHF and instruction tuning to follow natural-language directions, which is why zero-shot prompting often works without examples.

04. Key Techniques and Terms

Zero-shot prompting:
Ask the model to do a task with no examples. Works well for instruction-tuned models on common tasks. Example: classifying sentiment, answering a factual question, summarizing a paragraph. The model draws entirely on pretraining.

Few-shot prompting:
Provide 2 to 5 input-output demonstration pairs inside the prompt before the actual query. This guides the model on format, tone, and reasoning style. Research by Min et al. (2022) found that label space and input distribution in demonstrations matter more than the correctness of individual labels, though correct labels are still better in practice.

Role / persona:
Prefixing the prompt with a role assignment ("You are a senior data engineer") shifts the model's vocabulary, assumed knowledge level, and tone. It does not grant the model new factual knowledge, but it narrows the space of likely responses toward domain-appropriate language.

Output format control:
Specifying structure in the prompt ("Return a JSON object with keys: title, summary, tags") is more reliable than hoping the model chooses a format. Without explicit format instructions, models default to a generic prose style that may be hard to parse programmatically.

Instruction vs. context vs. examples. These are the three building blocks of any prompt:

  • Instruction: the verb-driven directive ("Summarize", "Classify", "Extract").
  • Context: background the model needs to execute the task (the document, the user's role, the product domain).
  • Examples: demonstrations of the desired input-output pattern (few-shot).

05. Examples

Zero-shot classification:

Classify the following customer message as: complaint, question, or compliment.

Message: "Your app crashed twice and I lost all my work."

Category:

Few-shot entity extraction:

Extract the company name and dollar amount from each sentence.

Sentence: "Stripe raised $600M in its Series H."
Result: {"company": "Stripe", "amount": "$600M"}

Sentence: "Databricks closed a $500M round last quarter."
Result: {"company": "Databricks", "amount": "$500M"}

Sentence: "Mistral AI secured $113M from Andreessen Horowitz."
Result:

Role + format control:

You are a senior technical writer at a SaaS company.
Rewrite the following error message for a non-technical end user.
Keep it under 30 words. Use a friendly tone.

Error: "NullPointerException in UserService.getProfile() at line 47"

Rewritten message:

06. Common Mistakes

  1. Too vague. "Tell me about marketing" gives the model nothing to constrain output. Add scope, audience, length, and format.

  2. Missing output format:
    Without a format spec the model invents one. If downstream code parses the response, the format must be explicit.

  3. Cramming multiple tasks into one prompt:
    "Summarize this document, translate it to French, and list action items" produces mediocre results for all three. Break it into separate prompts or use prompt chaining.

  4. Ignoring the audience spec:
    "Explain quantum entanglement" produces a PhD-level answer by default. "Explain quantum entanglement to a 12-year-old" produces something actually usable.

  5. Never iterating:
    A first-draft prompt is rarely optimal. Prompt engineering is empirical: run it, inspect the failure mode, adjust one variable, run again.

  6. Assuming the model has context you didn't provide:
    The model has no memory of past sessions (unless explicitly provided). Every prompt is a fresh start.

Verified against primary sources

Every claim traces to a cited source below.

Key terms

Prompt
The full text you send a model before it generates a reply.
Zero-shot
Prompting with no examples included.
Few-shot
Prompting with a few examples of the desired output.

Tags

#prompting #prompt-engineering #zero-shot #few-shot #llm

More in Prompting