Zero- and few-shot Named Entity Recognition and Text Expansion in medication prescriptions using large language models.

Journal: Artificial intelligence in medicine
Published Date:

Abstract

Medication prescriptions in electronic health records (EHR) are often in free-text and may include a mix of languages, local brand names, and a wide range of idiosyncratic formats and abbreviations. Large language models (LLMs) have shown a promising ability to generate text in response to input prompts. We use ChatGPT3.5 to automatically structure and expand medication statements in discharge summaries and thus make them easier to interpret for people and machines. Named Entity Recognition (NER) and Text Expansion (EX) are used with different prompt strategies in a zero- and few-shot setting. 100 medication statements were manually annotated and curated. NER performance was measured by using strict and partial matching. For the EX task, two experts interpreted the results by assessing semantic equivalence between original and expanded statements. The model performance was measured by precision, recall, and F1 score. For NER, the best-performing prompt reached an average F1 score of 0.94 in the test set. For EX, the few-shot prompt showed superior performance among other prompts, with an average F1 score of 0.87. Our study demonstrates good performance for NER and EX tasks in free-text medication statements using ChatGPT3.5. Compared to a zero-shot baseline, a few-shot approach prevented the system from hallucinating, which is essential when processing safety-relevant medication data. We tested ChatGPT3.5-tuned prompts on other LLMs, including ChatGPT4o, Gemini 2.0 Flash, MedLM-1.5-Large, and DeepSeekV3. The findings showed most models outperformed ChatGPT3.5 in NER and EX tasks.

Authors

  • Natthanaphop Isaradech
    Department of Community Medicine, Faculty of Medicine, Chiang Mai University, 110, Intrawarorot Road, Meaung, 50200, Thailand, 66 53935472, 66 935476.
  • Andrea Riedel
    Erlangen University Hospital, Medical Center for Information and Communication Technology, Erlangen, Germany; Friedrich-Alexander-Universität Erlangen-Nürnberg, Medical Informatics, Erlangen, Germany.
  • Wachiranun Sirikul
    Department of Community Medicine, Faculty of Medicine, Chiang Mai University, Chiang Mai 50200, Thailand.
  • Markus Kreuzthaler
    Institute of Medical Informatics, Statistics, and Documentation, Medical University of Graz, Austria.
  • Stefan Schulz
    Institute for Medical Informatics, Statistics and Documentation, Medical University of Graz, Austria.