LLM Basics
Lesson 4 of 6

System Prompts & Role Framing

If you've taken the AI Security course, lesson 1 there covered this exact mechanism: a system prompt is just tokens at the front of the context window, and models are trained to give those tokens extra weight. That fact is a vulnerability when someone else controls what's in the context. It's also a feature when you control it: a well-written system prompt is the single highest-leverage lever you have over a model's tone, format, and constraints.

Predict before you look

Same user request — write a product description — sent with and without a system prompt defining a persona and constraints. Before you look: how different do you expect the two outputs to be?

Without a system prompt, the model defaulted to a generic, verbose spec-sheet format — bullet points, a technical specifications table, even a fabricated "12 months battery life" and exact key count that weren't asked for or grounded in anything (a small, concrete reminder that an unconstrained model will confidently invent specifics). With a system prompt defining a persona ("upbeat, concise e-commerce copywriter"), a structural constraint ("exactly one standout feature"), a length limit ("two sentences"), and an ending requirement (a call to action), the output hit every constraint precisely.

Notice what's happening mechanically: none of those constraints are new capabilities — the model always could write two concise sentences. The system prompt just put clear, early, high-weighted tokens in the context window specifying which of the model's many possible outputs to produce.

What made the role-based system prompt effective here?