Improving Gemini’s Ability to Generate Syntactically Correct Mermaid Code
Publication Date
4-20-2026
Document Type
Conference Proceeding
Publication Title
Conference Proceedings IEEE SOUTHEASTCON
DOI
10.1109/southeastcon63549.2026.11476269
Abstract
Google Gemini is a widely used large language model among users involved in computer science, including students, educators, and software developers. An important capability of such models is the generation of visual diagrams, which can help users understand complex computer science concepts such as process scheduling or network protocols. However, Gemini frequently produces syntactically invalid Mermaid code, preventing diagrams from rendering correctly and reducing the usefulness of its responses. This paper presents a lightweight framework designed to improve the syntactic correctness of Mermaid code generated by Gemini. The proposed approach combines retrieval-based guidance, prompt refinement, and iterative correction within an automated wrapper that detects, repairs, and validates invalid diagram code. Experimental results show that the prototype improves the reliability and effectiveness of Gemini's diagram-generation capabilities, increasing its usefulness as a support tool for computer science education and development.
Keywords
diagram generation, large language models, Mermaid, prompt engineering, retrieval-augmented generation
Department
Computer Science
Recommended Citation
Pawan Sarma, David Scot Taylor, Melody Moh, and Teng Sheng Moh. "Improving Gemini’s Ability to Generate Syntactically Correct Mermaid Code" Conference Proceedings IEEE SOUTHEASTCON (2026). https://doi.org/10.1109/southeastcon63549.2026.11476269