Abstract
Prompt engineering has the potential to enhance large language models' (LLM) ability to solve tasks through improved in-context learning. In clinical research, LLMs have shown expert-level performance for tasks ranging from pathology slide classification to identifying suicidality. We introduce clickBrick, a modular prompt-engineering framework, and test its effectiveness in a psychiatric context. We explore the effects of increasingly structured prompts for a comprehensive psychopathological assessment of 100 index patients from psychiatric electronic health records. We compare the performance of a locally-run LLM against an expert-labelled ground truth for the extraction of 12 transdiagnostic psychopathological criteria. Potential clinical value was explored by training linear support vector machines on outputs from the strongest and weakest prompts to predict discharge ICD-10 main diagnoses for a historical sample of 1,692 patients. Our results show that clickBrick improved extraction accuracy by 19% to 36%, with balanced accuracies spanning 71% to 94%. This framework offers a reproducible pathway for deploying trustworthy generative AI across mental health and other clinical fields.
Introduction
Psychiatry is a uniquely text-heavy medical discipline. Unlike cardiology or radiology, which rely on quantitative metrics like ejection fractions or tumor dimensions, psychiatric diagnosis and treatment planning live within the unstructured prose of clinician notes. While Large Language Models (LLMs) are naturally suited to parse this text, the medical community lacks a standardized, transparent methodology for "engineering" prompts for high-stakes clinical tasks.
Existing research often relies on proprietary "black-box" models that pose risks to patient privacy or fails to report exact prompt structures, hindering replication. To address these gaps, we developed clickBrick, a systematic framework to build, test, and report prompts for 12 critical psychiatric dimensions (e.g., suicidality, addiction, anxiety) using open-weight models hosted locally.
The clickBrick Framework
The clickBrick framework treats prompt engineering as an iterative, modular construction project. Prompts are built by "clicking" together specific components, or "bricks":
- Baseline: A simple query (e.g., "Does the patient show symptoms of depression?").
- Professional Role: Assigning a specific persona ("You are an experienced psychiatrist").
- Operational Definitions: Providing formal clinical criteria for the symptom being evaluated.
- Few-Shot Examples: Providing the model with labeled "positive" and "negative" cases to guide its pattern recognition.
- Reasoning (Chain-of-Thought): Adding instructions like "Think step by step" to trigger logical sequencing.
Methodology
We utilized a Llama-3.1-70B-Instruct model running locally on an Nvidia A6000 GPU to process German psychiatric admission notes. This local deployment ensured that sensitive patient data never left the hospital premises.
Datasets and Validation
- Primary Dataset: 2,520 clinical cases from 1,692 individual patients at a German psychiatric acute care ward.
- Ground Truth: A sub-sample of 100 cases was meticulously annotated by three subject-matter experts (a resident, a research assistant, and an attending psychiatrist) to establish a gold standard.
- Task Scope: The model was tasked with extracting 12 transdiagnostic psychopathological dimensions, including mania, sleep disorders, and self-endangerment.
To evaluate clinical utility, we used the LLM-extracted data to train a linear Support Vector Machine (SVM) to predict final ICD-10 discharge diagnoses, comparing the predictive power of data generated by the strongest versus the weakest prompts.
Key Insights
The "No Silver Bullet" Rule
Our testing revealed that no single prompt structure is universally superior. While Chain-of-Thought (CoT) reasoning performed best in 7 out of 12 domains (such as anxiety), simpler "few-shot" prompts actually outperformed CoT for specific categories like aggression and self-harm. This suggests that the complexity of the prompt must be matched to the specific clinical dimension.
LLMs Mirror Human Ambiguity
We observed a medium-strength correlation between human inter-rater reliability and LLM accuracy. In domains where human experts struggled to reach a consensus, the LLM’s performance also tended to decline. This indicates that LLM performance is often bounded by the inherent semantic clarity of the clinical documentation itself.
Sensitivity to Semantic Noise
To test robustness, we intentionally introduced typos and "noisy" text into the prompts. This led to a significant degradation in performance, proving that LLMs are highly sensitive to the precision of instructions provided by clinicians. Clean, expert-led prompt design is non-negotiable for clinical accuracy.
Results
The application of the clickBrick framework yielded substantial improvements across all metrics:
- Accuracy Gains: The framework increased mean Balanced Accuracy (BAcc) from 56.2% (using the weakest prompts) to 82.8% (using the best-performing prompts).
- Domain Success: The most significant improvements were observed in extracting symptoms for depression (+36%), mania (+32%), and cognitive impairment (+30%).
- Expert-Level Performance: For specific tasks like identifying mania, the model achieved a peak accuracy of 94%.
- Downstream Utility: Using data from the "best" clickBrick prompts improved the accuracy of automated ICD-10 diagnosis prediction from 71% to 76%, demonstrating that better prompt engineering translates directly into higher clinical value.
Discussion and Limitations
While clickBrick identifies the optimal prompt within a structured set of expert-designed options, it does not guarantee a global mathematical optimum across all possible natural language variations. Furthermore, this study did not systematically evaluate the model for demographic biases (e.g., gender or ethnicity), which remains a critical prerequisite for real-world deployment. Future work should involve individuals with lived experience in the prompt design process and explore automated prompt optimization, where one LLM iteratively refines the "bricks" for another.
Conclusion
ClickBrick prompt engineering demonstrates that iterative, expert-led design is critical for unlocking the clinical potential of LLMs. By providing a reproducible pathway for structuring clinical queries, this framework enables the deployment of high-performance, privacy-preserving AI that can assist in the complex task of psychopathological assessment.
Summary updated