Why role prompting works
LLMs are trained on text written by many different types of authors. When you assign a role — 'You are a senior security engineer' — you activate a specific subspace of the model's knowledge and writing style that is associated with that role. The model produces responses more consistent with how a security engineer would actually write.
Research shows that specific, credible roles improve performance on domain-specific tasks by 10–30% compared to a generic 'helpful assistant' instruction. The effect is strongest for tasks with a clear expert community: medical, legal, engineering, and scientific domains.
Craft an effective persona
A good persona has four elements: (1) a specific professional title ('Senior Machine Learning Engineer at a fintech company'), (2) a relevant specialisation ('specialising in model deployment and MLOps'), (3) a communication style ('you communicate clearly with both technical and non-technical stakeholders'), and (4) a quality standard ('you give concrete, actionable advice rather than theoretical overviews').
Avoid vague roles like 'expert' or 'professional'. Specificity activates better associations. 'Expert data scientist' is weaker than 'A data scientist at a hedge fund who has built production ML pipelines for 10+ years and is known for catching edge cases that others miss.'
Role prompting for adversarial tasks
For code review, use: 'You are a security-conscious senior engineer doing a thorough code review. Your job is to find bugs, security vulnerabilities, and performance issues — not to be polite about the code quality. Be direct and prioritise issues by severity.'
For writing feedback: 'You are an editor at a major publication who has read thousands of articles. Your job is to identify structural problems, weak arguments, and unclear prose. Do not soften your feedback — the author wants honest critique, not encouragement.'
When role prompting helps most
Role prompting has the biggest impact on: domain-specific writing (medical, legal, technical), code review and debugging, explaining complex topics, and tasks where tone and register matter (executive communication, customer service).
It has minimal impact on factual recall, mathematical calculation, or tasks where the output is highly constrained (classification, structured data extraction). For these tasks, focus on clear instructions and output format specifications instead.