Editor’s introduction
Researchers assessed 14 locally deployable, instruction-tuned open-source large language models using 1,664 expert-annotated clinical question-answer pairs from Finnish breast cancer patients. The study found clinically significant errors in 2.9% of outputs and discordant responses in 0.96% of semantically equivalent queries, indicating variability in output reliability. All evaluations occurred in a fully offline environment, processing complete longitudinal records without pre-selection. While models demonstrated strong performance in retrieving patient-specific information, the presence of clinically relevant errors underscores the need for human validation in real-world clinical use.
Introduction
Modern clinical practice faces an information paradox. Electronic health records (EHRs) contain extensive longitudinal patient data, yet the volume and fragmentation of these records impose a substantial cognitive burden on clinicians in their daily practice. In oncology and other multidisciplinary medical specialities, patient histories are distributed across years of heterogeneous EHR documentation, including radiology and pathology reports, surgical summaries, and medication records. Synthesizing this information during active consultations is time-consuming and prone to oversight, potentially increasing workload, and delaying interpretation, particularly when clinicians rely on manual review or keyword-based search across dispersed documentation. Systems must therefore support flexible, natural language querying of patient EHRs and return precise, context-aware answers grounded in complete longitudinal records. Such capabilities could improve workflow efficiency, reduce cognitive burden, and support higher-quality clinical decision-making.
Large language models (LLMs) have recently been applied to question answering over EHRs to improve access to complex clinical information. In this work, we refer to patient-specific QA grounded in longitudinal clinical records as clinical contextual question answering (CCQA). Unlike standard document retrieval, this task requires synthesizing information across multiple sources to derive clinically relevant variables such as diagnosis timing, disease characteristics, or treatment sequences. Previous work has shown that LLMs can encode clinical knowledge and achieve strong performance on medical question answering tasks, and these models have been applied to EHR-based QA using synthetic patient records. However, synthetic data may not capture the scale and complexity of real-world clinical information, which spans years of heterogeneous structured and unstructured patient records. As a result, patient-specific QA over EHRs using LLMs remains comparatively underexplored in studies using real-world clinical data.
This gap is further pronounced in healthcare settings involving non-English clinical texts. In Finland’s healthcare system, EHRs are primarily written in Finnish, with embedded English and Latin terminology, domain-specific abbreviations, and complex linguistic structures that challenge general-domain language models. Prior work in Finnish clinical NLP is limited and has focused mainly on task-specific classification and information extraction, with no prior studies, to our knowledge, evaluating generative LLMs for patient-specific clinical question answering over Finnish-language EHRs. More broadly, these challenges reflect pretraining imbalances, as medical text constitutes only a small fraction of large-scale corpora and many languages remain under-represented. Together, this setting provides a stringent test of model generalization beyond standard benchmarks.
Historically, many clinically relevant natural language processing systems have relied on retrieval-augmented generation (RAG) to manage long documents by retrieving and processing subsets of the record. Such approaches can be limited in tasks requiring longitudinal reasoning, particularly when it is unclear which parts of the patient history are relevant. In complex specialties such as oncology, accurate interpretation often requires integrating events separated by months or years, distinguishing active disease from historical or resolved findings, and reasoning over the clinical timeline. Recent advances in large language models have enabled substantially longer input sequences, allowing models to process full patient EHRs and support end-to-end reasoning over longitudinal clinical histories.
Despite rapid progress in LLM development, several important questions remain unresolved. First, it is unclear how model scale, architecture, and domain specialization influence performance in real-world CCQA over longitudinal EHRs. Second, although low-precision quantization has been proposed to enable deployment on resource-constrained hardware, its impact on clinical reliability remains unknown. Third, most prior medical LLM research focuses on general question answering, narrowly defined extraction tasks, or synthetic data, leaving uncertainty about performance in multilingual, longitudinal clinical narratives. Finally, accuracy alone is insufficient for clinical adoption. Consistency across semantically equivalent queries and calibration of model confidence are essential for trustworthy integration into clinical workflows.
In this study, we present a systematic benchmark of retrieval-free long-context LLMs for Clinical Contextual Question Answering in a multilingual oncology environment. Using a dataset of 1,664 expert-annotated question–answer pairs derived from EHRs of 183 patients undergoing breast cancer screening or treatment, we evaluated five families of open-source models ranging from 4 billion to 70 billion parameters. Our analysis examines accuracy, response consistency across semantically equivalent queries, calibration of model confidence, memory footprint under extended sequence lengths, and the impact of quantization and prompting strategies. In addition, we conducted a clinical safety evaluation of incorrect responses from the highest-performing model to assess their clinical significance. By providing a comprehensive comparison of locally deployable models operating on full patient histories, this work demonstrates the feasibility of privacy-preserving, retrieval-free clinical information retrieval and offers practical insights into how model scale, architecture, and deployment constraints shape real-world clinical AI performance.
Discussion
In this study we have evaluated 14 locally deployable, instruction-tuned open-source large language models for Clinical Contextual Question Answering (CCQA) across complete longitudinal electronic health records in a Finnish oncology setting. Several long-context generalist models demonstrated high accuracy and strong agreement across semantically equivalent question formulations. This suggests that patient-specific clinical information can be accurately retrieved from heterogeneous Finnish EHR narratives when complete records are processed without retrieval-based preselection. All experiments were performed within a closed offline computing environment without external data transmission. By assessing accuracy, response consistency, probabilistic calibration, inference latency, GPU memory requirements, quantization behaviour, and clinician-adjudicated safety, this work provides a deployment-oriented characterization of model performance under realistic offline constraints.
Prior work on medical natural language processing has focused primarily on medical question-answering benchmarks or narrowly scoped extraction tasks. In this study, we address patient-specific reasoning in complete longitudinal records in an under-represented clinical language setting, specifically EHRs in Finnish, where clinically relevant information may be distributed across years of documentation. Rather than segmenting records using retrieval pipelines, we examined retrieval-free ingestion of complete patient histories, enabling assessment of contextual integration across temporally separated clinical events. This design reflects clinical scenarios in which relevant information may be dispersed and not easily identifiable through local similarity-based retrieval alone. The observed performance suggests that long-context instruction-tuned models can support privacy-preserving clinical information retrieval within institutionally governed infrastructure.
For large language models, performance generally improves with scale. However, we found that parameter count alone did not determine clinical task performance. A mid-sized 30B-parameter model achieved accuracy comparable to the leading 70B models, while requiring substantially less memory and lower latency, suggesting that architectural efficiency and instruction tuning influence downstream clinical utility. Furthermore, reasoning-oriented LLMs reached similar accuracy but incurred longer inference times due to intermediate reasoning steps, without consistent gains in final answer accuracy. In time-constrained clinical workflows, such latency may limit usability. Thus, model selection in healthcare settings should jointly consider predictive performance, computational efficiency, and workflow compatibility.
Agreement across semantically equivalent question formulations was high among the top-performing systems, with several models achieving consistency rates between 97% and 98%. Such stability is desirable in clinical settings, where queries can be phrased in multiple ways. Nevertheless, our clinical safety analysis revealed that paraphrasing can produce divergent responses in some cases, with some formulations yielding correct answers while others lead to clinically significant errors. The robustness to linguistic variation, therefore, remains only partially resolved and should be considered when integrating LLMs into clinical workflows. Because model outputs may depend on the precise wording of an input, evaluation frameworks for clinical language models should account for potential sensitivity to question formulation.
For individual clinical questions, the best-performing models achieved high accuracy, with question-specific performance ranging from 87% to 100% (Supplementary Tables 2 and 3). Questions involving categorical attributes typically documented in pathology reports or treatment summaries, such as tumour laterality or invasiveness, histological subtype, and receptor status, were answered with consistently high accuracy. In contrast, lower performance was observed in tasks requiring temporal reasoning over treatment timelines or interpretation of quantitative values in electronic health records. For example, determining whether a patient received neoadjuvant therapy (i.e., treatment administered before surgery), requires integrating temporally separated information. These patterns suggest that long-context language models perform most reliably when clinical variables are explicitly documented, whereas tasks requiring contextual interpretation across longitudinal documentation remain more challenging.
Models also differed in their deployment characteristics. The maximum usage of GPU memory for long EHR input ranged from approximately 15 GB to exceeding the available 160 GB memory limit. The inference latency varied similarly widely, from sub-second responses to several minutes per query. In clinical encounters in which multiple queries may be issued, response times measured in minutes may be incompatible with routine clinical workflows. These findings highlight that the selection of models for clinical deployment should consider not only predictive performance but also GPU memory requirements and inference latency. In particular, the Qwen3-30B model achieved accuracy comparable to the best 70B-parameter models while requiring substantially lower GPU memory and inference time.
Dataset and annotation
We assembled a retrospective dataset of 183 pseudonymised patient records from the Wellbeing Services County of Pirkanmaa, Finland. The cohort included individuals with current or prior breast cancer, suspected disease, or screening encounters without malignant findings. The cohort included patients with current and previous breast cancers, and records also contained information on other medical conditions and treatments. Data were extracted by the data-providing authority in accordance with data-minimization principles to include only clinical information relevant to breast cancer diagnosis, treatment, surveillance, and related investigations. The resulting dataset was delivered in pseudonymised form and analysed within a secure offline research environment. A detailed description of the data structure is provided in Supplementary Section A.
Patient records were represented as a standardized table of 26 predefined clinical fields (key–value pairs), where individual field values ranged from coded entries to extended narrative text spanning multiple pages. These included pseudonymised patient identifiers, temporal information on clinical events, coded clinical entries, and free-text narratives describing imaging, pathology, surgical procedures, systemic therapies, medications, and information of follow-ups. Documentation was primarily in Finnish, with occasional English and Latin medical terminology reflecting routine clinical practice. No translation or language normalization was applied. Patient-specific observation periods ranged from 2 to 62 years, with a median of 14 years. Record length ranged from 408 to 5,508 words, with a median of 1,792 words. This corresponded to 3,828 to 51,007 characters, with a median of 17,365 characters including spaces.
Each record was annotated using up to 21 predefined clinical question–answer pairs addressing breast cancer history, tumour characteristics, receptor status, laterality, nodal involvement, metastatic disease, and primary treatments. Responses were restricted to categorical labels or numeric values, with an “Unknown” category assigned when relevant information was absent or inconclusive. Questions not applicable to a given patient were omitted. For example, tumour-specific or treatment-related questions were not applied to patients without confirmed invasive breast cancer. Annotations were restricted to clinical events occurring in or after 2015 to establish a consistent temporal reference window across patients with potentially multiple cancer episodes. An exception was CQ1 (year of first breast cancer diagnosis), which required identification of the earliest documented breast cancer regardless of the year of the diagnosis. Clinical documentation predating 2015 was retained because accurate determination of post-2015 clinical variables often depended on prior diagnostic history, treatments, and longitudinal disease trajectories. The same temporal constraints were incorporated into the prompts provided to the models, ensuring alignment between annotation criteria and model instructions. Detailed definitions of all questions and response categories are provided in Supplementary Section B.
Annotations were performed by a medical oncologist with 6 years of specialization in breast cancer. To assess intra-annotator reliability, the annotator repeated the labelling process after a two-month interval while blinded to the initial annotations. Of the 1,927 question–answer instances annotated in both rounds, 1,685 (87.4%) were identical. Instances with discordant labels were excluded from further analysis.
From these high-confidence annotations, 21 instances (one per clinical question) were reserved for framework development and construction of a single one-shot demonstration example included in the prompt. These instances were not part of the evaluation dataset. The final evaluation dataset therefore comprised 1,664 question–answer pairs.
All records were pseudonymised by the data-providing authority prior to transfer. Direct identifiers were removed and replaced with study-specific pseudo-identifiers, and the linkage key enabling re-identification was retained exclusively by the data controller and was not accessible to the investigators. The dataset therefore constituted pseudonymised personal data under the General Data Protection Regulation (GDPR). Data processing and analysis were conducted within a secure, access-controlled offline environment compliant with GDPR requirements. Due to privacy constraints, neither the original identifiable records nor the pseudonymised clinical texts used in this study can be publicly released. Synthetic examples that preserve the structure and key characteristics of the dataset are provided in Supplementary Section A.
Experimental Setup
Experiments were conducted in a secure offline computing environment using an AMD EPYC 75F3 32-core CPU, 256 GB RAM, and two NVIDIA A100 GPUs with 80 GB VRAM each (160 GB total GPU memory). Models were executed using the Hugging Face Transformers framework, with low-bit quantization implemented via bitsandbytes where supported.
Prior to the main experiments, GPU memory profiling was performed to determine which models could be deployed within the available hardware constraints. Profiling was conducted in an open high-performance computing environment using higher-capacity hardware to characterize memory requirements across a wide range of input lengths. Synthetic input sequences of controlled length were used to measure peak memory consumption during a single forward decoding step, with sequence lengths ranging from minimal input to 25,120 tokens in increments of 512 tokens. Model inclusion in the main experiments was determined by feasibility within the 160 GB deployment budget. Profiling was performed without clinical data, and each model was evaluated in an isolated process to ensure accurate measurement. Additional details and full results are provided in Supplementary Section I.
For each evaluation instance, the complete patient record was provided to the model without prior filtering or retrieval. Records consisted of all predefined clinical fields formatted as a single text document by concatenating column names and their contents as key–value pairs separated by blank lines. Individual field values ranged from short coded entries to extended narrative text. Data were presented exactly as stored in the source records. The full prompt template is provided in Supplementary Section C.
Models were evaluated using a question format with predefined answer options included in the prompt to encourage use of the target terminology and to reduce scoring errors arising from lexical variation, synonyms, or language differences. Answer options were ordered alphabetically to avoid positional bias or unintended information leakage.
Inference was performed in bfloat16 precision for all models, except in dedicated analyses of low-precision deployment. Additional experiments using 8-bit and 4-bit quantization were conducted only for models compatible with the bitsandbytes library. To obtain deterministic outputs, stochastic decoding was disabled by setting temperature to zero and disabling sampling and beam search. Models were instructed to produce only the final answer without explanation, resulting in short responses typically consisting of a single word or numeric value. Maximum output length was limited to 25 tokens for standard instruction-tuned models to allow minor verbosity without truncating valid responses. Reasoning-oriented models that generate intermediate reasoning traces prior to the final response were allowed up to 1,000 tokens to ensure completion of the reasoning process, although only the final answer was used for evaluation.
GPU Memory Profiling
Prior to the main experiments, memory profiling was conducted in an open high-performance computing environment using hardware with greater capacity than the deployment system in order to characterize memory requirements across a wide range of input lengths. Profiling was performed on three NVIDIA H200 GPUs, whereas the main experiments were restricted to a secure offline environment equipped with two NVIDIA A100 GPUs (80 GB each), providing a total memory budget of 160 GB. The objective was to determine which models could process long input sequences within this deployment constraint and to estimate the maximum feasible context length for each architecture.
Sequence lengths ranged from 1 to 25,120 tokens. Lengths of 512 tokens and above were evaluated in increments of 512 tokens, with an additional single-token input included to capture the minimal context case. Figures 3–5 report memory usage for bfloat16 precision and for 8-bit and 4-bit quantized models, respectively. In each plot, the dashed horizontal line denotes the 160 GB memory budget applied in the main experiments.
Profiling was performed in a non-clinical environment without patient data, allowing unrestricted scaling of input length. Each model was profiled in a separate isolated Python process to ensure a clean memory state and to avoid cross-run memory retention. Within each model run, sequence lengths were evaluated sequentially from shortest to longest while tracking peak GPU memory usage after each inference step.


