When working with message roles like system, user, and assistant in AI chat models, the key metric is accuracy of role classification or correct role assignment. This ensures the model understands who is speaking and responds appropriately. For example, the system role sets instructions, the user role asks questions, and the assistant role replies. Correct role recognition helps the AI behave as expected.
Message roles (system, user, assistant) in Prompt Engineering / GenAI - Model Metrics & Evaluation
Start learning this pattern below
Jump into concepts and practice - no test required
| Predicted \ Actual | System | User | Assistant |
|--------------------|--------|------|-----------|
| System | 90 | 5 | 5 |
| User | 3 | 92 | 5 |
| Assistant | 2 | 4 | 94 |
Total samples = 300
Precision and recall per role:
- System Precision = 90 / (90 + 3 + 2) = 90 / 95 = 0.947
- System Recall = 90 / (90 + 5 + 5) = 90 / 100 = 0.9
- User Precision = 92 / (5 + 92 + 4) = 92 / 101 = 0.910
- User Recall = 92 / (3 + 92 + 5) = 92 / 100 = 0.92
- Assistant Precision = 94 / (5 + 5 + 94) = 94 / 104 = 0.904
- Assistant Recall = 94 / (2 + 4 + 94) = 94 / 100 = 0.94
In message role classification, precision means how often the predicted role is correct. Recall means how many actual messages of a role were found.
If precision is low, the model confuses roles often, causing wrong responses. If recall is low, some messages are missed or misclassified, leading to ignored instructions or questions.
Example: If the system role is confused with user role, the AI might ignore important instructions. Here, high recall for system role is critical to catch all instructions.
Example: If user messages are misclassified as assistant, the AI might respond to itself, causing confusion. High precision for user role avoids this.
Good: Precision and recall above 90% for all roles means the model correctly identifies who is speaking most of the time.
Bad: Precision or recall below 70% means many messages are misclassified. For example, if system role recall is 50%, half of instructions are missed, causing poor AI behavior.
- Accuracy paradox: If one role is very common, high accuracy can hide poor performance on rare roles.
- Data leakage: Training data containing future messages can inflate metrics falsely.
- Overfitting: Model memorizes training roles but fails on new conversations.
- Ignoring role context: Metrics without considering conversation flow can mislead about real performance.
Your model has 98% accuracy but only 12% recall on the system role. Is it good for production? Why or why not?
Answer: No, it is not good. Even though overall accuracy is high, the model misses 88% of system messages (instructions). This means important instructions are ignored, causing the AI to behave incorrectly. High recall on system role is critical.
Practice
system role in AI chat messages?Solution
Step 1: Understand the roles in AI chat
Thesystemrole is designed to give the AI instructions or context on how to respond.Step 2: Differentiate from other roles
Theuserrole is for input, and theassistantrole is for AI output, so setting instructions fits thesystemrole.Final Answer:
To set instructions and guide the AI's behavior -> Option CQuick Check:
System role = instructions [OK]
- Confusing system role with user input
- Thinking assistant role sets instructions
- Assuming system role stores chat history
Solution
Step 1: Identify the role for user input
The user messages must have the role set to "user" to indicate input from the person.Step 2: Check each option's role field
{"role": "user", "content": "What is AI?"} uses "user" correctly, while others use "assistant", "system", or invalid "bot".Final Answer:
{"role": "user", "content": "What is AI?"} -> Option BQuick Check:
User role = "user" [OK]
- Using "bot" instead of "assistant" or "user"
- Mixing system role with user messages
- Forgetting to set the role field
[{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"}]What role will the AI use to respond?
Solution
Step 1: Understand message roles in conversation
The AI responds with messages having the role "assistant" to show its output.Step 2: Identify the role for AI replies
Since the input messages include system and user roles, the AI's reply will be labeled as "assistant".Final Answer:
assistant -> Option DQuick Check:
AI replies use role "assistant" [OK]
- Thinking AI replies use "system" role
- Confusing user input role with AI output
- Assuming unknown roles like "moderator"
[{"role": "system", "content": "Be concise."}, {"role": "user", "content": "Explain AI."}, {"role": "user", "content": "Tell me more."}]Why might the AI ignore the second user message?
Solution
Step 1: Check message sequence rules
AI expects alternating user and assistant messages; two user messages in a row can cause confusion.Step 2: Identify the problem in the message list
Here, two user messages come one after another without an assistant reply, so the AI may ignore the second user message.Final Answer:
Because there are two user messages without an assistant reply in between -> Option AQuick Check:
Messages alternate user-assistant-user [OK]
- Thinking system role is missing
- Assuming assistant role used twice
- Believing empty messages cause ignoring
Solution
Step 1: Place instructions in the system role
Instructions for AI behavior must be in the system message before user input.Step 2: Check message order and roles
[{"role": "system", "content": "You are a friendly tutor. Answer clearly."}, {"role": "user", "content": "Explain math."}] correctly puts the system message first with instructions, then the user question.Final Answer:
[{"role": "system", "content": "You are a friendly tutor. Answer clearly."}, {"role": "user", "content": "Explain math."}] -> Option AQuick Check:
System message first with instructions [OK]
- Putting system message after user input
- Using assistant role for instructions
- Starting with user message without system context
