Original Paper
Abstract
Background: Patient experience surveys may contain signals of diagnostic breakdowns that are difficult to identify through conventional safety surveillance. Natural language processing (NLP) may enable these narratives to be analyzed at scale.
Objective: The aim of the study is to develop and evaluate 3 increasingly context-sensitive NLP approaches for identifying patient-perceived diagnostic breakdowns in ambulatory patient experience survey comments and to explore the potential of prompt-engineered large language models (LLMs) for this task.
Methods: We analyzed 523 free-text comments from a 2023 ambulatory patient experience survey at a Canadian academic community hospital. Comments were manually coded using a structured framework to establish a finalized reference standard. Three sequential approaches were developed: a term frequency-inverse document frequency–based extreme gradient boosting classifier (phase I), a fine-tuned Twitter-RoBERTa model (phase II), and a locally deployed LLaMA 3.3 70B model refined through iterative expert-guided prompt development (phase III). Phases I and II were evaluated using 5×5 nested stratified cross-validation. Phase III was refined and evaluated on the full dataset and therefore represents development-set rather than independent held-out performance.
Results: Following expert review, 51 of 523 (9.8%) comments were classified as diagnostic breakdowns. Compared with phase I, phase II showed higher recall (0.767 vs 0.626), F1-score (0.620 vs 0.548), area under the receiver operating characteristic curve (0.921 vs 0.810), and area under the precision-recall curve (0.564 vs 0.490). In phase III, iterative prompt refinement reduced overclassification of general experiential complaints. The final prompt achieved recall of 0.961, precision of 0.803, specificity of 0.975, and an F1-score of 0.875 on the development dataset.
Conclusions: Patient-authored survey narratives are an underused source of information for diagnostic safety and quality improvement. Context-sensitive NLP approaches may improve detection of subtle diagnostic concerns, and the strong development-set performance of the prompt-engineered LLM supports further study. External validation and prospective evaluation within diagnostic-safety workflows are needed before broader implementation.
doi:10.2196/98901
Keywords
Introduction
Diagnostic errors are a persistent threat to patient safety. An estimated 1 in 20 outpatients in the United States experience a diagnostic error each year, with misdiagnosis of dangerous diseases contributing to thousands of cases of preventable permanent disability or death in the United States annually [,]. The National Academies of Sciences, Engineering, and Medicine (NASEM) defines diagnostic error as the failure to establish an accurate and timely explanation of a patient’s health problem or to communicate that explanation effectively to the patient []. These errors occur across all care settings and are further complicated by factors such as clinical uncertainty, fragmented communication, and time constraints [,]. Although organizations like NASEM have brought increased attention to the issue, common diagnostic error detection strategies, including review and analysis of medical records, malpractice claims, and safety reports, remain labor-intensive, inconsistently applied, and poorly suited for continuous surveillance [,]. As a result, the perspectives and experiences of patients are rarely integrated into formal diagnostic safety evaluations []. The term diagnostic breakdown has been used by our team and others to describe a patient-perceived problem involving the accuracy, timeliness, or communication of diagnosis that may indicate a possible diagnostic error [-]. Although not designed specifically to capture diagnostic errors, patient experience surveys invite respondents to provide free-text responses describing both positive and negative care experiences, including issues related to diagnosis. These accounts can offer signals of diagnostic breakdowns that might otherwise go unnoticed through conventional surveillance methods. For example, Baker et al [] found that nearly one-quarter of negative patient experience survey comments contained language suggestive of diagnostic breakdowns. Smith et al [] demonstrated that patient experience surveys in urgent care settings reveal missed opportunities in information gathering and treatment planning. McDonald et al [] further emphasized that engaging patients in system-level safety initiatives may be a promising strategy for reducing diagnostic errors. Together, these findings point to the potential value of incorporating patient experiences and perspectives into diagnostic safety surveillance and measurement.
In parallel, natural language processing (NLP) has been increasingly used to extract clinically and operationally relevant information from unstructured health care text. In the area of diagnostic safety, Tabaie et al [] applied term frequency-inverse document frequency (TF-IDF)–based machine learning to clinician-authored electronic health record (EHR) notes, demonstrating the potential for NLP to identify signals of diagnostic breakdowns. However, prior applications of NLP to diagnostic safety have focused on sources such as clinician-authored EHR notes and health-system safety data, while the use of patients’ own descriptions of care for this purpose remains comparatively underexplored.
NLP has also increasingly been applied to patient-authored text for purposes other than diagnostic safety. Transformer models extend earlier lexical approaches such as TF-IDF by representing words in relation to their surrounding context and can be fine-tuned for specific classification tasks. Recent studies have used fine-tuned transformer models to identify patient concerns in portal messages [], classify themes in patient-experience comments [], and characterize patients’ assessments of care in online reviews []. These applications demonstrate the potential to analyze patient voice at scale, although patient-authored narratives are often more informal, emotionally expressive, and variable in language and structure than clinical documentation [].
More recently, large language models (LLMs) have expanded the range of text-classification tasks that can be addressed through natural-language prompting without task-specific fine-tuning []. LLMs have shown promise in clinical applications such as medical question answering [] and radiology report summarization []. In patient-authored narratives, Koh et al [] evaluated 3 off-the-shelf LLMs for classifying formal primary care complaints across an established taxonomy of care-related domains, rather than diagnostic safety, using zero-shot prompts built from field definitions and keywords without labeled examples [].
Despite these advances, few studies have examined whether NLP can identify patient-perceived diagnostic breakdowns in routinely collected patient-experience survey comments. This single-site study aimed to develop and evaluate 3 increasingly context-sensitive NLP approaches for identifying patient-perceived diagnostic breakdowns in ambulatory patient experience survey comments and to explore the potential of prompt-engineered LLMs for this novel classification task.
Methods
Study Design
This single-site study evaluated 3 sequential phases representing increasingly context-sensitive NLP approaches for identifying patient-perceived diagnostic breakdowns in free-text ambulatory patient experience survey comments. Survey comments were first manually coded by 2 research assistants (MAH and SK) using a structured coding framework to create a reference standard. The reference standard was then used to develop and evaluate 3 phases of the study: phase I, a TF-IDF–based extreme gradient boosting (XGBoost) classifier; phase II, a fine-tuned transformer model; and phase III, a locally deployed LLM refined through iterative prompt refinement.
Data Source and Study Sample Selection
This study analyzed data from the 2023 ambulatory care patient experience survey administered at a large urban academic community hospital in Toronto, Canada. Patients aged 18-80 years who attended an outpatient visit between June and August 2023 were invited to complete the survey by email or telephone. A total of 3904 survey invitations were sent (1043 by phone and 2861 by email), and 1074 surveys were completed. The survey included one open-ended question asking participants to describe the reason for their overall experience score: “Please let us know what is the main reason for your score?” Of the completed surveys, 523 included a nonempty response to this question and were included in the analysis (). Prior to the analysis, free-text responses were deidentified to remove direct identifiers including names, medical record numbers, and dates of birth.

Reference Standard Development
To establish the reference standard for model development and evaluation, all 523 free-text comments were manually coded for patient-perceived diagnostic breakdowns using the same structured codebook. The codebook (), based on the NASEM definition of diagnostic error, included 4 categories: diagnostic accuracy, timeliness, communication of the diagnosis, and other diagnostic communication breakdowns. The fourth category was added following feedback from patient partners and scientific advisors to categorize communication failures occurring throughout the diagnostic process that were not captured by the original framework. The codebook included operational definitions, decision rules, and annotated example comments derived from our previous work, applying these categories to patient-reported data in the United States [,]. Multiple diagnostic breakdown categories could be applied to a single comment.
One coder (MAH) had previous experience applying the coding framework and trained the second coder (SK). Training included a joint review of the codebook, operational definitions, and annotated examples. Both coders independently coded an initial set of 50 comments in NVivo (version 14; Lumivero) to assess interrater agreement, yielding a Cohen κ of 0.69, a level generally considered consistent with substantial agreement []. After calibration, the remaining comments were evenly divided for independent coding. Upon completion, all coded responses were jointly reviewed to establish consensus on the initial reference standard. Disagreements were resolved through discussion, or, when necessary, adjudicated by a senior diagnostic safety researcher (KMS).
Throughout the coding process, the research team met regularly to review challenging cases and refine guidance for ambiguous patient narratives. These discussions aimed at distinguishing diagnostic from nondiagnostic communication issues, separating logistical delays from those affecting the diagnostic process, and resolving other edge cases. Coders were blinded to patient demographics and visit characteristics during coding. This process produced the initial reference standard before model development. During the phase III human-in-the-loop process described in the Phase III: Prompt Engineering With LLaMA 3.3 70B section, selected cases were subsequently returned for targeted expert rereview when model outputs raised concerns about possible inconsistencies in the original human labels. Corrections were made where warranted, resulting in the finalized reference standard used for all reported analyses.
Following finalization of the reference standard, patient and visit characteristics were summarized according to the classification of diagnostic breakdown or no diagnostic breakdown. Age was summarized using mean (SD) and median (IQR) and compared between groups using the Welch independent-samples t test. Sex was summarized using frequencies and percentages and compared using the Pearson chi-square test. Appointment department was compared using the Fisher exact test. All tests were 2-sided, with P<.05 considered statistically significant.
NLP Model Development and Evaluation
Overview
The initial reference standard supported development of 3 sequential NLP phases: a TF-IDF–based XGBoost classifier (phase I), a fine-tuned transformer model (phase II), and a locally deployed LLM refined through iterative prompt development (phase III). During phase III, targeted expert rereview of selected cases led to the finalized reference standard used for all reported analyses, as described in greater detail in the Phase III: Prompt Engineering With LLaMA 3.3 70B section.
Model development progressed iteratively across the 3 phases rather than being fully prespecified. Later approaches were introduced in response to methodological needs identified during development, with each phase incorporating additional capacity to represent or apply contextual information in patient-authored narratives. The overall model development and evaluation workflow is shown in .

Phases I and II were developed and evaluated using nested cross-validation, whereas phase III used iterative development of the diagnostic breakdown classification prompt on the full study dataset. Thus, its reported performance reflects the development set rather than independent held-out evaluation. Phase-specific development and evaluation procedures are described in the Phase I: TF-IDF+XGBoost, Phase II: Fine-Tuned Transformer (Twitter RoBERTa), and Phase III: Prompt Engineering With LLaMA 3.3 70B sections.
All analyses were conducted in Python (version 3.13.2; Python Software Foundation) on a workstation equipped with an NVIDIA GeForce RTX 4070 Ti SUPER graphics processing unit with 16 GB of memory. No protected health information was entered into publicly accessible LLM platforms, and all LLM inference was conducted through a locally deployed pipeline.
Phase I: TF-IDF+XGBoost
In the first phase, we implemented a traditional bag-of-words approach using TF-IDF to transform patient survey comments into numerical matrices for classification []. The bag-of-words model represents each document as a multivariate vector of individual word occurrences, ignoring grammar and word order while preserving word frequency. Because this approach relies on surface-level lexical features without contextual understanding, robust preprocessing was used to mitigate noise, sparsity, and lexical variability inherent in patient-authored text []. Preprocessing steps included lowercasing, removal of punctuation, numeric expressions, and date and time references, as well as elimination of standard and domain-specific stop words using the Natural Language Toolkit []. Tokens shorter than 3 or longer than 30 characters were removed to minimize noninformative artifacts.
The TF-IDF matrix was then constructed by assigning a weight to each term in a document based on its local frequency (term frequency) and its inverse frequency across the corpus (inverse document frequency), highlighting words that are both representative of the specific document and relatively uncommon in the overall dataset []. We excluded common terms (present in more than 95% of responses) and rare terms (present in fewer than 5% of responses), as these were unlikely to inform the classification task []. The resulting matrices were used to train an XGBoost classifier, a tree-based ensemble algorithm known for its high performance on structured and high-dimensional data []. XGBoost iteratively builds decision trees to minimize classification error while offering regularization and feature importance outputs for interpretability.
To optimize model performance, we used Bayesian optimization via Optuna to tune key hyperparameters, including learning rate, maximum tree depth, minimum child weight, gamma, subsample ratio, column sampling ratio, and both L1 (alpha) and L2 (lambda) regularization terms []. To address class imbalance, scale_pos_weight was fixed at the negative-to-positive class ratio. We used stratified cross-validation, which approximately preserved the class distribution across folds. The optimization was embedded in a 5×5 nested stratified cross-validation framework, which helps prevent overfitting and information leakage, resulting in more reliable performance estimates, particularly crucial for small datasets. In each outer fold, 80% of the data were used for model development and hyperparameter optimization, while the remaining 20% were held out for evaluation. Within each outer training set, Optuna used 5-fold inner cross-validation to identify the optimal hyperparameters. Since tuning was performed independently within each outer fold, this framework did not yield a single final set of optimized hyperparameters. Instead, it was designed to provide a less biased estimate of generalization performance while minimizing overfitting and information leakage in a small dataset setting. Comprehensive information on the search space of the model’s hyperparameters is detailed in .
Phase I served as the initial lexical approach in the sequential model-development process. While computationally efficient, TF-IDF represents text primarily through patterns of word occurrence and does not explicitly account for word order or surrounding context, and may therefore have difficulty when similar words convey different meanings across narratives []. This methodological limitation motivated phase II, which explored whether contextualized language representations could better capture meaning in patient-authored narratives.
Phase II: Fine-Tuned Transformer (Twitter RoBERTa)
Transformer-based architecture has become the backbone of modern NLP due to its ability to capture complex contextual relationships through self-attention mechanisms []. Transformers process tokens in parallel and model relationships among them, enabling the capture of long-range dependencies and nuanced semantic meaning beyond individual word frequencies. Leveraging this architecture, pretrained models are trained on large-scale unlabeled corpora to learn transferable syntactic and semantic representations [,]. Models pretrained specifically on biomedical or clinical text, such as BioBERT [] and ClinicalBERT [], have been developed for clinical NLP tasks.
A dominant paradigm in applied NLP is fine-tuning these pretrained transformers on downstream tasks using relatively small, labeled datasets []. A lightweight classification head is appended to the model, and supervised learning is used to update all or part of the model weights. In the context of health care, where labeled data are often limited and linguistic patterns vary across clinical settings, fine-tuning enables effective domain adaptation [].
However, patient-authored narratives can differ substantially from clinician-authored documentation in their use of informal syntax, colloquial expressions, and emotionally expressive language []. Given these characteristics, together with prior studies showing that general-purpose transformer models can perform comparably to or better than clinically pretrained models on patient-authored text [,], we selected the twitter-roberta-base-sentiment-latest model for phase II. This RoBERTa variant was pretrained on over 124 million English tweets, providing exposure to informal and colloquial language with characteristics relevant to patient-authored survey responses []. Minimal preprocessing was applied, including lowercasing and whitespace normalization while preserving punctuation and sentence structure to retain semantic meaning. Tokenization was performed using the model’s pretrained RobertaTokenizer.
Fine-tuning was conducted using the Hugging Face transformers and peft libraries [,]. Given the small dataset size, we used parameter-efficient fine-tuning with low-rank adaptation (LoRA) to reduce overfitting, which inserts trainable low-rank matrices into the model’s attention layers while keeping the base weights frozen []. Training used the AdamW optimizer, a variant of Adam that decouples weight decay from the gradient-based parameter update, which can improve regularization and generalization in deep learning models []. To address class imbalance, phase II used weighted cross-entropy loss, with class weights based on the positive-to-negative class ratio. Early stopping was applied based on validation loss, with training halted when validation loss failed to improve for 3 consecutive epochs. Hyperparameters, including learning rate, number of epochs, batch size, maximum length, and LoRA rank, were tuned using Bayesian optimization via Optuna, with the same 5×5 nested cross-validation framework as in phase I. Details of the hyperparameter search space are provided in .
Phase II shifted the representation of patient-authored text from sparse lexical features to contextualized language representations. However, as a supervised fine-tuning approach, classification remained dependent on the available labeled examples, which was particularly relevant, given the limited and imbalanced dataset. Diagnostic breakdown criteria and edge case distinctions were also learned implicitly from these examples rather than specified directly to the model. These considerations motivated phase III, which explored whether an instruction-tuned LLM could apply explicit task definitions, decision rules, and exclusions through natural-language prompting.
Phase III: Prompt Engineering With LLaMA 3.3 70B
The final phase used prompt engineering using the instruction-tuned LLaMA 3.3 70B LLM in a quantized GGUF format []. With over 70 billion parameters and pretraining on over 15 trillion tokens drawn from a diverse set of high-quality sources (Common Crawl, Wikipedia, academic literature, etc), the LLaMA model offers substantial representational capacity for modeling complex linguistic structures, reasoning through subtle distinctions in meaning, and general world knowledge. In addition, the model was instruction-tuned using a diverse set of human-annotated and synthetic task instructions []. This process improves its ability to follow prompts and makes it well-suited for few-shot classification, where the task is conveyed through natural language instructions and examples. The model was deployed locally using the Ollama framework []. Quantization allowed us to run the model efficiently without access to high-end server hardware. All inference was performed using deterministic decoding (temperature=0) to ensure reproducibility across runs.
Prompt engineering functioned as declarative logic programming, using natural language instructions to encode classification rules and explicitly handle edge-case logic for diagnostic breakdown prediction. The prompt encoded the diagnostic breakdown classification by defining decision criteria and illustrating labeling logic through a small set of examples. Special attention was given to distinguishing nondiagnostic issues, such as logistical delays or procedural discomfort, from true diagnostic failures, including miscommunication, delayed workup, or missed diagnoses. To guide the model’s reasoning, prompts included rationales alongside each example, enabling a form of chain-of-thought prompting [], guiding the model to reason step-by-step before arriving at a final decision.
The few-shot examples were sourced from two origins: (1) a previously published study of US hospital patient experience comments [] and (2) synthetically crafted cases developed by the research team to reflect generic diagnostic safety scenarios. All examples were reviewed by a diagnostic safety expert to ensure their alignment with the definition of diagnostic breakdowns and appropriateness for the ambulatory care setting.
Prompt design was an iterative, human-in-the-loop refinement process, systematically testing multiple prompt versions and progressively incorporating expert feedback. Across iterations, we refined the instruction language, classification criteria, and choice of examples to improve clarity and task alignment, especially for handling nuanced edge cases. The output format was standardized to include both a classification label and a concise rationale (≤50 tokens). Model-generated rationales were qualitatively reviewed by a domain expert (MAH) and used to refine subsequent prompt versions, with particular attention to cases in which the model classification differed from the initial human label or the rationale revealed ambiguity in the application of the codebook.
When expert review suggested that an initial human label might be inconsistent with the predefined coding criteria, the original comment was returned for targeted rereview against the codebook. Labels were corrected only when the expert review concluded that the original classification was not supported by the coding framework. The model output therefore served as a trigger for human re-evaluation rather than as the basis for relabeling. Following completion of this review, the corrected labels were incorporated into the finalized reference standard and locked for all reported analyses.
Since the model was not fine-tuned or updated (ie, no gradient steps or memory-based adaptation), and the prompts were crafted to be broadly generalizable, this process did not constitute model training in the conventional sense. However, prompt refinement was informed by qualitative review of model outputs during iterative development; therefore, phase III performance should be interpreted as prompt-optimized performance within this dataset rather than directly comparable held-out estimates of generalization, as in phases I and II.
Model Evaluation
Final performance analyses for phases I and II and the phase III version 4 prompt used the finalized reference standards, which incorporate corrections identified during the phase III human-in-the-loop process. To assess the model’s performance, we report a set of classification metrics appropriate for imbalanced binary outcomes ().
| Metric | Definition |
| Recall (sensitivity) | The proportion of positive cases correctly identified |
| Specificity | The proportion of negative cases correctly identified |
| Precision (positive predictive value) | The proportion of predicted positives that are truly positive |
| Negative predictive value | The proportion of predicted negatives that are truly negative |
| F1-score (positive class) | The harmonic mean of precision and recall for the positive class |
| Area under the receiver operating characteristic curve | Probability that the model ranks a randomly chosen positive instance higher than a randomly chosen negative one |
| Area under the precision-recall curve | Area under the curve plotting precision versus recall across thresholds—especially useful for imbalanced datasets |
Phases I and II were evaluated using stratified 5-fold cross-validation within a nested cross-validation framework. Given the high stakes of missing a diagnostic breakdown, recall was prioritized to reflect the model’s ability to correctly identify true positive cases. However, because excessive false positives could lead to increased manual review burden in the intended retrospective screening workflow, precision (positive predictive value) was also considered important. To balance these 2 aspects, we emphasized the F1-score for the positive class. In addition, we reported area under the receiver operating characteristic curve (AUROC) and area under the precision-recall curve (AUPRC) as threshold-independent metrics. Means and SDs across the 5 folds are reported for each metric. Because phase III produced a discrete class label rather than a probability score as phases I and II, AUROC and AUPRC were not calculated. Performance was assessed on the full dataset using F1-score, recall, precision, specificity, and negative predictive value.
Ethical Considerations
The study was approved by the Michael Garron Hospital Research Ethics Board (REB #915-2312-Mis-413). All free-text survey responses were deidentified prior to analysis, with direct identifiers removed, and all procedures were conducted in accordance with institutional privacy and confidentiality requirements.
Results
Data
Initially, 44 of 523 responses were classified as diagnostic breakdowns. During phase III, an iterative review process led to recoding 9 responses: 8 previously labeled as no breakdown were reclassified as breakdown, and 1 originally labeled as breakdown was reassigned to no breakdown. Following this review, the final dataset included 51 (9.8%) diagnostic breakdown and 472 (90.2%) no breakdown.
Patients were stratified according to their finalized diagnostic breakdown classification. summarizes demographic and visit characteristics, including age, sex, and appointment department, by diagnostic breakdown status. Age did not differ significantly between groups (t57.5=–1.53; P=.13), and the distribution of appointment departments was also similar between groups (Fisher exact test, P=.92). However, sex distribution differed significantly (χ21=4.1; P=.04), with female patients representing a greater proportion of the diagnostic breakdown group than the no diagnostic breakdown group (37/51, 72.5% vs 273/472, 57.8%).
| Overall (n=523) | Breakdown (n=51) | No breakdown (n=472) | P value | |||
| Patient age at encounter (years) | .13 | |||||
| Mean (SD) | 62.0 (14.1) | 58.6 (16.7) | 62.3 (13.7) | |||
| Median (IQR) | 63.8 (54.4-72.2) | 63.5 (46.5-72.9) | 63.8 (55.0-72.2) | |||
| Patient sex, n (%) | .04 | |||||
| Female | 310 (59.3) | 37 (72.5) | 273 (57.8) | |||
| Male | 213 (40.7) | 14 (27.5) | 199 (42.2) | |||
| Department, n (%) | .92 | |||||
| Breast diagnostic | 8 (1.5) | 1 (2) | 7 (1.5) | |||
| Colposcopy | 8 (1.5) | 1 (2) | 7 (1.5) | |||
| Endoscopy | 57 (10.9) | 4 (7.8) | 53 (11.2) | |||
| Ophthalmology | 16 (3.1) | 2 (3.9) | 14 (3) | |||
| Fracture clinic | 151 (28.9) | 15 (29.4) | 136 (28.8) | |||
| Gynecology | 1 (0.2) | 0 (0) | 1 (0.2) | |||
| Plastic surgery | 32 (6.1) | 2 (3.9) | 30 (6.4) | |||
| Minor procedures | 11 (2.1) | 0 (0) | 11 (2.3) | |||
| Otolaryngology | 29 (5.5) | 4 (7.8) | 25 (5.3) | |||
| Preanesthetic assessment | 58 (11.1) | 8 (15.7) | 50 (10.6) | |||
| Surgery | 141 (27) | 13 (25.5) | 128 (27.1) | |||
| Thyroid DAUa | 2 (0.4) | 0 (0) | 2 (0.4) | |||
| Urology clinic | 9 (1.7) | 1 (2) | 8 (1.7) | |||
aDAU: diagnostic assessment unit.
In terms of response length, the average word count was 37.89 (SD 82.14), with a range from 1 to 970 words (median 20, IQR 9-39). Using TF-IDF representation, the final vocabulary size was 2076, with an average of 14.55 (SD 16.05) nonzero terms per response. When tokenized using the Twitter-RoBERTa tokenizer, the mean token count was 49.62 (SD 104.31), ranging from 3 to 1253 tokens (median 29, IQR 13-51), with 5 responses exceeding the model’s 512-token input limit; tokens beyond the first 512 were truncated.
Classification Model Performance: Phases I and II
We first examined the performance across phases I and II. summarizes the performance across stratified 5-fold cross-validation. The phase II model consistently outperformed the phase I model across almost all evaluation metrics. Importantly, recall improved notably from 0.626 to 0.767, reducing missed diagnostic breakdowns (ie, false negatives). The F1-score also improved, reflecting a better balance between precision and recall. In addition, AUROC rose from 0.810 to 0.921, and AUPRC improved from 0.490 to 0.564, demonstrating stronger overall discriminative ability and robustness across thresholds. Moreover, the phase II model exhibited lower variability across folds, as reflected by smaller SDs for recall (0.143 vs 0.252), F1-score (0.039 vs 0.170), and AUPRC (0.129 vs 0.201), suggesting greater stability.
| Metric | Phase I: TF-IDFb+XGBoostc, mean (SD) | Phase II: Twitter-RoBERTa fine-tuned, mean (SD) | Phase III: LLaMA prompt engineering |
| Recall | 0.626 (0.252) | 0.767 (0.143) | 0.961 |
| Specificity | 0.936 (0.042) | 0.921 (0.046) | 0.975 |
| Precision | 0.533 (0.118) | 0.550 (0.130) | 0.803 |
| NPVd | 0.959 (0.024) | 0.974 (0.016) | 0.996 |
| F1-score | 0.548 (0.170) | 0.620 (0.039) | 0.875 |
| AUROCe | 0.810 (0.135) | 0.921 (0.021) | N/Af |
| AUPRCg | 0.490 (0.201) | 0.564 (0.129) | N/A |
aPhase III values were calculated on the full dataset during prompt refinement and are therefore not directly comparable. AUROC and AUPRC were unavailable because phase III produced discrete labels rather than probability scores.
bTF-IDF: term frequency-inverse document frequency.
cXGBoost: extreme gradient boosting.
dNPV: negative predictive value.
eAUROC: area under the receiver operating characteristic curve.
fN/A: not applicable.
gAUPRC: area under the precision-recall curve.
Phase III Performance
Overview
In phase III, iterative prompt refinements progressively improved the LLaMA model’s ability to distinguish diagnostic breakdowns from general patient dissatisfaction. Four prompt versions were evaluated, each addressing limitations identified in the prior iteration. Because prompt refinement and performance assessment used the same study dataset, the reported phase III metrics represent development-set performance.
Across all 4 versions, the prompt retained a consistent overall structure comprising the assigned reviewer role, classification task, operational definition, classification framework, decision guidance, few-shot examples, and output requirements (). The classification labels, decision guidance, examples, and output requirements were progressively refined across versions. Full prompt texts for each version are provided in , and performance metrics are summarized in .
Role and task
“You are a reviewer specializing in diagnostic safety. Determine whether the following patient self-reported survey response reflects a patient-perceived diagnostic breakdown.”
Definition
“[Version-specific operational definition of diagnostic breakdown.]”
Classification framework
“[Version-specific classification labels and criteria.]”
Important considerations and decision guidance
“[Version-specific decision rules for distinguishing diagnostic breakdowns from experiential or logistical dissatisfaction and for addressing ambiguous cases.]”
Examples
“[Version-specific few-shot examples with classifications and, where applicable, brief rationales.]”
Output format
“[Version-specific required classification label and, where applicable, a concise rationale.]”
Case to classify
“Case: {incident}”
| Version | Recall | Specificity | Precision | NPVb | F1-score |
| Version 1 | 1.000 | 0.745 | 0.265 | 1.000 | 0.419 |
| Version 2 | 0.955 | 0.927 | 0.545 | 0.991 | 0.694 |
| Version 3 | 0.938 | 0.973 | 0.776 | 0.990 | 0.849 |
| Version 4 | 0.961 | 0.975 | 0.803 | 0.996 | 0.875 |
aArea under the receiver operating characteristic curve and area under the precision-recall curve were not reported because the large language model produced discrete labels rather than probability scores.
bNPV: negative predictive value.
Version 1: Baseline Prompt
Version 1 used a binary label system (breakdown/no breakdown) with a concise task definition and 5 synthetic few-shot examples. The definition framed a diagnostic breakdown as a failure (1) to establish an accurate and timely explanation or (2) to communicate it to the patient. No rationale was required in the model output.
While version 1 captured all true breakdown cases (recall=1.000), qualitative review revealed frequent overprediction of breakdowns in response to vague dissatisfaction, particularly long wait times or communication complaints without diagnostic impact. In the ambulatory setting, such delays do not constitute a breakdown unless they affect diagnosis or health outcomes.
This pattern produced a highly sensitive but imprecise classifier: while no true breakdowns were missed, precision was low (0.265), indicating high false positives from predictions. Overall performance was modest (F1=0.419), reflecting the imbalance between low precision and high recall (). The following excerpt illustrates an example misclassification:
Case: it’s always a very long wait time at the fracture clinic.
Issue: The model labeled this as a breakdown despite no indication of harm or diagnostic delay.
Version 2: Explicit Exclusion Criteria
Version 2 refined both the definition and the examples by adding explicit exclusion criteria for wait times and communication issues that did not affect diagnosis or clinical care. The following excerpt illustrates an added rule in the definition:
A long wait time for an appointment alone does not constitute a diagnostic breakdown unless the delay may have contributed to a deterioration in health or delayed diagnosis/treatment.
Miscommunication before a visit/procedure is not a breakdown unless it directly affects diagnosis or clinical care (eg, fasting instructions).
In addition, we revised the synthetic few-shot examples to include concise rationales that demonstrated how each label aligned with the updated definition. The output format was also modified to require the model to generate a rationale after each label, enabling the evaluation of its reasoning.
Following these modifications, observed discrimination improved notably. Precision approximately doubled from 0.265 to 0.545, reflecting a substantial reduction in false positives, while recall remained high (0.955). Specificity improved from 0.745 to 0.927, indicating more accurate rejection of nonbreakdown cases. As a result, overall model balance improved considerably (F1=0.694; ).
Despite these gains, version 2 continued to struggle with borderline cases. Of the 37 cases misclassified by version 2, a total of 13 (35%) involved emotional distress, indirect communication issues, or unclear diagnostic impacts. These cases revealed the challenges of applying a binary classification framework, as edge cases often involved subtle or ambiguous nuances that were not well-captured by a simple yes/no decision.
Version 3: 3-Class Framework and Real Examples
To address these issues, version 3 introduced a major conceptual shift by implementing a 3-class framework, explicitly designed to capture varying degrees of diagnostic concern:
- Diagnostic breakdown—clear: Explicit evidence of diagnostic breakdown impacting health outcomes or clearly disrupting diagnosis/treatment.
- Diagnostic breakdown—suggestive: Indicators suggesting possible diagnostic breakdown, typically communication-related, potentially impacting the patient’s physical or mental health status.
- No breakdown: No clear or suggestive evidence of a diagnostic breakdown. Includes experience or logistical complaints (eg, scheduling or wayfinding issues) without evidence of health impact or diagnostic disruption.
Additionally, the operational definition in version 3 was expanded to include a third diagnostic failure type:
(c) in the diagnostic process (ie, in clinical history taking, physical examination, referrals, diagnostic testing, communication, treatment) that lead to worse physical or mental health conditions for the patient.
This reframing emphasized patient-perceived harm and broadened the task to capture failures in the diagnostic process itself. Emotional and mental health consequences were considered valid breakdowns if clearly linked to diagnostic clarity or communication.
Furthermore, version 3 replaced the synthetic few-shot examples with real patient-reported cases from our previously published, annotated US patient experience survey study []. Each example was accompanied by a concise rationale, explicitly linking it to the refined classification definitions. The following excerpt illustrates a new example of version 3:
Case: The 6-month wait for an appointment meant my condition worsened significantly before I was seen.
Classification: Dx breakdown—clear
Rationale: This is a violation of definition (a)—failure to establish a timely explanation. The delay in diagnosis led to worsening health, which satisfies the criteria for a diagnostic breakdown.
Following this structural change, fewer ambiguous cases were classified as clear diagnostic breakdowns, the observed precision increased to 0.776, and specificity rose to 0.973, indicating continued reduction in false positives. Recall remained strong (0.938), and overall performance improved (F1=0.849; ).
While version 3 addressed structural ambiguity, some residual inconsistencies remained in how the model interpreted emotional or mental health–related narratives, particularly in distinguishing routine frustration or dissatisfaction from more serious psychological consequences such as panic, fear, or sustained emotional distress.
We also observed that 4 of 13 (31%) false-positive cases involved the model classifying general experiential complaints, such as discomfort during procedures, rude staff interactions, or facility-related issues, as breakdowns, even when these had no direct impact on diagnostic clarity, timeliness, or communication.
Version 4: Refined Guidance on Emotional Harm and Experiential Complaints
Version 4 introduced more precise guidance on when emotional or mental harm qualifies as a diagnostic breakdown, as well as stricter rules to distinguish experiential dissatisfaction from diagnostic safety failures, reinforcing that not all negative experiences reflect breakdowns in diagnostic care. The following excerpt illustrates an added guidance on emotional harm:
Emotional or mental distress must be considered meaningfully—mild stress or frustration alone is not sufficient. However, if the patient perceives a notable deterioration in mental health related to diagnostic clarity or communication, this can be considered a breakdown.
The following excerpt illustrates an added clarification on experiential complaints:
Experiential or logistical dissatisfaction—such as discomfort during procedures, negative interactions with staff, or facility-related issues—should not be classified as a diagnostic breakdown unless there is a clear impact on the diagnostic process, timeliness, or communication. These issues reflect patient experience but not diagnostic safety failure.
Version 4 achieved the highest observed performance among the 4 prompt versions on the study dataset. The model maintained high sensitivity (recall=0.961) while achieving improved precision (0.803). Specificity remained high (0.975), and the resulting F1-score was 0.875 ().
On the full study dataset, the version 4 confusion matrix () showed that 49 of 51 breakdown cases were correctly identified, with only 2 false negatives, and 460 of 472 nonbreakdown cases were correctly rejected, with 12 false positives. This error pattern was consistent with the intended use of the model as a surveillance and case-screening tool.

As shown in , the phase III version 4 model produced the highest observed F1-score (0.875), compared with the nested cross-validated estimates of 0.548 for phase I and 0.620 for phase II. Within phase III, version 4 maintained high recall while substantially improving precision, suggesting that graded classification categories, explicit domain criteria, and expert-aligned rationales may help distinguish diagnostic-safety concerns from general patient dissatisfaction.
Discussion
Principal Findings
This study evaluated 3 increasingly context-sensitive NLP approaches and found that routine ambulatory patient-experience comments at a Canadian hospital contained identifiable signals of patient-perceived diagnostic breakdowns. Under nested cross-validation, phase II improved on phase I across recall, F1-score, AUROC, and AUPRC, while phase III achieved the highest observed F1-score (0.875) on the full dataset. The performance patterns across phases reflected differences in each method’s ability to capture contextual nuance and distinguish diagnostic concerns from general dissatisfaction, highlighting the value of context-sensitive and reasoning-capable methods for diagnostic-safety surveillance.
Qualitative review of phase III outputs further indicated that the model could apply explicit prompt criteria to borderline cases, including distinguishing diagnostic delays from routine scheduling concerns. Iterative refinement with diagnostic-safety experts was central to improving that distinction. However, because phase III was refined and evaluated on the same dataset, the results demonstrate the promise of instruction-tuned LLMs for the task rather than definitive superiority over the cross-validated models.
Comparison With Prior Work
Consistent with Tabaie et al [], the phase I model showed that lexical features can identify diagnostic-safety signals. In our patient-authored comments, however, high-weighted terms such as “wait” and “appoint” appeared in both diagnostically relevant narratives and general service complaints, and the TF-IDF model often could not distinguish between them. The difficulty reflects a broader challenge of applying lexical models to patient-authored comments, which are typically more informal and variable than clinical documentation [].
Fine-tuning Twitter-RoBERTa improved recall and reduced the need for extensive preprocessing, consistent with prior evidence that alignment between pretraining data and patient-authored language can improve performance [,]. Madanay et al [] similarly found that a fine-tuned RoBERTa model could classify the presence and valence of patients’ judgments about physicians’ interpersonal manner and technical competence in web-based reviews. Those evaluative outcomes were generally more directly expressed than the diagnostic-breakdown construct examined in our study, which required distinguishing subtle diagnostic concerns from overlapping complaints about communication, waiting, and service quality. Phase II’s remaining errors suggest that contextual embeddings improved interpretation of patient-authored language but were not sufficient to consistently apply a narrowly defined diagnostic-safety construct, particularly with a small positive class.
Koh et al [] similarly applied LLMs to patient complaint narratives but found variable agreement with human reviewers, with stronger performance for broad complaint domains than for severity and harm. Their study classified multiple Healthcare Complaints Analysis Tool fields using capable proprietary LLMs and fixed zero-shot prompts, whereas our narrower diagnostic-safety task used a locally deployed LLaMA 3.3 70B model with few-shot examples, explicit exclusion criteria, generated rationales, and iterative expert refinement. The stronger observed phase III results may therefore reflect greater task-specific prompt adaptation rather than greater underlying model capability. Direct comparison remains inappropriate because the tasks, models, datasets, and evaluation designs differed.
In line with previous work by Baker et al [] and Smith et al [], our findings show that routinely collected patient-experience comments can contain diagnostic-safety signals. Our study extends that evidence to a Canadian ambulatory setting. Diagnostic breakdowns accounted for 9.8% (51/523) of included comments, lower than the approximately one-quarter of negative comments reported by Baker et al []. The difference likely reflects the broader denominator in our study, which included all comments rather than negative comments only, and should not be interpreted as evidence of a lower underlying frequency.
The higher proportion of female patients in the diagnostic-breakdown group may reflect differences in diagnostic experiences, reporting patterns, or other unmeasured factors, as prior studies have identified sex differences in both patient-reported health care experiences and diagnostic trajectories [,]. Given the small number of male breakdown cases, this finding should be interpreted cautiously and explored in larger studies.
Implications for Diagnostic-Safety Surveillance
The findings support further evaluation of the classifier as a retrospective screening tool within existing quality-improvement workflows. Health systems could periodically review patient-experience comments and route flagged or borderline cases to patient-safety teams, while human reviewers determine whether further investigation or action is warranted. Because many organizations already collect these comments, the approach could expand diagnostic-safety surveillance without requiring a new data-collection system. Local deployment may also reduce privacy and data-governance concerns by keeping patient comments within the organization’s computing environment []. Implementation would still require technical integration, model maintenance, governance, and staff capacity to review flagged cases.
Scalability and computational requirements differed across approaches. Phase I had the lowest computational burden, phase II required additional resources for transformer fine-tuning, and phase III required greater graphics processing unit memory and inference time. In our local configuration, phase III inference with rationale generation required approximately 30 seconds per comment, supporting periodic review of moderate survey volumes but potentially requiring greater local computing capacity or secure cloud-based deployment at larger scale. These options introduce trade-offs in cost, privacy, and governance. More broadly, pairing an operational codebook with iteratively refined prompting may extend to other quality-of-care concerns. However, the classification framework and prompts would need to be adapted to the specific construct and clinical context and independently validated before use. The full prompt-development process is provided in to support local adaptation and validation.
Limitations
This study has several limitations. First, all data came from one Canadian hospital’s ambulatory patient-experience survey and were classified using a locally developed codebook. The results should not be assumed to generalize to other institutions, health systems, survey instruments, or patient populations.
Second, patient comments are typically brief and lack the clinical detail available in a medical record. Model outputs should therefore be interpreted as signals warranting further review, not as definitive evidence of diagnostic breakdown.
Third, the evaluation frameworks differed structurally across phases. Phases I and II were assessed using nested cross-validation on held-out folds, whereas phase III was refined and evaluated on the same full dataset. Phase III performance should therefore be interpreted as prompt-development performance within this dataset rather than as an independent estimate of generalizability or a directly comparable result.
Fourth, prompt development required iterative expert refinement and may need adaptation for other settings or definitions. Some borderline cases remained inherently ambiguous even after expert review, so performance metrics should be interpreted relative to the finalized consensus reference standard rather than as measures against an objective diagnostic truth. Additionally, during phase III, review of model rationales also prompted reconsideration of 9 original labels, which may have increased alignment between the finalized reference standard and the phase III prompt.
Finally, the study sample was limited by both selective free-text response and a small positive class. Only 523 of 1074 survey respondents provided a comment, and those who did may differ systematically from those who did not. Among included comments, only 51 (9.8%) contained diagnostic breakdowns. Although phases I and II used class weighting and stratified cross-validation, the limited number of positive cases likely contributed to variability and uncertainty in performance estimates. Phase III did not rely on supervised fine-tuning on these labels, but its development-set performance was likewise estimated from only 51 positive cases and requires validation in larger, independent samples.
Future Directions
Building on these findings, 3 directions may extend this work. First and foremost, the model and prompts developed here should be validated across different health systems and health care settings using a finalized prompt evaluated on data that were not used in its development. Second, improving the underlying narrative data, rather than only the models applied to them, may enhance detection. Structured narrative-elicitation protocols have been shown to produce more complete and meaningful patient accounts than a single open-ended survey question and could increase the information available for NLP-based classification []. Applying this approach to surveys specifically designed to capture patient-perceived diagnostic excellence may also yield narratives better suited to this task []. Third, hybrid approaches combining automated classification with structured human review for uncertain or borderline cases may improve trust, utility, and real-world adoption relative to either fully automated or fully manual review.
Conclusions
Patient-authored survey narratives represent an underused source of information for diagnostic safety and quality improvement. This study demonstrates that evolving NLP methods, particularly instruction-tuned LLMs, can identify diagnostic breakdown signals within patient-authored survey narratives. Context-sensitive and reasoning-capable models may enhance the detection of subtle diagnostic concerns in free-text comments, although phase III performance reflects iterative prompt development on the full dataset. Leveraging routinely collected patient experience data through modern NLP may offer a feasible strategy to expand diagnostic safety surveillance and support continuous quality improvement efforts in health care systems. Future work should externally validate the finalized model and prompt and prospectively evaluate their integration into diagnostic-safety workflows.
Data Availability
The datasets generated or analyzed during this study are not publicly available due to institutional privacy and confidentiality restrictions concerning hospital patient experience survey data but may be available from the corresponding author on reasonable request, subject to institutional approval.
Funding
The authors declare that financial support was received for the research, authorship, and publication of this article. This project was funded (grant R18HS029356) from the Agency for Healthcare Research and Quality (AHRQ), US Department of Health and Human Services (HHS; KEM, KMS, TDG, principal investigators). The authors are solely responsible for this document’s contents, findings, and conclusions, which do not necessarily represent the views of AHRQ. Readers should not interpret any statement in this report as an official position of AHRQ or of HHS. KMS receives funding from the Michael Garron Hospital Foundation as the Michael Garron Chair in Patient Oriented Research. None of the authors has any affiliation or financial involvement that conflicts with the material presented in this report.
Generative AI Use
The authors declare that generative AI was used in the creation of this manuscript. Generative AI (ChatGPT) was used for proofreading, editing, or language polishing. The authors verified all outputs of the tools used in the preparation of this manuscript and take full responsibility for the final content of the manuscript.
Authors' Contributions
Conceptualization: YQ, MAH, KEM, KMS
Data curation: MAH, SK, KMS
Funding acquisition: KMS, TDG, KEM, HH
Methodology: YQ, MAH, AT, KN, KMS
Supervision: KMS
Validation: MAH, SK, KMS
Writing – original draft: YQ, MAH
Writing – review & editing: All authors
Conflicts of Interest
None declared.
Ambulatory patient experience survey codebook: patient-perceived diagnostic breakdowns.
DOCX File , 36 KBHyperparameter search space.
DOCX File , 23 KBPrompt design and iteration details.
DOCX File , 25 KBReferences
- Singh H, Meyer AND, Thomas EJ. The frequency of diagnostic errors in outpatient care: estimations from three large observational studies involving US adult populations. BMJ Qual Saf. 2014;23(9):727-731. [FREE Full text] [CrossRef] [Medline]
- Newman-Toker DE, Nassery N, Schaffer AC, Yu-Moe CW, Clemens GD, Wang Z, et al. Burden of serious harms from diagnostic error in the USA. BMJ Qual Saf. 2024;33(2):109-120. [CrossRef] [Medline]
- Committee on Diagnostic Error in Health Care, Board on Health Care Services, Institute of Medicine, The National Academies of Sciences, Engineering, Medicine. Improving Diagnosis in Health Care. Washington, DC. National Academies Press; 2015.
- Cox CL, Miller BM, Kuhn I, Fritz Z. Diagnostic uncertainty in primary care: what is known about its communication, and what are the associated ethical issues? Fam Pract. 2021;38(5):654-668. [FREE Full text] [CrossRef] [Medline]
- Singh H, Weingart SN. Diagnostic errors in ambulatory care: dimensions and preventive strategies. Adv Health Sci Educ Theory Pract. 2009;14 Suppl 1(0 1):57-61. [FREE Full text] [CrossRef] [Medline]
- Murphy DR, Meyer AN, Sittig DF, Meeks DW, Thomas EJ, Singh H. Application of electronic trigger tools to identify targets for improving diagnostic safety. BMJ Qual Saf. 2019;28(2):151-159. [FREE Full text] [CrossRef] [Medline]
- Wolf ZR, Hughes RG. Error reporting and disclosure. In: Hughes RG, editor. Patient Safety and Quality: An Evidence-Based Handbook for Nurses. Rockville, MD. Agency for Healthcare Research and Quality (US); 2008.
- Giardina TD, Haskell H, Menon S, Hallisy J, Southwick FS, Sarkar U, et al. Learning from patients' experiences related to diagnostic errors is essential for progress in patient safety. Health Aff (Millwood). 2018;37(11):1821-1827. [FREE Full text] [CrossRef] [Medline]
- Bell SK, Bourgeois F, DesRoches CM, Dong J, Harcourt K, Liu SK, et al. Filling a gap in safety metrics: development of a patient-centred framework to identify and categorise patient-reported breakdowns related to the diagnostic process in ambulatory care. BMJ Qual Saf. 2022;31(7):526-540. [CrossRef] [Medline]
- Baker KM, Brahier M, Penne M, Hill MA, Davis S, Gallagher WJ, et al. Using patient experience surveys to identify potential diagnostic safety breakdowns: a mixed methods study. J Patient Saf. 2024;20(8):556-563. [CrossRef] [Medline]
- Hill MA, Haskell H, Dainty KN, Kuluski K, Shea C, Heimlich L, et al. Scoping review of patient and family engagement interventions in diagnosis: a paradox of too much, yet so little. BMJ Qual Saf. 2026;35(8):552-564. [FREE Full text] [CrossRef] [Medline]
- Smith K, Baker K, Haskell H, Hill M, Tate J. Using patient experience surveys to assess diagnostic safety in urgent care. Health Services Research. 2021;56(S2):53-54. [CrossRef]
- McDonald KM, Bryce CL, Graber ML. The patient is in: patient involvement strategies for diagnostic error mitigation. BMJ Qual Saf. 2013;22(Suppl 2):ii33-ii39. [FREE Full text] [CrossRef] [Medline]
- Tabaie A, Tran A, Calabria T, Bennett SS, Milicia A, Weintraub W, et al. Evaluation of a natural language processing approach to identify diagnostic errors and analysis of safety learning system case review data: retrospective cohort study. J Med Internet Res. 2024;26:e50935. [FREE Full text] [CrossRef] [Medline]
- Ren Y, Wu Y, Fan JW, Khurana A, Fu S, Wu D, et al. Automatic uncovering of patient primary concerns in portal messages using a fusion framework of pretrained language models. J Am Med Inform Assoc. 2024;31(8):1714-1724. [FREE Full text] [CrossRef] [Medline]
- Alhazzani NZ, Al-Turaiki IM, Alkhodair SA. Text classification of patient experience comments in Saudi dialect using deep learning techniques. Appl Sci. 2023;13(18):10305. [CrossRef]
- Madanay F, Tu K, Campagna A, Davis JK, Doerstling SS, Chen F, et al. Classification of patients' judgments of their physicians in web-based written reviews using natural language processing: algorithm development and validation. J Med Internet Res. 2024;26:e50236. [FREE Full text] [CrossRef] [Medline]
- Reader TW, Gillespie A, Roberts J. Patient complaints in healthcare systems: a systematic review and coding taxonomy. BMJ Qual Saf. 2014;23(8):678-689. [FREE Full text] [CrossRef] [Medline]
- Wang J, Shi E, Yu S, Wu Z, Hu H, Ma C, et al. Prompt egineering for healthcare: methodologies and applications. Meta-Radiology. 2026;4(1):100190. [CrossRef]
- Singhal K, Tu T, Gottweis J, Sayres R, Wulczyn E, Amin M, et al. Toward expert-level medical question answering with large language models. Nat Med. 2025;31(3):943-950. [CrossRef] [Medline]
- Hu D, Zhang S, Liu Q, Zhu X, Liu B. Large language models in summarizing radiology report impressions for lung cancer in Chinese: evaluation study. J Med Internet Res. 2025;27:e65547. [FREE Full text] [CrossRef] [Medline]
- Koh SWC, Wong ERN, Tan JCM, van der Lubbe SCC, Goh JC, Ching ESY, et al. Classifying patient complaints using artificial intelligence-powered large language models: cross-sectional study. J Med Internet Res. 2025;27:e74231. [FREE Full text] [CrossRef] [Medline]
- Landis JR, Koch GG. The measurement of observer agreement for categorical data. Biometrics. 1977;33(1):159-174. [Medline]
- Sparck Jones K. A statistical interpretation of term specificity and its application in retrieval. J Doc. 1972;28(1):11-21. [CrossRef]
- HaCohen-Kerner Y, Miller D, Yigal Y. The influence of preprocessing on text classification using a bag-of-words representation. PLoS One. 2020;15(5):e0232525. [FREE Full text] [CrossRef] [Medline]
- Bird S, Klein E, Loper E. Natural Language Processing with Python: Analyzing Text with the Natural Language Toolkit. Sebastopol, CA. O'Reilly Media, Inc; 2009.
- Salton G, Buckley C. Term-weighting approaches in automatic text retrieval. Inf Process Manag. 1988;24(5):513-523. [CrossRef]
- Manning CD, Raghavan P, Schütze H. Introduction to Information Retrieval. Cambridge. Cambridge University Press; 2008.
- Chen T, Guestrin C. XGBoost: a scalable tree boosting system. 2016. Presented at: KDD '16: Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining; August 13-17, 2016:785-794; San Francisco, CA, United States. [CrossRef]
- Akiba T, Sano S, Yanase T, Ohta T, Koyama M. Optuna: a next-generation hyperparameter optimization framework. 2019. Presented at: KDD '19: Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining; August 4-8, 2019:2623-2631; Anchorage, AK, United States. [CrossRef]
- Vaswani A, Shazeer N, Parmar N, Uszkoreit J, Jones L, Gomez AN, et al. Attention is all you need. 2017. Presented at: 31st Conference on Neural Information Processing Systems (NIPS 2017); December 4-9, 2017:5998-6008; Long Beach, CA, United States.
- Devlin J, Chang MW, Lee K, Toutanova K. BERT: pre-training of deep bidirectional transformers for language understanding. 2019. Presented at: Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers); June 2-7, 2019:4171-4186; Minneapolis, MN, United States. [CrossRef]
- Rogers A, Kovaleva O, Rumshisky A. A primer in BERTology: what we know about how BERT works. Trans Assoc Comput Linguist. 2020;8:842-866. [FREE Full text] [CrossRef]
- Lee J, Yoon W, Kim S, Kim D, Kim S, So C, et al. BioBERT: a pre-trained biomedical language representation model for biomedical text mining. Bioinformatics. 2020;36(4):1234-1240. [FREE Full text] [CrossRef] [Medline]
- Huang K, Altosaar J, Ranganath R. ClinicalBERT: modeling clinical notes and predicting hospital readmission. ArXiv. Preprint posted online on November 29, 2020. [CrossRef]
- Howard J, Ruder S. Universal language model fine-tuning for text classification. 2018. Presented at: Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers); July 15-20, 2018:328-339; Melbourne, Australia. [CrossRef]
- Nunes M, Bone J, Ferreira JC, Elvas LB. Health care language models and their fine-tuning for information extraction: scoping review. JMIR Med Inform. 2024;12:e60164. [FREE Full text] [CrossRef] [Medline]
- Mermin-Bunnell K, Zhu Y, Hornback A, Damhorst G, Walker T, Robichaux C, et al. Use of natural language processing of patient-initiated electronic health record messages to identify patients with COVID-19 infection. JAMA Netw Open. 2023;6(7):e2322299. [FREE Full text] [CrossRef] [Medline]
- Loureiro D, Barbieri F, Neves L, Anke L, Camacho-Collados J. TimeLMs: diachronic language models from Twitter. 2022. Presented at: Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics: System Demonstrations; May 22-27, 2022:251-260; Dublin, Ireland. URL: https://aclanthology.org/2022.acl-demo.25/ [CrossRef]
- Mangrulkar S, Gugger S, Debut L, Belkada Y, Paul S, Bossan B. PEFT: State-of-the-art parameter-efficient fine-tuning methods. GitHub. 2022. URL: https://github.com/huggingface/peft [accessed 2026-10-30]
- Wolf T, Debut L, Sanh V, Chaumond J, Delangue C, Moi A, et al. Transformers: state-of-the-art natural language processing. 2020. Presented at: Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations; November 16-20, 2020:38-45; Online. [CrossRef]
- Hu EJ, Shen Y, Wallis P, Allen-Zhu Z, Li Y, Wang S, et al. LoRA: low-rank adaptation of large language models. 2022. Presented at: Proceedings of the 10th International Conference on Learning Representations; April 25-29, 2022; Online. URL: https://openreview.net/pdf?id=nZeVKeeFYf9
- Loshchilov I, Hutter F. Decoupled weight decay regularization. 2019. Presented at: Proceedings of the 7th International Conference on Learning Representations; May 6-9, 2019; New Orleans, LA, United States. URL: https://openreview.net/forum?id=Bkg6RiCqY7
- LLaMA 3.3 70B instruct model card. AI@Meta. URL: https://github.com/meta-llama/llama3/blob/main/MODEL_CARD.md [accessed 2026-10-30]
- Zhang S, Dong L, Li X, Zhang S, Sun X, Wang S, et al. Instruction tuning for large language models: a survey. ACM Comput Surveys. 2025;58(7):1-36. [CrossRef]
- Ollama: a lightweight, extensible framework for local LLaMA model inference. Ollama Inc. 2025. URL: https://ollama.com/library/llama3 [accessed 2026-10-30]
- Wei J, Wang X, Schuurmans D, Bosma M, Ichter B, Xia F, et al. Chain-of-thought prompting elicits reasoning in large language models. 2022. Presented at: 36th Annual Conference on Neural Information Processing Systems (NeurIPS 2022); November 28-December 9, 2022:24824-24837; New Orleans, LA, United States. [CrossRef]
- Ballering AV, Muijres D, Uijen AA, Rosmalen JGM, Olde Hartman TC. Sex differences in the trajectories to diagnosis of patients presenting with common somatic symptoms in primary care: an observational cohort study. J Psychosom Res. 2021;149:110589. [FREE Full text] [CrossRef] [Medline]
- Mitchell S, Schlesinger M. Managed care and gender disparities in problematic health care experiences. Health Serv Res. 2005;40(5 Pt 1):1489-1513. [FREE Full text] [CrossRef] [Medline]
- Hassan M, Kushniruk A, Borycki E. Barriers to and facilitators of artificial intelligence adoption in health care: scoping review. JMIR Hum Factors. 2024;11:e48633. [FREE Full text] [CrossRef] [Medline]
- Grob R, Schlesinger M, Parker AM, Shaller D, Barre LR, Martino SC, et al. Breaking narrative ground: innovative methods for rigorously eliciting and assessing patient narratives. Health Serv Res. 2016;51(Suppl 2):1248-1272. [FREE Full text] [CrossRef] [Medline]
- O'Hanlon CE, Berdahl C, Ye F, Ohana E, Tolpadi A, Bradley MA, et al. Surveying patients to assess timeliness of cancer diagnosis. Diagnosis (Berl). 2026;13(2):300-311. [FREE Full text] [CrossRef] [Medline]
Abbreviations
| AUPRC: area under the precision-recall curve |
| AUROC: area under the receiver operating characteristic curve |
| EHR: electronic health record |
| LLM: large language model |
| LoRA: low-rank adaptation |
| NASEM: National Academies of Sciences, Engineering, and Medicine |
| NLP: natural language processing |
| TF-IDF: term frequency-inverse document frequency |
| XGBoost: extreme gradient boosting |
Edited by I Steenstra; submitted 27.Apr.2026; peer-reviewed by K McDonald, K Savolainen, S Saini, RA Price; comments to author 20.Jul.2026; revised version received 28.Oct.2026; accepted 28.Oct.2026; published 02.Dec.2026.
Copyright©Yiyang Qu, Mary A Hill, Azade Tabaie, Kewei Ni, Sharifa Kazi, Traber D Giardina, Helen Haskell, Kristen E Miller, Kelly M Smith. Originally published in JMIR AI (https://ai.jmir.org), 02.Dec.2026.
This is an open-access article distributed under the terms of the Creative Commons Attribution License (https://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work, first published in JMIR AI, is properly cited. The complete bibliographic information, a link to the original publication on https://www.ai.jmir.org/, as well as this copyright and license information must be included.

