Personality-Guided Code Generation Using Large Language Models

Yaoqi Guo, Zhenpeng Chen, Jie M. Zhang, Yang Liu, Yun Ma

Introduction

In software engineering, personality traits significantly influence developer performance and team dynamics. Diverse teams often yield higher-quality software, and individual success frequently depends on the "fit" between a developer's cognitive style and the specific task, such as detail-oriented debugging versus high-level architectural design. While Large Language Models (LLMs) are commonly prompted to "act as a programmer," these generic instructions overlook the nuances of specialized roles. This research investigates whether assigning specific Myers-Briggs Type Indicator (MBTI) personas to LLMs can improve their code generation capabilities by aligning their "personality" with the requirements of a given coding problem.

Methodology

The researchers proposed a two-stage pipeline for Personality-Guided Code Generation:

  1. Personality Generation: A high-performing model (GPT-4o) analyzes a coding problem to identify the most suitable MBTI personality type. It generates a four-letter MBTI code (e.g., INTJ) along with a detailed description of that persona's problem-solving approach.
  2. Code Generation: This persona is integrated into a prompt for the target LLM. The model is instructed to adopt the specific personality and utilize the provided description to solve the coding task.
The two-stage pipeline for personality-guided code generation, involving personality selection and subsequent code generation.

This approach was compared against standard "Direct Prompting" and alternative frameworks like the Big Five personality model.

Experimental Setup

The framework was evaluated using seven LLMs—including GPT-4o, Llama 3.1, and DeepSeek-Coder—across four benchmarks:

  • MBPP Sanitized & MBPP+: Entry-level Python problems with varying test rigor.
  • HumanEval+: Manually curated Python problems with extensive unit tests.
  • APPS: High-difficulty problems ranging from introductory to competitive programming levels.

Results and Analysis

The study found that personality guidance improved performance in 23 out of 28 model-dataset combinations. Key findings include:

  • Performance Gains: Improvements exceeded 5% in 11 cases and 10% in five cases. The most significant gain was a 12.9% increase in pass rates for GPT-4o mini on MBPP Sanitized.
  • MBTI Distribution: While the "Architect" (INTJ) was the most frequently assigned persona due to its logical and strategic nature, the optimal personality varied by task.
Distribution of assigned MBTI types across different benchmarks, showing the prevalence of INTJ and ISTJ personas.
  • Framework Comparison: MBTI outperformed the Big Five model, likely because its dimensions (e.g., Sensing vs. Intuition) map more effectively to programming-related cognitive styles.
  • Model Sensitivity: "Moderate" models benefited most. Top-tier models like GPT-4o showed smaller gains as they are near performance ceilings, while weaker models lacked the reasoning capacity to inhabit complex personas.

Conclusion

Assigning specific MBTI personas to LLMs significantly enhances code generation accuracy, particularly when combined with detailed personality descriptions and Chain-of-Thought prompting. Future work will explore scaling this to multi-file projects and multi-agent collaborative environments where different personas can review and refine each other's work.

Summary updated

BibTeX
@inproceedings{guo2025personality,
  author = {Yaoqi Guo and Zhenpeng Chen and Jie M. Zhang and Yang Liu and Yun Ma},
  title = {{Personality-Guided Code Generation Using Large Language Models}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
}
Figure