In-Context Learning for Diagram Code Generation: What is the Effect on Faithfulness and Quality?

in-context-learning-for-diagram-code-generation:-what-is-the-effect-on-faithfulness-and-quality?

In-Context Learning for Diagram Code Generation: What is the Effect on Faithfulness and Quality?

[Submitted on 28 Jan 2026 (v1), last revised 4 Nov 2026 (this version, v3)]

View PDF HTML (experimental)

Abstract:We investigate how provision of in-context examples based on discourse similarity affects quality and hallucination in diagram code generation from educational materials. Using a sample of texts as sources for diagram generation, we test two methods using a conventional text-to-diagram task format, instruction-based zero-shot generation and ICL with text-to-diagram examples, and an unconventional ICL method with a discourse analysis-to-diagram example, which requires a model to generate a diagram from a discourse analysis. We evaluate AI-generated diagrams for faithfulness to provided context and their quality outcomes using both human and automated evaluation. Bayesian data analysis of the human diagram evaluation shows that there is significant evidence that the unconventional task format improves context faithfulness in diagram generation compared to the zero-shot instruction with reducing the odds of context faithfulness hallucination by nearly $70%$; however, we do not find the ICL having a significant effect on the diagram aesthetic presentation and superficial coherence. Evaluation with the LLM-as-a-judge G-Eval metric shows nearly 4.5-fold increased odds of the perfect faithfulness outcome for the novel ICL task. Our study provides a novel insight into ICL format effect on superficial fluency and faithfulness in context-grounded structured diagram code generation.

Submission history

From: Evanfiya Logacheva [view email]
[v1] Wed, 28 Jan 2026 10:45:28 UTC (1,034 KB)
[v2] Fri, 21 Aug 2026 14:06:11 UTC (888 KB)
[v3] Wed, 4 Nov 2026 14:33:42 UTC (8,532 KB)