The input text or instruction provided to a language model that guides its response, ranging from simple questions to complex, structured instructions with examples, context, and constraints.
A prompt is like a question or request you give to an AI. If you ask “What’s the weather?” you’ll get a generic response. But if you ask “What’s the weather in San Francisco today, and should I bring an umbrella?” you’ll get a much more useful, specific answer.
The quality of your prompt directly affects the quality of the AI’s response. A vague prompt gets a vague answer. A clear, specific prompt gets a clear, specific answer. That’s why “prompt engineering” — the art of writing effective prompts — has become an important skill.
In the context of large language models, a prompt is the complete input provided to the model, which typically includes:
Components of a Prompt:
Prompt Structure (Modern Chat Models):
[
{"role": "system", "content": "You are a helpful coding assistant."},
{"role": "user", "content": "Explain what a prompt is."}
]
Types of Prompts:
Prompt Engineering Techniques:
Prompt Anatomy:
Prompts are the primary interface between humans and AI, making prompt quality critical for enterprise success:
Why Prompts Matter:
Enterprise Prompt Management:
Prompt Engineering as a Skill:
Writing a brief for a freelancer. If you say “Write something about dogs,” you’ll get something generic. If you say “Write a 500-word blog post for first-time dog owners about choosing the right breed, focusing on apartment-friendly dogs, with a friendly and encouraging tone,” you’ll get something valuable. The prompt is your brief — the more specific and clear it is, the better the result.
# Different prompt structures and their effects
from openai import OpenAI
client = OpenAI()
# 1. Simple prompt (zero-shot)
simple_prompt = "What is machine learning?"
response = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": simple_prompt}]
)
print("Simple:", response.choices[0].message.content[:100])
# 2. Structured prompt with system message and constraints
structured_prompt = [
{"role": "system", "content": "You are a technical writer. Explain concepts clearly and concisely."},
{"role": "user", "content": "Explain machine learning in exactly 2 sentences for a non-technical audience."}
]
response = client.chat.completions.create(
model="gpt-4",
messages=structured_prompt
)
print("Structured:", response.choices[0].message.content)
# 3. Few-shot prompt with examples
fewshot_prompt = """
Classify the sentiment of customer reviews as Positive, Negative, or Neutral.
Example 1:
Review: "The product arrived quickly and works perfectly!"
Sentiment: Positive
Example 2:
Review: "Terrible quality. Broke after one use."
Sentiment: Negative
Now classify this review:
Review: "It's okay. Does what it's supposed to do, nothing more."
Sentiment:"""
response = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": fewshot_prompt}]
)
print("Few-shot:", response.choices[0].message.content)
Reality: Prompts can include system instructions, context, examples, constraints, and output specifications. They’re much more than simple questions.
Reality: Prompts are context-dependent. The best prompt varies by model, use case, and audience. Continuous iteration is key.
Reality: Anyone who can clearly articulate what they want can write effective prompts. It’s a communication skill, not a coding skill.