Editor’s introduction
The study evaluates how large language models can extract OPQRST data—key elements of patient symptom assessment—from unstructured electronic health record text by reframing the task as text generation rather than sequence labeling. This approach enables the model to produce reasoning steps that mirror a physician’s thought process, improving transparency and interpretability. Performance is assessed using modified Named Entity Recognition metrics, including BERT Score, to evaluate semantic alignment with clinical intent. The research demonstrates a more clinically relevant method for information extraction, particularly in settings with limited labeled data. However, the study is limited to in-context learning and does not include fine-tuned LLMs on clinical datasets. Additionally, annotators were not provided with the model’s reasoning steps during the annotation process, limiting opportunities for human-AI collaboration to refine both the annotations and model outputs.
Introduction
The accurate and efficient extraction of critical patient information from Electronic Health Records (EHRs) is an important problem in machine learning and healthcare. In healthcare, the ability to swiftly and accurately extract pertinent information from EHRs is crucial, yet the complexity and volume of these records make this task difficult. Clinicians rely on these details to make informed decisions about patient care, and the ability to quickly identify key elements such as the OPQRST (a common mnemonic for patient assessment, which contains Onset, Provocation/palliation, Quality, Region/Radiation, Severity, and Time) can greatly improve healthcare delivery. However, addressing this problem is challenging due to the vast amount of complex and unstructured data present in EHR notes, making it difficult for traditional machine learning approaches to effectively capture and extract the relevant information.
Previous attempts to tackle the extraction of OPQRST from EHRs have been treated as a sequence labeling task, and limited by the lack of labeled training data in this low-resource setting, hindering the performance of pre-trained models. Additionally, these models often function as black boxes, lacking the ability to provide reasoning for their outputs, which is crucial in high-risk medical scenarios. In contrast, we propose a novel approach to extract OPQRST in EHRs by leveraging Large Language Models (LLMs) such as Llama 2 and GPT-4. By framing the task as a text generation problem instead of sequence labeling, we enable the model to provide reasoning steps, mimicking the physician’s thought process. This method not only aids in mimicking a physician’s cognitive process during patient evaluation but also enables the model to learn with minimal labeled data, focusing on reasoning rather than only extraction. This approach not only improves interpretability but also reduces the need for extensive ground truth annotations, as the model’s output can be guided by analyzing the generated reasoning.
Furthermore, considering the unique challenges posed by viewing the task as text generation rather than sequence labeling, the problem with the generative model is that it tends to output text that is similar but not exactly the same as the original text, whereas the traditional Named Entity Recognition (NER) evaluation metrics only designed to capture the hard matches, resulting in the categorization of any phrases not directly extracted from the original text as incorrect. To tackle this problem, we introduce a novel adaptation to the traditional NER evaluation metrics by adding semantic similarity checking for the generated phrases. We employ metrics like the BERTScore or prompt LLMs to assess the semantic similarity between the generated phrase and ground truth phrase. This approach allows us to capture the effectiveness of the generated outputs in reflecting the true clinical context, thereby bridging the gap between machine-generated phrases and their human-generated counterparts.
Medical Information Extraction
The field of medical information extraction (IE) is crucial for distilling structured insights from the vast expanses of unstructured EHRs. Recent literature review highlights the critical need for collaboration between natural language processing (NLP) experts and clinical professionals to address the uniqueness of clinical data. This review underscores the scarcity of publicly available clinical datasets—a consequence of stringent privacy regulations like the Health Insurance Portability and Accountability Act (HIPAA) and institutional privacy concerns. Concurrently, emphasizes the essential tasks within clinical IE, such as NER and relation extraction (RE). These tasks are fundamental for transforming narrative clinical texts into actionable data, supporting medical decision-making and risk prediction. This work also points to the inherent challenges posed by the linguistic complexities of clinical narratives, including negation, co-references, and the variability of medical terminology, which significantly complicate the IE process. A cited study developed a multi-task framework to jointly tackle the task of medical NER and entity normalization. A cited study developed a web service for medical NER and relationship extraction in medical data. To tackle the issue of limited data annotation, proposed a method for few-shot learning of NER in the medical domain.
LLMs based Extraction
In-context learning, which relies on prompt engineering to guide large pre-trained language models, has shown promising results in clinical NLP tasks where labeled datasets are often limited. In clinical NLP, prompt engineering is crucial for leveraging state-of-the-art language models, as labeled datasets are often scarce, expensive, time-consuming to create, and constrained by data use agreements across institutions. highlight the need for addressing specific challenges such as wording ambiguity, lack of context, and negation handling while emphasizing the importance of responsible LLMs implementation and collaboration with domain experts in healthcare settings. Different types of prompts proposed in recent literature, including prefix, cloze, chain of thought, and anticipatory prompts, have been used under the clinical settings.
Prompt Creation
The designing of the extraction prompt involved several steps as there were many parts to it. We engineered it in an iterative manner. We had prior knowledge about the dependency between the OPQRS entities and the chief complaint. A chief complaint (CC) is an initial statement of patient-derived medical issues, which is often elicited prior to formal medical tests and diagnoses. It provides a brief statement about a patient’s reasons for encounter, current symptoms, and medical history. Following queue from the paper cite question decomposition paper and our prior knowledge we initially crafted an initial prompt that would decompose the entity extraction task into question-answer (Q/A) pairs. The first Q/A pair would extract the chief complaint followed by the second Q/A pair that would extract the entity. E.g.: first Q/A pair: What is the chief complaint? A: The chief complaint is… The second Q/A pair would be Q: When did it start? A: It started several hours prior to the arrival.
We observed that the extracted phrases (several hours prior to arrival) were unnecessarily verbose and consisted of extra tokens (in this case ‘to arrival’). On the advice of the physician, we developed a prompting template that would mimic a physician’s thought process by urging the model to look for keywords that are commonly associated with the chief complaint and OPQRS entities. This helped to narrow down the scope for searching the entity in the long History of Present Illness (HPI).
The next step was to come up with an automatic way of extracting the generated outputs. Taking cue from, we prompted the model to add ‘@’ tokens before and after the final answer so that we could use regex parsing to extract the output to perform the large-scale evaluation.
Evaluation Metrics
For traditional NER evaluation metrics, we adopt the evaluation protocol of SemEval 2013 task 9.1 to evaluate models for mention extraction and entity linking. Precision, Recall, and F1 scores are reported in “Exact” mode (exact boundary match) to measure the performance of entity extraction.
To allow for a more comprehensive assessment of the model’s performance in cases where the generated text is not an exact match to the original, We extend the entity-based F1 score by proposing a new metric that measures the similarity between the generated phrase and the ground truth using BERTScore or PromptLLM.
The evaluation prompt was designed after performing extensive conversations between the human and the LLM. This was done to understand whether the LLMs can follow human-designed instructions. Mainly it was accomplished in 5 steps. In step one, a simple definition of the task that can easily be understood by a human is provided to the language model. The human asks the LLM to respond with Yes/No if it understands the task. After ascertaining it has understood the task, for step two we provide a test instance that was designed keeping in mind the edge cases where the LLMs are more likely to generate errors. We observe the LLMs perform poorly on the example and are not able to reason out correctly. The performance was gauged by eyeballing the results and reasoning provided by the LLMs. In step three, The LLM was then corrected by the human and the reasoning behind the correction was explained to it. Step 4 constituted drafting a question that would ask the LLMs to improve the task definition in a manner so that it does not commit similar mistakes again. The LLMs provide the refined definition which is in turn used to prompt the LLMs and to extract the entity in step five.
Dataset
The annotation process was carried out by the collaborating expert physician who is well-versed in understanding EHR data. An annotation guideline was created to lay down the rules. Some of the rules followed are: To make sure that the ground truth is faithful to the source text we chose to keep any spelling/grammatical errors in the annotation. If any entity does not exist the ground truth the annotation is an empty string. We try to keep our annotation succinct and to the point by not including any unnecessary phrases. But we also make sure the phrases are complete in meaning. If there are multiple mentions of an entity then we replicate the instance and create new data points per unique extracted phrase. We took care to consider annotating OPQRS entities that are associated with the chief complaint only and not describing any other symptom.
The annotation process resulted in a test set of 85 samples. The distribution of samples across all entities was as follows. The entity ‘Onset’ had 63 instances followed by ‘Provocation’ having 35 instances. ‘Palliation’ had 20 instances and ‘Quality’ had 53. ‘Region’ had 49 followed by ‘Radiation’ having 42 annotations. Finally ‘Severity’ had the least number of instances i.e 16. Each dataset sample consists of the History of Present Illness (HPI) section of the EHRs along with the extracted phrase and its corresponding label (Onset, Provocation, etc). All data will be released under restrictions.
Experiment settings
All our experiments were performed using the Llama-2-13B-chat model. We used one 80GB A100 for loading the model and carrying out inference. We used the Hugging Face Accelerate library for the deployment. With regards to the experiment settings, the temperature was set to a mid value of 1.0, the top_p parameter was set to 0.95 and the top_k parameter was set to 30. The combination of top_p and top_k was selected based on experimentation and observing the outputs. We want to make sure the model follows the reasoning steps but also is able to have certain flexibility in terms of generating tokens for the extracted entities. To limit the variety of tokens in terms of generating the reasoning steps we set the top_k parameter to 30. To encourage variety in the extracted tokens in the reasoning steps we set a high top_p value. Depending on the stage of the pipeline, during the extraction phase, the maximum number of tokens was set to 2000. For evaluation, we set the maximum number of tokens to 500 as the reasoning was shorter in length as compared to the extraction phase.
Ablation Study
We are aiming to perform three ablation experiments to check the efficacy of our prompt. The experiments are performed for the entity ‘Onset’. The first ablation experiment will gauge how adding reasoning steps influences the LLMs decision making process. The reasoning steps were added to mimic the physician’s thought process, i.e to first extract the chief complaint and then extract the entity ‘Onset’. The prompt contains the definition of the entity and a corresponding few shot examples without the reasoning steps. The second ablation experiment studies the effect of the self-verification step in our reasoning steps. The motivation behind adding the self-verification step was to mitigate hallucinations in the model’s outputs. The prompt contains the definition of the entity and a corresponding few shot examples that contain the reasoning steps without the self-verification step. We compare these two settings to our method which contains the reasoning steps and the self-verification step.
Discussion
In this study, we introduced a novel approach for extracting OPQRST data from EHRs utilizing Large Language Models (LLMs) and reframing the task from traditional sequence labeling to text generation. Our research aimed to harness the sophisticated capabilities of LLMs to mimic the reasoning process of clinicians, thereby enhancing the interpretability. This transparency is crucial for clinical acceptance and trust, as it provides healthcare professionals with insights into the AI’s decision-making process. On the other hand, We proposed and implemented modifications to traditional Named Entity Recognition (NER) metrics to better evaluate the performance of text generation models in a clinical context. By incorporating measures of semantic similarity, our approach provides a more comprehensive assessment of model output, recognizing the clinical intent of the text rather than just exact matches. This innovation helps in evaluating the true usability of AI-generated text in clinical practice.
While our results directly show the effectiveness of extracting OPQRST data, we believe this approach can also be applied to other healthcare settings where there is a lack of labeled training data, and transparency and decision-making processes are highly evaluated.
Limitations
This work is still limited in several ways. First, only in-context learning is used in this study, and we did not consider LLMs that are fine-tuned in the clinical corpus. Second, during the annotation process, we do not provide the reasoning steps to the physician. It would be interesting to explore the collaboration of Human-LLMs in this setting where the annotator improves their annotation by viewing the reasoning and the entity extracted by the LLMs while the LLMs inturn improve its suggestions garnering feedback from the humans.
Baseline Prompts
Rules: Here are the rules to extract the entity ‘Onset’ from the EHR note. 1) Identify the verb tense that indicates the chief complaint. 2) Identify the specific phrase that describes the chief problem. 3) Identify the adverbial phrase for time that indicates the start of the chief complaint. 4) Provide the final phrase.
1 Ablation prompt 1
Definition: You are a chatbot who knows the task of ‘Named Entity recognition’. You are provided with some clinical data related to a patients visit to the emergency department of a hospital. The target task is to extract the the words that belong to the entity ‘Onset’. ‘Onset’ means the beginning or initiation of a symptom, sign, or medical condition. For ‘Onset’ we will be looking temporal markers. For example, ‘several days/hours ago’, ‘today/yesterday’, etc.
Example2: 39-year-old white female presents with chest tightness. she relates that she was initially seen at a medics present was concern for blood clot so they sent her here. she relates she has a history of pulmonary embolus in her family. she has pain in her back at times. she denies any shortness of breath. she’s had no syncope. she’s had no recent illnesses.
2 Ablation prompt 2
Definition: You are a chatbot who knows the task of ‘Named Entity recognition’. You are provided with some clinical data related to a patients visit to the emergency department (ED) of a hospital. The target task is to extract the the words that belong to the entity ‘Onset’. For that we will first extract words related to the entity ‘Chief Complaint’ and then based on that we will extract the words related ‘Onset’. I will now give you the definition of both entities. ‘Chief complaint’ is the main issue/problem that the patient presents to the ED with. ‘Onset’ means the beginning or initiation of a symptom, sign, or medical condition i.e the chief complaint (extracted before).
You have to make sure that you follow the definition I provide and not interpret the meaning of ‘Onset’ in a general way. So I will be providing with you some examples on how to extract the entities ‘Chief Complaint’ and ‘entity. Basically we will be trying to mimic a physician’s train of thought on how to extract these entities. We will be first looking for words that usually mark the starting of phrases related to ‘Chief Complaint’. For example, ‘presents with’, ‘complains of’, ‘comes to/in’, etc and mostly the actual chief complaint follows these words. For ‘Onset’ we will be looking temporal markers. For example, ‘several days/hours ago’, ‘today/yesterday’, etc.


