The Art of the Prompt
Learn the core techniques of prompt engineering and how to control a model’s persona, rules, and output format using system prompts
We'll cover the following...
For the past two sections, we have built a deep, conceptual understanding of how an LLM works and how it is trained. We are now shifting our focus from theory to practice, and our goal is to become builders.
An aligned LLM is a powerful generalist. But how do we guide its behavior in a specific application? Before writing any complex code, we will focus on the art of communication. In this lesson, we’ll explore prompt engineering, which is the practice of designing effective prompts to control the behavior of a language model.
Prompting techniques
The prompt is the blueprint for the model’s response. It controls the content and context of the answer. Alongside the prompt, we also have generation parameters (like temperature and top_p), which act as the creativity dial, controlling how the model chooses from the possibilities laid out by the blueprint. In this lesson, we will focus on mastering the blueprint itself.
System prompts
Most modern LLM APIs provide a special, high-priority channel for foundational instructions: the system prompt. It is not just another message like a user prompt; the model is specifically fine-tuned during its alignment phase to treat the system prompt as its constitution or prime directive. It’s a “meta-prompt” that instructs the model on how to behave, while the user prompt specifies what to do.
Think of a GPS system. The system prompt is where you set your core preferences at the start of a trip: “Avoid highways,” “I’m driving a large truck,” “Use kilometers.” These are the global rules for the entire journey. A user prompt is the real-time command: “Find the nearest gas station.” The GPS will follow the command, but it will do so within the constraints of the constitution you’ve set.
The system prompt is our most powerful tool for giving our application a persistent persona (a personality), a clear set of rules (its constraints), and a consistent response format. It transforms the model from a ...