By Ashwin Kumar Nyalakonda, Anil Mogha, and Gourav Garg — K3 Innovations, Inc. (Paper ML23).
Abstract
Generating Analysis Data Model (ADaM) datasets remains one of the most resource-intensive and error-prone steps in clinical trial programming. Although CDISC standards and open-source frameworks such as admiral provide structure and best practices, implementation still requires extensive manual coding and deep package expertise. General-purpose Large Language Models (LLMs) show promise for accelerating code development, but without domain context they often produce non-compliant syntax, misuse pharmaverse functions, and generate outputs that are difficult to reproduce or validate.
This paper presents a metadata-driven, LLM-augmented pipeline for ADaM dataset generation implemented within the SPARC platform. By embedding ADaM specifications, controlled terminology, and explicit library usage guidelines for packages such as admiral, dplyr, and haven, the pipeline enables extensive in-context learning that guides LLMs toward regulator-ready R code. Prompts are organized by variable categories — common variables, copied source variables, date variables, and parameter-driven variables — before being synthesized into coherent, auditable programs.
Pilot evaluations using GPT-4o and a fine-tuned Qwen-2.5-7B model successfully generated ADSL, ADAE, and ADLB datasets with reduced programming effort and improved consistency across teams. Compared to conventional manual workflows, the hybrid approach accelerates dataset development, lowers error rates, and ensures alignment with pharmaverse best practices. This paper provides a practical walkthrough of the prompt pipeline, highlights successes and limitations, and offers guidance for integrating LLM-based code generation into existing ADaM workflows while maintaining compliance, efficiency, and reproducibility.
Read the full paper
The complete paper — the prompt pipeline, pilot results, and integration guidance — is available as a PDF above.