-
Notifications
You must be signed in to change notification settings - Fork 12
Add project page: Qualitative Data Categorisation Improvements #362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| --- | ||
| title: 'Qualitative Data Categorisation Improvements' | ||
| summary: 'LLM-based multi-label text classifier for NHS patient experience comments, replacing a legacy ML model with a RAG-augmented approach requiring no model training' | ||
| origin: 'Insight and Voice' | ||
| tags: ['CLASSIFICATION', 'LARGE LANGUAGE MODELS (LLM)', 'MACHINE LEARNING', 'NATURAL LANGUAGE PROCESSING (NLP)', 'MODELLING', 'UNSTRUCTURED', 'TEXT DATA', 'PYTHON', 'IN DEVELOPMENT'] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is entirely the fault of my template, will change it, but would you change the tag for LLM to just say LLM?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and the NLP one to just say "Natural Language Processing" with no brackets |
||
| --- | ||
|
|
||
|  | ||
|
|
||
| Patient experience teams across the NHS collect thousands of free-text comments via the Friends and Family Test (FFT). These comments need categorising against 31 themes from the Qualitative Data Categorisation (QDC) Framework to identify patterns and drive service improvement. | ||
|
|
||
| This is a multi-label classification problem — a single comment can be assigned several categories simultaneously. For example, "The staff were great but I couldn't get parked" covers both "Staff manner" and "Parking". | ||
|
|
||
| The legacy approach used a trained sklearn/BERT ensemble that required manual retraining and achieved ~0.70 weighted F1. | ||
|
|
||
| We replaced this with an LLM-based classifier using Claude Sonnet via the NHS Federated Data Platform (FDP) API. The system uses retrieval-augmented few-shot prompting — for each comment being classified, it retrieves semantically similar examples from a corpus of 13,000 labelled comments and includes them as in-context calibration. Comments are processed in batches of 50 per API call for efficiency. This approach requires no model training, and making category changes is as simple as updating a prompt. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we've been told to not mention FDP in comms stuff so maybe remove this |
||
|
|
||
| Beyond classification, the LLM approach enables segmented sentiment highlighting — each comment is broken into its component clauses, with each segment assigned its own category and sentiment. This means "The staff were great but I couldn't get parked" produces two segments: "The staff were great" (Staff manner, Positive) and "I couldn't get parked" (Parking, Negative). This gives patient experience teams a much richer, more actionable view of feedback than flat category labels alone. | ||
|
|
||
| ## Results | ||
|
|
||
| The LLM approach achieves: | ||
|
|
||
| - **Macro F1: 0.776** (vs ~0.70 for the legacy model) | ||
| - **Weighted F1: 0.777** | ||
| - Multi-label classification across 31 categories with no training data pipeline | ||
| - Per-segment sentiment and evidence extraction | ||
|
|
||
| ## Outputs & Links | ||
|
|
||
| Output | Link | ||
| ---|--- | ||
| Open Source Code & Documentation (Currently Private) | [Link](https://github.com/nhsengland/QDC_LLM) | ||
| Technical Methodology (Currently Private) | [Link](https://github.com/nhsengland/QDC_LLM/blob/main/docs/methodology.md) | ||
| Original Framwork Documentation | [Link](https://github.com/The-Strategy-Unit/PatientExperience-QDC) | ||
|
|
||
| [comment]: <> (The below header stops the title from being rendered (as mkdocs adds it to the page from the "title" attribute) - this way we can add it in the main.html, along with the summary.) | ||
| # | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please add some alt text!