Model Card for Distil_IBD_BERT
The model classifies documents as either IBD or Not IBD
Model Details
Model Description
As above. This is a model trained to detect IBD patients from clinical text
- Developed by: Matt Stammers
- Funded by: University Hospital Foundation NHS Trust
- Shared by: Matt Stammers - SETT Data and AI Clinical Lead
- Model type: BERT Transformer (Finetuned)
- Language(s) (NLP): English
- License: cc-by-nc-4.0
- Finetuned from model: distilbert/distilbert-base-uncased
Model Sources
- Repository: https://huggingface.co/MattStammers/Distil_IBD_BERT
- Paper: MedRxiv- MedRxiv Paper
- Demo: https://huggingface.co/spaces/MattStammers/IBD_Cohort_Identification
- GitHub: https://github.com/MattStammers/An_Open_Source_Collection_Of_IBD_Cohort_Identification_Models
Uses
For document classification tasks to differentiate between documents likely to be for patients with IBD and those not suggestive of IBD.
Direct Use
This model can be used directly at Cohort Identification Demo
Downstream Use
Others are encouraged to build on this model and improve it but only for non-commercial purposes.
Out-of-Scope Use
This model is less powerful (in terms of F1 Score) when making predictions at the patient level by 1-2%. It can be used for this purpose but with care. Its biggest weakness in terms of performance is specificity and it is very likely currently overfitted to the training data.
Bias, Risks, and Limitations
This model contains substantial biases and is known to be biased against non-white patients, women and the wealthy so use with care (see the paper for information on the training cohort).
Recommendations
It will likely work best in a predominantly caucasian/Western population.
How to Get Started with the Model
Use the code below to get started with the model.
The model is best used with the transformers library.
Training Details
Training Data
The model was trained on fully pseudonymised clinical information at UHSFT which was carefully labelled by a consultant (attending) physician and evaluated against a randomly selected internal holdout set. All non-IBD patients have now been removed.
Training Procedure
See the paper for more information on the training procedure
Training Hyperparameters
- Training regime: fp32
Speeds, Sizes, Times
This model (part of a set of models) took 119.71 minutes to train
Evaluation
The model was internally validated against a holdout set - Type 2a validation according to TRIPOD.
Testing Data, Factors & Metrics
Testing Data
The testing data cannot be revealed due to IG regulations and to remain compliant with GDPR, only the resulting model can be
Factors
IBD vs Not-IBD
Metrics
Full evaluation metrics are available in the paper with a summary below
Results
Model | Doc Coverage | Accuracy | Precision | Recall | Specificity | NPV | F1 Score | MCC |
---|---|---|---|---|---|---|---|---|
DistilBERT | 768 (100.00%) | 89.88% (CI: 86.87% - 92.26%) | 90.33% (CI: 87.01% - 92.87%) | 96.99% (CI: 94.70% - 98.31%) | 67.80% (CI: 58.92% - 75.55%) | 87.91% (CI: 79.64% - 93.11%) | 93.54% (CI: 92.07% - 95.07%) | 0.7120 (CI: 0.6324 - 0.7857) |
Summary
Overall performance of the model is high but it has so far only been validated internally.
Environmental Impact
Training the model used 1.11kWh of energy emmitting 230.09 grams of CO2
- Hardware Type: L40S
- Hours used: 2
- Carbon Emitted: 0.230.09 Kg CO2
Citation
Stammers M, Gwiggner M, Nouraei R, Metcalf C, Batchelor J. From Rule-Based to DeepSeek R1: A Robust Comparative Evaluation of Fifty Years of Natural Language Processing (NLP) Models To Identify Inflammatory Bowel Disease Cohorts. medRxiv. 2025:2025-07. MedRxiv- MedRxiv Paper
Glossary
Term | Description |
---|---|
Accuracy | The percentage of results that were correct among all results from the system overall. Calc: ((TP+TN))/((TP+FP+TN+FN)). Very susceptible to class imbalance. |
Precision (PPV) | Also called positive predictive value (PPV), it is the percentage of true positive results among all results that the system flagged as positive. Calc: TP/((TP+FP)). A measure of the trustworthiness of positive results. |
Negative Predictive Value (NPV) | The percentage of results that were true negatives (TN) among all results that the system flagged as negative. Calc: TN/((TN+FN)). A measure of the trustworthiness of negative results. |
Recall | Also called sensitivity. The percentage of results flagged positive among all results that should have been obtained. Calc: TP/((TP+FN)). 100% recall means there are no false negative results – useful in confidently screening out negative cases. |
Specificity | The percentage of results that were flagged negative among all negative results. Calc: TN/((TN+FP)). 100% specificity means there are no false-positive results and rules in the disease. |
F1-Score | In this case, the unweighted harmonic mean of PPV/precision and sensitivity/recall. Calc: (2 × (Precision × Recall))/((Precision + Recall)). More resistant to the effects of class imbalance. |
Matthews’ Correlation Coefficient (MCC) | A statistical measure used to evaluate the quality of binary classifications. Unlike other metrics, MCC considers all four categories of a confusion matrix. Calc: ((TP×TN) − (FP×FN))/√((TP+FP)(TP+FN)(TN+FP)(TN+FN)). The results are more abstract but highly resistant to the effects of class imbalance, which is why they are included in this study. |
Precision / Recall AUC | Represents the area under the Precision-Recall curve, which plots Precision against Recall at various threshold settings. It is more resistant to class imbalance than AUROC (area under the receiver operator curve). Both were used in testing, but the confusion matrix components form the primary outcomes for this study because they are more human-interpretable and harder to statistically manipulate. |
Demographic Parity (DP) | Demographic Parity, also known as Statistical Parity, requires that the probability of a positive prediction is the same across different demographic groups. Calc: DP = P(Ŷ=1∣A=a) = P(Ŷ=1∣A=b), where Ŷ is the predicted outcome and A represents the protected attribute (e.g., race, gender). This figure is given as an absolute difference where positive values suggest the more privileged group gains and negative values the reverse. The rule of 10% is used here to look for significant biases. |
Equal Opportunity (EO) | Equal Opportunity focuses on equalising the true positive rates across groups. Among those who truly belong to the positive class, the model should predict positive outcomes at equal rates across different groups. Calc: EO = P(Ŷ=1∣Y=1, A=a) = P(Ŷ=1∣Y=1, A=b), where Ŷ is the predicted outcome and Y is the actual outcome. If there is no bias, then the value will be equal for all groups. A higher value indicates a bias against the group considered more vulnerable. The rule of 10% is used here to look for significant biases. |
Disparate Impact (DI) | Divides the protected group’s positive prediction rate by that of the most-favoured group. If the ratio is below 0.8 or above 1.25, disparate impact is considered present. Calc: DI = P(Ŷ=1∣A=unfavoured) / P(Ŷ=1∣A=favoured). Values outside the 0.8–1.25 range suggest bias. |
Time / Energy / CO₂ Emissions | Measured in minutes and total energy consumption in kilowatt-hours (kWh), which can then be extrapolated to CO₂ emissions via a conversion factor set at 0.20705 Kg CO₂e per kWh for this study. |
Model Card Authors
Matt Stammers - Computational Gastroenterologist
Model Card Contact
Legal
- No guarantee is given of model performance in any production capacity whatsoever.
- These models should be used in full accordance with the EU AI Act - Regulation 2024/1689.
- These models are not CE marked medical devices and are suitable at this point only for research and development / experimentation at users own discretion.
- They can be improved but any improvements should be published openly and shared openly with the community.
- UHSFT and the author own the copyright and are choosing to share them freely under a CC BY-NC 4.0 Licence for the benefit of the wider research community but not for commercial organisations who are breaking copyright law and infringing upon NHS intellectual property if they try to sell/market these models for profit.
- Downloads last month
- 17
Model tree for MattStammers/Distil_IBD_BERT
Base model
distilbert/distilbert-base-uncased