Glossary termPractice

Prompt Engineering

Also known as: Prompt design

The practice of designing and refining instructions, examples and context given to a generative AI model to obtain more useful and reliable outputs.

Prompt engineering is the craft of communicating with generative models. Because large language models respond to the full text they are given, the wording, structure and content of a prompt strongly influence the result. Common techniques include stating the task and audience clearly, assigning a role, providing relevant documents, giving worked examples (few-shot prompting), specifying an output format and asking the model to reason step by step. For image generators, prompts describe subject, style, composition and lighting, sometimes with lists of things to avoid.

The practice emerged with GPT-3 in 2020, whose developers showed that tasks could be specified through examples in the prompt rather than through retraining, a capability known as in-context learning. Research then documented techniques such as chain-of-thought prompting, self-consistency and decomposition of complex tasks into steps. In building applications, prompt engineering broadened into managing whole contexts: system instructions, retrieved documents, tool descriptions and conversation history, a discipline sometimes called context engineering.

Prompt engineering lowered the barrier to using AI, since anyone who can write clearly can steer a capable model. It is also fragile: small wording changes can shift outputs, and techniques that help one model may not help another. As models have become better at following plain instructions, elaborate tricks matter less than clear goals, good examples and relevant context. Prompting is not a security boundary; instructions can be overridden by prompt injection or jailbreaks, so safeguards must exist outside the prompt as well.

Key points

  • Prompt wording, structure, examples and context strongly shape generative model outputs.
  • Few-shot prompting, specifying formats and requesting step-by-step reasoning are long-standing techniques.
  • In applications, prompt work extends to managing the entire context supplied to a model.
  • Prompts are not a security control, since they can be overridden by injected or adversarial text.

Related entries

Glossary term

Ability of a language model to perform a task from instructions or examples given in its prompt, without any change to its trained weights.

Glossary term

Prompting technique that has a language model write out intermediate reasoning steps before its final answer, often improving accuracy on complex problems.

Glossary term

The maximum amount of input, measured in tokens, that a language model can take into account at once, including the text it is generating.

Glossary term

Prompt Injection

AICybersecurity

Security vulnerability in which crafted text causes an AI model to follow an attacker's instructions instead of those of its developer or user.

Glossary term

Neural network trained on very large amounts of text to predict the next token, able to generate language and perform many tasks from prompts.

Glossary term

Technique that improves a language model's answers by first retrieving relevant documents and supplying them to the model as context.

Glossary term

Further training of a pretrained model on a smaller, task-specific dataset so that it adapts its behavior to a particular domain, style or task.

Referenced by

Other entries that discuss or point to Prompt Engineering.