Preserving Model-to-Code Traceability During LLM-Based Code Generation
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.
- Link
- https://www.semanticscholar.org/paper/4a9e006c287d14dd83535fc74f69d8a23e8bf301
- Found by
- Semantic Scholar
- Authors
- Marc North, Nelly Bencomo, Amir Atapour-Abarghouei
- Categories
- evaluation
- Published
- 2026-10-03
- Last seen by the radar
- 2026-10-05
- Citations
- 0
- Influential citations
- 0
- Radar score
- 26.75 / 100 (how it is scored)
- Why it scored so
- Matched: evaluat; Primary record: Semantic Scholar
- Related links
- https://doi.org/10.1145/3822455.3838762