Role-based prompting
When you ask a random person on the street to explain quantum physics, you get a different answer than asking a physics professor. LLMs work the same way. By assigning a role or persona, you activate domain-specific knowledge and set the tone for the entire response.
Persona prompting
How system prompts shape LLM behavior into different roles
Here is a simple role prompt: Without role: "Explain recursion" Result: A generic, textbook-like answer. With role: "You are a grumpy 10-year-old student who just learned about recursion and thinks it is the coolest thing ever. Explain recursion." Result: An enthusiastic, simple explanation with personality. The role changes not just what the model says, but how it says it.
Use the system prompt for persistent roles that apply to the whole conversation (like "You are a senior Python developer"). Use the user message for one-off personas. System prompts are processed before user messages, making them ideal for setting consistent behavior across multiple turns.
AI prompt: Try it with AI
Loading practice…
Quiz: Quiz
Loading practice…
Fill in the blanks: Build a system prompt
Loading practice…
Flashcards: Flashcards
Loading practice…
Validation checklist: Role-based prompting checklist
Loading practice…