Work

SPE-ECG: An Ontology-Guided Knowledge Representation Framework for Enhancing LLM-Based Code Generation

Year: 2026
Type: article
Abstract: Large Language Models (LLMs) can translate natural-language instructions into code, but when the input is unstructured clinical protocol text, the generated code may omit doses, monitoring intervals, or safety thresholds that the text states. Such omissions matter because they can propagate into software that supports clinical monitoring. We propose SPE-ECG (Structured Prompt Engineering for Enhanced Code Generation), a transparent, rule-based pipeline that converts unstructured domain text into a JSON prompt using text cleaning, part-of-speech tagging, bigram matching, and hand-built domain dictionaries, without fine-tuning any model. In a case study of 43 rheumatoid arthritis DMARD monitoring protocols, we compared raw and structured prompts on three LLMs (GPT-3.5, LLaMA 2, and Gemma), scoring the generated Python code using version 3.15.1 with BLEU against the raw-prompt code of the other two models. Mean BLEU rose for all three models (relative gains of 55.1%, 32.5%, and 19.9%); the paired differences were significant for GPT-3.5 and LLaMA 2 but not, after correction for multiple comparisons, for Gemma. These results suggest that lightweight input structuring can change how closely different models’ outputs agree, and that it could serve as a low-cost, auditable preparation step for protocol-to-code tools built on free or open models. BLEU does not measure correctness, no ablation or state-of-the-art baseline was run, and clinical validation is required before any use.
Source: Computation
Language: English
Field: Medicine
Open Access status: gold
Estimated APC paid: $2,172
OpenAlex ID: W7225182704
FWCI:
Cites: 20
Cited by:
Related to: 10