Prompt Engineering
Prompt engineering designs the instructions and context given to large language models to elicit accurate, useful responses. It covers prompting strategies like few-shot examples, chain-of-thought reasoning, system prompts, and the iterative testing that improves model output quality for specific tasks.
itArtificial intelligence and machine learning | OpenSkills.info
Course pathWalk it in order
Look it upDip in anytime
Go furtherLeaves this page
Don't Panic
Don't Panic — Prompt Engineering
Prompt engineering is the practical art of telling a language model what job it has, what material it may use, and what shape the answer must take. The model is not reading intent from the air, regrettably. It has the text in front of it, plus its training, and it makes the next token choice from there.
That makes the prompt less like a magic phrase and more like a specification with an unusually talkative implementation. A vague request leaves the implementation to fill in decisions you had already made somewhere behind your forehead. A clear task, constraints, context, and format move those decisions into the part of reality the model can inspect.
The first useful trick is structure. Put instructions apart from reference data, and label the pieces. The second is few-shot prompting, which means showing a few input-and-output examples when the desired pattern is easier to demonstrate than describe. The third is an eval: a repeatable test that checks whether the prompt meets stated success criteria. This is the bit that turns “that answer looked good” into evidence, which is less glamorous but survives Tuesday.
One surprise waits in the middle of all this: the same prompt is not permanently solved. A different model or model version can respond differently, and a prompt that behaves on one tidy example can fail on an unfamiliar input. Pin the model version when consistency matters, keep a varied test set, and change one thing at a time. Otherwise every revision becomes a small archaeological dig through your own decisions.
Prompt engineering also has borders. If the model needs information outside its training, use retrieval-augmented generation, which places relevant documents in the request. If output must feed software, specify a structured format and validate it. If the task is deterministic, ordinary code is often the more cooperative creature. If edge cases still fail after measured revisions, a new prompt may not be the remedy.
Read the Intro for the map of prompts, roles, context, and evaluation. Use the Slides to see the relationships at a glance. Keep the Cheatsheet nearby when shaping a task, and use the practice reference and exercise to build an evaluation loop rather than collecting impressive-looking prompts in a drawer. The reference links then lead into the model-specific rules, where the details inevitably change their hats.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://platform.openai.com/docs/guides/prompt-engineering
Supports
- Prompt engineering is the process of writing effective instructions for a model so it consistently generates content meeting requirements
- Message roles (developer, user, assistant) with differing authority levels
- Developer messages provide system rules, user messages provide inputs (function and arguments analogy)
- Few-shot learning with diverse examples steers model toward new tasks
- Markdown and XML formatting to mark logical boundaries and communicate hierarchy
- Prompt structure sections (identity, instructions, examples, context) in recommended order
- Including relevant context (RAG) to give models access to data outside training
- Context window limits defined in tokens per model
- GPT models benefit from precise explicit instructions
- Reasoning models work better with high-level guidance and less micro-management
- Pinning production apps to specific model snapshots for consistent behavior
- Building tests and evaluation suites to measure prompt behavior
- https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/overview
Supports
- Prompt engineering requires clear success criteria and empirical testing before starting
- Not every failing eval is best solved by prompt engineering (latency and cost may need model selection instead)
- Techniques covered include clarity, examples, XML structuring, role prompting, thinking tags, and prompt chaining
- Interactive tutorial with nine chapters and exercises for hands-on practice
- https://ai.google.dev/gemini-api/docs/prompting-strategies
Supports
- Prompt design is creating natural language requests that elicit accurate high-quality responses from a language model
- Clear instructions, examples, and output constraints as core strategies
- Iterative testing and refinement as standard practice
- https://cookbook.openai.com/examples/gpt4-1_prompting_guide
Supports
- Prompting practices evolve between model versions and require prompt migration
- Context examples, specific clear instructions, and inducing planning via prompting maximize model intelligence
- AI engineering is empirical and nondeterministic requiring informative evals and frequent iteration
- https://arxiv.org/abs/2005.14165
Supports
- GPT-3 evaluates tasks specified through text interaction and few-shot demonstrations without gradient updates
- The 2020 GPT-3 paper established few-shot prompting as a practical adaptation pattern
- https://arxiv.org/abs/2104.08691
Supports
- Prompt tuning uses learned soft prompts as a parameter-efficient adaptation method
- The paper distinguishes learned prompts from discrete text prompts
- https://openai.com/index/instruction-following/
Supports
- InstructGPT research reports models trained to follow instructions using human feedback
- The work was published in January 2022
- https://arxiv.org/abs/2201.11903
Supports
- Chain-of-thought prompting uses demonstrations with intermediate reasoning steps
- The paper was first published in January 2022
- https://openai.com/index/chatgpt/
Supports
- ChatGPT launched on November 30, 2022 as a conversational model
- ChatGPT is a sibling model to InstructGPT and is trained to follow instructions
- https://openai.com/index/gpt-4-api-general-availability/
Supports
- The Chat Completions API provides a structured message interface and multi-turn conversation capabilities
- Structural separation of user content from instructions can reduce prompt injection risk
- https://openai.com/index/function-calling-and-other-api-updates/
Supports
- Function calling was announced on June 13, 2023
- Models can return JSON arguments matching described functions
- https://arxiv.org/abs/2305.10601
Supports
- Tree of Thoughts was published in May 2023 and explores multiple intermediate reasoning paths
- https://openai.com/index/introducing-structured-outputs-in-the-api/
Supports
- Structured Outputs was introduced on August 6, 2024
- Structured Outputs constrains supported model responses to developer-supplied JSON Schemas
- https://www.langchain.com/langsmith/evaluation
Supports
- LangSmith supports prompt iteration, datasets, and multiple evaluator types
- https://humanloop.com/docs/getting-started/overview
Supports
- Humanloop provides prompt management, evaluation, and observability for LLM applications
- https://www.promptlayer.com/
Supports
- PromptLayer supports prompt management, evaluation, and observability
- https://www.braintrust.dev/
Supports
- Braintrust provides evaluation workflows for AI applications
- https://www.vellum.ai/
Supports
- Vellum provides prompt and workflow development with evaluation support
