Abstract
The rapid advancement of Large Language Models (LLMs) has significantly improved code generation, yet most models remain text-only, neglecting crucial visual aids like diagrams and flowcharts used in real-world software development. To bridge this gap, we introduce M²-CODER (also referred to as MM-Coder), a Multilingual Multimodal software developer. M²-CODER integrates visual design inputs—Unified Modeling Language (UML) diagrams and flowcharts (termed Visual Workflow)—with textual instructions to enhance code generation accuracy and architectural alignment. To enable this, we developed $M^2C$-INSTRUCT, a diverse multimodal instruction-tuning dataset including visual-workflow-based code generation, allowing M²-CODER to synthesize textual and graphical information like human developers. Furthermore, we introduce $M^2EVAL$, a new benchmark for evaluating multimodal code generation. Our evaluations highlight significant remaining challenges for models in precise visual information capture, yet demonstrate that M²-CODER achieves performance competitive with models ten times its size.
The Multimodal Gap in Software Engineering
While Large Language Models have become remarkably proficient at writing code from text prompts, they are largely "blind" to the way humans actually design software. In industrial settings, developers rarely rely on text alone; they utilize Visual Workflows—UML diagrams, flowcharts, and UI mockups—to communicate complex logic and system architecture.
Existing code models struggle with these inputs because they are trained almost exclusively on text. When a software architect provides a flowchart, a text-only model misses the structural constraints and logic flow. M²-CODER addresses this by creating a multimodal developer capable of interpreting both technical specifications and visual diagrams to generate architecturally aligned code across over 50 programming languages.
Methodology: Two-Stage Supervised Fine-Tuning
The development of M²-CODER utilizes a two-stage Supervised Fine-Tuning (SFT) framework, using Qwen2-VL-7B as the foundational base:
- Stage 1: Foundational Visual Understanding: The model is trained on a massive scale (12.9M samples) to establish strong OCR (Optical Character Recognition) and information extraction capabilities. This stage aligns code snippets with their visual representations to ensure the model can "read" technical imagery.
- Stage 2: High-Quality Instruction Following: The model is further refined on a smaller, high-quality dataset (168K samples) specifically focused on Visual Workflow tasks. This teaches the model to synthesize information from a diagram to solve programming problems where the text alone is insufficient.
A key technical contribution is the data construction pipeline. It uses LLMs to generate diagrams from code (via PlantUML/Mermaid) and then "refines" the prompts to ensure the diagram contains essential information missing from the text, forcing the model to rely on visual reasoning to succeed.
Data Resources: $M^2C$-INSTRUCT and $M^2EVAL$
The paper introduces two major resources to the research community:
- $M^2C$-INSTRUCT: A colossal multimodal instruction-tuning dataset containing 13.1 million instances across 50+ programming languages. It includes "Cross-Modal" problems (rendering code as images) and "Diagram" problems (generating code from logic diagrams).
- $M^2EVAL$: A new execution-based benchmark for evaluating multimodal code generation. It consists of 300 problems across 10 programming languages (Python, Java, C++, JS, etc.). Unlike previous benchmarks that focus on simple image-to-code rendering, $M^2EVAL$ requires the model to implement functional logic described in diagrams.
Experimental Results and Insights
Our evaluations reveal that diagrams are non-redundant; top-tier text-only models like DeepSeek-V3 and Qwen2.5-Coder scored 0% on $M^2EVAL$, confirming that visual input is mandatory for these tasks.
M²-CODER-7B achieved an average Pass@1 score of 25.3% across all languages, significantly outperforming other open-source models in its size class, such as InternVL3-8B (15.3%). Notably, the 7B-parameter M²-CODER outperformed or matched much larger models, such as the 72B Qwen2-VL-Instruct, on several tasks. This suggests that specialized multimodal data is more critical than raw parameter count for the software engineering domain.
Despite these gains, a "Visual Reasoning" gap remains. Even the strongest proprietary model, GPT-4o, reached only 49.7% accuracy. The primary failure mode is "visual hallucination"—failing to capture precise details from diagrams, such as missing a specific method in a class diagram. Additionally, models show a performance bias toward Python and JavaScript, likely due to the distribution of their text-based pre-training data.
Conclusion and Future Directions
M²-CODER represents a significant step toward industrial-grade AI software developers. By bridging the gap between visual design and functional code, it enables LLMs to interpret complex specifications more like human engineers. Future work will focus on expanding the task scope to include multimodal debugging and completion, as well as exploring "long thinking" paradigms to help models better parse complex, multi-step logic within flowcharts before code synthesis begins.
Summary updated