Introduction
In healthcare research and clinical operations, the assignment of Anatomical Therapeutic Chemical (ATC) codes to drug mentions—a process known as ATC coding—is a vital yet resource-intensive task. Standardizing drug mentions (e.g., mapping "Tylenol" to the code N02BE01) is essential for public health reporting and drug utilization studies. However, organizations like Ontario Health currently rely on manual expert review of thousands of records, creating a significant bottleneck that is both slow and costly.
While Large Language Models (LLMs) offer a potential solution for automating this classification, they face two primary challenges in clinical settings: data privacy and the sheer complexity of the ATC hierarchy, which contains over 6,000 codes. Researchers from the University of Waterloo and InterRAI Canada have addressed these issues by developing a hierarchical prompting method that enables locally deployable, open-source models to perform high-accuracy ATC coding.
Methodology: Level-by-Level Prompting
The core innovation of this research is the Level-by-Level Prompting approach. Rather than attempting a "flat" classification where a model picks one code from thousands, the task is decomposed into a series of step-wise navigation decisions within the ATC ontology.
- Hierarchical Navigation: The LLM is prompted to select from the 14 top-level ATC categories (e.g., "N: Nervous System"). Upon selection, it is then prompted to choose from valid sub-categories at Level 2, continuing until it reaches the specific Level 5 substance code.
- Constrained Output: At each level, the model's choices are restricted to valid options within the hierarchy, effectively eliminating "hallucinations" of non-existent codes.
- Knowledge Grounding: The researchers explored augmenting prompts with drug definitions from the Unified Medical Language System (UMLS) to provide additional context for the model's decision-making.
- Local Deployment via Fine-Tuning: To ensure patient privacy, the team fine-tuned a smaller Llama 3.1 8B model. This allows healthcare providers to run the system on modest local hardware without sending sensitive data to external APIs.
Experimental Design
The performance of the Level-by-Level approach was evaluated across three distinct datasets:
- Health Canada Product Names: A dataset of 5,744 brand and generic name pairs.
- RABBITS Benchmark: A specialized dataset designed to test model robustness when brand names differ significantly from generic names.
- Ontario Health Assessments: A "gold-standard" dataset of 200 real-world, noisy clinical notes containing misspellings and complex instructions, annotated by domain experts.
Key Results and Performance
The study compared proprietary models (GPT-4o) against open-source alternatives (Llama 3.1 70B and a fine-tuned 8B version). The results demonstrate that hierarchical prompting significantly improves the utility of smaller models.
Key findings include:
- Accuracy: GPT-4o achieved the highest exact match accuracy at Level 5 (78.4%). However, the fine-tuned Llama 3.1 8B model (60.5%) successfully matched the performance of the much larger Llama 3.1 70B model (60.3%).
- Real-World Viability: On the noisy Ontario Health dataset, the fine-tuned 8B model achieved over 91% accuracy at Level 1, proving its effectiveness for high-level population health analysis.
- Efficiency: The fine-tuned 8B model provides a privacy-preserving, cost-effective solution that can be deployed locally while maintaining competitive accuracy.
Discussion: Insights on Model Behavior
The research revealed that zero-shot LLMs rely heavily on "string similarity"—the visual resemblance between a brand name and its generic counterpart. On the RABBITS dataset, where these names are less similar, performance dropped by nearly 40% compared to the Health Canada data. While adding UMLS definitions provided modest improvements, particularly at deeper levels of the hierarchy, it was not a complete solution for unrelated brand names.
Conclusion
Level-by-Level Prompting transforms a complex, high-cardinality classification task into a manageable series of decisions. By enabling smaller, open-source models to achieve high accuracy, this research paves the way for automated, privacy-preserving ATC coding in clinical environments. Future work will focus on hybrid systems that combine LLM linguistic capabilities with traditional rule-based matching to further improve robustness against dissimilar drug names.
Summary updated