Case studies›Real-world data

Epilepsy-related real world data from neurologist letters using large language models

How King's College Hospital used local AI to read patient letters for disease registries

King’s College Hospital NHS Foundation Trust4 min read

Executive Summary

The problem

Improving treatment for people with epilepsy depends on understanding how patients respond to different medicines, and this is dependent on disease registries. Around 70% of people with epilepsy control their seizures with medication, but choosing the right medicine depends on details such as epilepsy and seizure type and personal preferences. However, disease registries contain limited information about patients because most information is held in clinic letters that would need a doctor or expert to read and extract.

What they did

At King’s College Hospital, researchers evaluated large language models (LLMs) and CogStack to ‘read’ clinic letters to build an automated registry and understand what makes some epilepsy resistant to medications. Doctors measured the results from reading by expert epileptologists and against AI fine-tuned for epilepsy. Unlike many AI projects, the LLMs used were all secure and safe and run completely from inside the NHS on hospital computers in a Trusted Research Environment.

The result

0.92F1 for current medications (experts: 0.95)
33 seconds vs 110 secondsTime per letter: best AI model vs expert review
A synthetic clinic letter with its diagnosis, current medication and symptoms highlighted, beside the structured data read from it: epilepsy type focal, seizure type focal, current anti-seizure medicines levetiracetam and lamotrigine, associated symptoms depression and headache.

The Challenge

Epilepsy treatment needs detailed information: which subtype of epilepsy, which seizures, how often they occur, which medicines and which side effects. The electronic record holds it, but mostly in prose.

  • Diagnosis Codes used by hospitals miss the detail. Diagnostic codes depend on coding versions and on admin staff bothering to map to the correct codes.
  • Rules don’t travel. Rule-based software extraction struggles with free text, and rules written for one hospital often fail at another.
  • Doctors and nurses lack the time to do this admin work. Doctors with relevant expertise lack the time to read hundreds of pages of records.
  • Privacy comes first. Clinic letters contain sensitive personal information, so AI services that send data over the internet were ruled out from the start.

The Solution

The team designed data pipelines that combine CogStack’s AI with openly available LLMs (from the Llama and Mistral families) were deployed on the hospital’s own GPU server, so no identifiable patient data left the NHS. King’s held more than 25,000 adult epilepsy records from 2013-2019. A subset of 280 randomly selected clinic letters were independently marked by two epileptologists. This marking by doctors showed high consistency for validity (Cohen’s kappa 0.84). Every result was checked against the epileptologists’ markings.

  • Ask the letter a question: direct extraction posed a clear question about each letter, such as which anti-seizure medicines the patient currently takes.
  • Try smarter prompts: the team also tested summarising the letter first, adding background on epilepsy classifications, giving the model a role such as “Expert Epilepsy Neurologist”, and showing it worked examples.
  • Output structured data: every answer was converted into a consistent, structured format ready for analysis.
  • Benchmark everything: five LLMs and six extraction methods were compared with expert annotations and with MedCAT.

Results & Impact

The best models came within a few points of the experts for epilepsy medications, epilepsy subtype, seizure type.

Simple beats the clever. Asking a direct question consistently worked well. Role prompts made little difference, and adding worked examples actually lowered performance.

Newer and bigger AI isn’t automatically better. The largest AI models at the time were frequently not the best, and often a mixed approach of small and large AI works best.

Some things are hard for humans too. For associated symptoms such as headache or depression, the best model was on par with the experts, who often missed these symptoms as well.

“What would have taken a resident doctor 3-4 years to fill an epilepsy registry now can be done in weeks or months”
James TeoProfessor of Neurology & Associate Medical Director, Kings College Hospital

What this means for real-world data

This study points to where clinical AI is heading. Locally run LLMs can now read clinic letters with near-expert accuracy and far faster than manual review. Paired with established clinical NLP, they can turn routine records into research-ready real-world data at scale. CogStack brings both into the hospital.

Read the full study: Fang S, Holgate B, Shek A, et al. Extracting epilepsy-related information from unstructured clinic letters using large language models. Epilepsia 2025;66:3369–3384. https://doi.org/10.1111/epi.18475

Topics
Clinical NLPData extractionEpilepsyLarge language modelsPhenotypingReal-world data
Find more like this
Validating Waiting Lists at Scale with Clinical NLP: 40,000+ Referrals Safely Closed
Guy’s and St Thomas’ NHS Foundation Trust
Flagging 9 in 10 unplanned intensive care admissions before elective neurosurgery at UCLH
University College London Hospitals NHS Foundation Trust
Mental Health Records Made Usable: Medication Reviews Cut from Hours to Minutes
South London and Maudsley NHS Foundation Trust

Next steps

Turn your clinic letters into real-world evidence

The same approach reaches well beyond epilepsy, into medication histories, symptom and side-effect tracking, disease subtyping, trial eligibility screening and real-world evidence generation. Whether you are a clinical team, a researcher or a life sciences partner, we can help you apply it to your own questions, securely and inside your own environment.