P
Prompt Master
Prompt 大师

掌握和 AI 对话的艺术

Elements

instruction / context / input data / output indicator

If you've seen enough prompt engineering examples and applications, you'll notice that prompts tend to share common building blocks.

A prompt can contain any of the following elements:

  • instruction: The specific task or directive you want the model to perform
  • context: External or additional background information that helps the LLM respond better
  • input data: The content or question from the user
  • output indicator: The expected type or format of the output

Here's a simple prompt for a text classification task that shows these elements in action:

Prompt

Classify the text as neutral, negative, or positive.
Text: I think the food is okay.
Sentiment:

In this example, the instruction is "classify the text as neutral, negative, or positive." The input data is "I think the food is okay." The output indicator is "Sentiment:". No context was used here, but you could provide it — like adding more examples to help the model understand the task better and guide its output.

Not every element is required for every prompt. It depends on the task.

How to write the four core elements

Instruction

The instruction should make it immediately obvious what you want the model to do. Start with a verb: Summarize / Extract / Translate / Generate / Explain / Classify / Sort. If you want a specific style or audience, bake it right into the instruction.

Example

Summarize the following content in 3 bullet points, targeting product managers.

Context

Context is "the information the model needs to give a correct answer" — role definition, business background, relevant knowledge, constraints, examples, data sources. The more relevant the context, the more stable the output. But too much noisy context can actually distract the model.

Example

You are an e-commerce customer service agent. Keep your tone friendly but concise. The brand emphasizes "great value" and "30-day returns."

Input Data

This is the actual text, question, or data you want processed. Use clear delimiters (like """, ###, or XML tags) to wrap the input — it reduces the chance the model misinterprets things.

Example

Input:
"""
Customer review: Shipping was fast, but the packaging was damaged.
"""

Output Indicator

The output indicator determines what the output looks like. You can specify format (table, JSON, bullet points), fields, ordering, length, or language.

Example

Output format:
- Conclusion:
- Evidence:
- Recommendation:

A complete four-element example

### Instruction
Classify the user feedback into: Logistics / Product Quality / Service / Price, and provide a one-sentence summary.

### Context
You are an e-commerce operations analyst. You need to quickly identify the issue type so it can be routed to the right team.

### Input
"""
The headphones I bought last week have great sound quality, but they're a bit loose. Customer service responded quickly, and the exchange was smooth.
"""

### Output
Category: <Logistics|Product Quality|Service|Price>
Summary: <one sentence>

The instruction defines the classification task, the context provides the business scenario, the input is the review content, and the output indicator locks down the fields and format.

Common combinations

  1. instruction + input data Best for simple tasks like translation, summarization, or rewriting.

  2. instruction + context + input data Best for real business scenarios (with roles, rules, constraints).

  3. instruction + context + output indicator Best for generation tasks with no input data, like writing marketing copy or building plans.

Practical output format patterns

When output needs to feed into downstream systems (automation pipelines, data analysis, database imports), use explicit formats:

JSON

Output JSON with these fixed fields:
{
  "category": "string",
  "summary": "string",
  "confidence": 0-1
}

Table

Output a table: Issue Type | Impact Level | Recommended Action

Bullet points

Output 3-5 bullet points, each no longer than 20 words.

Tips for designing prompts

  • Start simple, then gradually add context and format constraints
  • The more specific your instructions, the more stable your results
  • Use clear delimiters to separate instructions, context, input, and output
  • Tell the model what to do, not what not to do
Prompt Lab

Turn this chapter's knowledge into practical skills

Enter the interactive lab and practice Prompt with real tasks. Get started in 10 minutes.

View Now

📚 Related resources

Common questions

Open a question to review the practical answer.

What are the four core elements of a prompt?

Instruction (the action verb—classify, extract, translate), Context (role, business rules, source knowledge), Input Data (the actual text or data to process), and Output Indicator (output format, like `Sentiment:` or a JSON schema). Not every prompt needs all four, but the more complex the task, the more you should fill in.

Why wrap input data in triple quotes or XML tags?

Without delimiters, the model can mistake the input body for new instructions—if a user review says 'ignore previous instruction,' the prompt breaks. Wrapping with `"""`, `###`, or `<input></input>` makes it obvious to the model that the content is data, not commands. It's the simplest defense against unintentional prompt injection.

Is 'output JSON' enough as an output indicator?

Not nearly. Lock down field names, types, and value ranges, e.g. `{"category":"string","summary":"string","confidence":0-1}`. With just 'output JSON,' the model improvises keys, nesting depth, and null/undefined—your downstream parser breaks. Anything feeding automation or a database needs a fully pinned schema.

What task type fits each of the three common prompt combinations?

Instruction + Input Data fits the simplest transformations—translation, summarization, rewriting. Instruction + Context + Input Data fits real-business scenarios with roles and rules (e-commerce ticket triage, contract clause review). Instruction + Context + Output Indicator fits no-input generation tasks like marketing copy or project plans.

Why prefer 'do this' over 'don't do that' in prompts?

Negative instructions are unreliable for probability models—'Do not ask about interests' often fails because the 'ask about interests' path still has high probability. A positive instruction—'Recommend from globally trending movies; if you can't, reply Sorry, I can't find a movie recommendation today'—is far more stable in practice.