← All publications

Conference Paper

Schema-Preserving Generation of Clinical TLF Templates and Executable R Code via Iterative LLM-Guided Debugging

Jaime Yan

PharmaSUG 2026 · 2026 · AP-211

DOI · 10.5281/zenodo.22182914 Companion code

Abstract

Manual authoring of CSR TLF templates is resource-intensive, and naive LLM prompting suffers schema drift and regulatory inconsistencies. This paper compares five LLM generation methods for producing ICH E3/CDISC-conformant TLF templates across 1,999 instance-matched bootstrap experiments on three LLM providers, using JSON Patch (RFC 6902) to preserve schema fidelity, and separately evaluates iterative LLM-guided debugging for translating the templates into executable R code. A hybrid RAG approach with reranking significantly outperformed direct prompting (mean quality score 85.7 vs 81.7, p < 0.05, consistent across providers and therapeutic areas), and iterative LLM-guided debugging raised R-code execution success from a low zero-shot rate to 70% within 3–5 rounds, with higher-fidelity templates needing fewer iterations.

Keywords

TLF templates · retrieval-augmented generation · LLM debugging · clinical study reports · ICH E3 · ADaM · R code generation

Cite

Jaime Yan. "Schema-Preserving Generation of Clinical TLF Templates and Executable R Code via Iterative LLM-Guided Debugging." PharmaSUG 2026, 2026. doi:10.5281/zenodo.22182914.