[Paper Review] Can We Improve Educational Diagram Generation with In-Context Examples? Not if a Hallucination Spoils the Bunch
The paper proposes an RST-guided in-context learning method for generating educational diagrams with LLMs, evaluates its impact on diagram quality and hallucination, and analyzes how context complexity affects performance. It finds potential reductions in hallucination and context-inconsistency, but notes significant variability due to LLM stochasticity and risk of inherited hallucinations.
Generative artificial intelligence (AI) has found a widespread use in computing education; at the same time, quality of generated materials raises concerns among educators and students. This study addresses this issue by introducing a novel method for diagram code generation with in-context examples based on the Rhetorical Structure Theory (RST), which aims to improve diagram generation by aligning models' output with user expectations. Our approach is evaluated by computer science educators, who assessed 150 diagrams generated with large language models (LLMs) for logical organization, connectivity, layout aesthetic, and AI hallucination. The assessment dataset is additionally investigated for its utility in automated diagram evaluation. The preliminary results suggest that our method decreases the rate of factual hallucination and improves diagram faithfulness to provided context; however, due to LLMs' stochasticity, the quality of the generated diagrams varies. Additionally, we present an in-depth analysis and discussion on the connection between AI hallucination and the quality of generated diagrams, which reveals that text contexts of higher complexity lead to higher rates of hallucination and LLMs often fail to detect mistakes in their output.
Motivation & Objective
- Motivate and address the reliability of AI-generated educational diagrams amid hallucinations in LLM outputs.
- Introduce an RST-based method for selecting in-context demonstrations to guide diagram generation.
- Develop a rubric and evaluation framework for assessing diagram quality (logical organization, connectivity, layout) and hallucinations.
- Empirically compare RST-based ICL variations against zero-shot generation using expert evaluators and automated metrics.
Proposed method
- Define an RST-informed in-context learning (ICL) pipeline for diagram code generation.
- Implement two RST-guided variants (RST1 and RST2) and compare to zero-shot generation.
- Use a similarity-search step to pick demonstrations based on RST structure.
- Prompt LLMs with step-by-step EDU parsing and RST-guided instructions to generate Graphviz dot code.
- Apply iterative repair and refinement steps to ensure renderable diagrams.
- Evaluate diagrams with a five-scale rubric for logical organization, connectivity, and layout, plus hallucination detection (factuality and faithfulness).
- Investigate automated evaluation approaches (implicit/explicit learning and reflection prompts) and compare to human judgments.

Experimental results
Research questions
- RQ1RQ1: Do RST-based in-context examples improve logical organization, connectivity, and layout quality versus zero-shot generation?
- RQ2RQ2: Do LLM-based evaluations of diagrams align with human expert assessments?
- RQ3RQ3: How do hallucinations affect diagram quality across different pipeline steps and contexts?
- RQ4RQ4: Can automated evaluation approaches reliably mirror human judgments for diagram quality and hallucination detection?
Key findings
- RST1 with the o3 model yielded higher quality diagrams for some criteria, and RST-based approaches reduced context inconsistencies and factual hallucinations relative to some baselines.
- GPT-4o showed more sensitivity to context complexity, with higher hallucination rates on advanced texts, whereas o3 showed more robust performance across contexts.
- Inherited hallucinations (H_inh) from earlier steps often degraded final diagram quality, especially in RST2.
- Explicit and reflective prompts in automated evaluation (E2, E3) aligned more closely with human judgments than implicit evaluation (E1).
- Diagrams frequently contained information not present in the provided context, indicating context-integration challenges for LLMs.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.