Research Careers Contact

GlossaryPrompt engineering

Prompt engineering

Prompt engineering is the practice of writing and refining the prompt, the full input a language model receives, so the model produces the output a task needs. A prompt holds the instructions, the task, any examples and any supporting material such as documents, data or prior conversation. Everything the model sees in one request is part of it.

How it works

A prompt for a production task usually has several parts: a system message with the role, rules and output format, the material the answer should use, such as retrieved documents or tool results, examples of good output and the request itself. Each part is a lever. Clear rules cut ambiguity. Examples show the model a pattern to copy, which is few-shot prompting. A defined format, or structured output, makes results readable by code. The whole prompt has to fit in the model's context window.

Prompting surveys describe the field as designing inputs that steer a pretrained model toward a task without changing its weights. In practice the work is iterative: run the prompt on a set of real inputs, read the failures, change one thing and run it again.

The practice has widened. Early advice centered on wording, such as asking a model to work through intermediate steps, which a 2022 paper showed improves multi-step answers. Reasoning models do that on their own and need less step-by-step instruction. For agents, the larger job is context engineering: choosing which instructions, documents, tool outputs and memory go into the window at each step.

Prompt engineering vs fine-tuning

Prompt engineering changes the input. Fine-tuning changes the model by training it on examples. Prompting is faster to change and needs no training data or infrastructure. Fine-tuning suits tasks where prompts alone cannot reach the needed consistency, or where a smaller, cheaper model has to learn a narrow job. A common path is to start with prompts and fine-tune only when prompting reaches its limits.

Why it matters

The same model gives very different results depending on how it is asked. A vague prompt produces vague or invented output, and the failures show up as wrong data downstream. A well-built prompt, kept under version control and tested on real cases, turns a general model into a dependable component.

How to get it right

  • State the goal, the rules and the output format explicitly.
  • Supply the source material the answer must use, and say to use only that material.
  • Include examples that cover common and tricky cases.
  • Treat text from documents and users as data, separate from instructions.
  • Test every change on a fixed set of real inputs, one change at a time.
  • Keep prompts under version control with a note on why each change was made.

Prompt engineering in robotics and drone hardware

Prompts for hardware tasks need the vocabulary and rules of the work: part number formats, units, design rule names and the fields a BOM or test record must contain. A prompt for reading a datasheet into a parts record names each field, such as package, temperature range and MSL, shows one correctly filled record and requires structured output, so engineers can check every value against the page it came from. Tested prompts for recurring jobs, such as BOM review, keep results consistent across boards and engineers.

Learn more