Skip to content
Book Open access

Preserving Model-to-Code Traceability During LLM-Based Code Generation

Oct 2026 · Proceedings of the ACM/IEEE 29th International Conference on Model Driven Engineering Languages and Systems · 0 citations · 14 references

Abstract

Large language models (LLMs) are increasingly used for model-to-code generation, but they weaken one of the central properties of model-driven engineering: traceability between design models and generated implementation artefacts. Existing approaches either rely on deterministic transformations, where trace links can be produced by construction, or treat traceability as a post-hoc recovery problem, where links are reconstructed after code has already been generated. This paper investigates a different possibility: preserving model-to-code traceability during LLM-based code generation. We study generation from UML class diagrams, represented in XMI, to Java and Python code. During generation, we capture token-level attribution between the model input and generated code output, and aggregate these signals into trace links between model elements and code features. We evaluate input masking, gradient-based attribution, and internal intervention techniques as mechanisms for preserving traceability during generation. Across open-weight LLMs of different sizes, value zeroing performs best, identifying the correct trace link with 90% top-1 accuracy and more than 95% top-5 accuracy. The results suggest that generating LLMs contain signals that can support meaningful model-to-code traceability, without requiring trace links to be reconstructed only after generation. This paper therefore reframes LLM-based model-to-code generation as a traceability-preservation problem. This opens a research direction for AI-supported MDE in which trace links are treated as engineering artefacts produced alongside generated code, rather than as evidence recovered afterwards.

Read PDF

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.