System Prompts and Role Prompting: Shape LLM Persona and Behavior

Learn how to use system prompts and role assignment to control LLM tone, constraints, and default behaviors for entire conversations.

🔰 beginner
⏱️ 60 minutes
👤 SuperML Team

· AI Engineering · 2 min read

🎯 What You'll Learn

  • Understand and apply the core concepts covered in this lesson

What is a System Prompt?

A system prompt is processed before the conversation starts and sets the model’s behavior for all subsequent messages. It’s where you define:

  • Who the model is (role)
  • What it’s for (purpose)
  • What it should/shouldn’t do (constraints)
  • How it should communicate (style)

Anatomy of a Good System Prompt

You are a senior data analyst at a fintech startup. [ROLE]

Your job is to answer questions about our transaction data and help the team understand trends and anomalies. [PURPOSE]

Guidelines:
- Always cite the specific metric or data point that supports your answer [CONSTRAINT]
- If you don't have enough data to answer confidently, say so [CONSTRAINT]
- Keep responses concise — max 150 words unless asked for detail [STYLE]
- Use bullet points for lists of more than 3 items [FORMAT]
- Tone: professional but accessible to non-technical stakeholders [STYLE]

Role Prompting

Assigning a role changes how the model frames its knowledge and tone:

RoleEffect
Senior software engineerMore rigorous, uses technical terminology
Technical writerClearer structure, accessible language
Devil’s advocateChallenges assumptions, identifies risks
Socratic tutorAsks questions rather than giving answers

Constraints That Work

  • Output length: “Keep responses under 200 words”
  • Uncertainty: “If unsure, say ‘I don’t know’ rather than guessing”
  • Scope: “Only answer questions about [topic]. Decline others politely”
  • Format: “Always respond in JSON unless the user asks for plain text”

Part of a structured course

Prompt Engineering Fundamentals

Master prompt engineering from zero — learn to write effective prompts, control LLM behavior, and build reliable AI applications. Free 6-week beginner course.

Lesson 5 of 10 ⏱ 6 weeks beginner Free

Related Tutorials