MattStammers commited on
Commit
31a4b6a
·
verified ·
1 Parent(s): 1804c97

Upload folder using huggingface_hub

Browse files
Files changed (7) hide show
  1. README.md +163 -3
  2. config.json +28 -0
  3. merges.txt +0 -0
  4. model.safetensors +3 -0
  5. special_tokens_map.json +51 -0
  6. tokenizer_config.json +58 -0
  7. vocab.json +0 -0
README.md CHANGED
@@ -1,3 +1,163 @@
1
- ---
2
- license: cc-by-nc-4.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-nc-4.0
3
+ language:
4
+ - en
5
+ metrics:
6
+ - precision
7
+ - recall
8
+ - brier_score
9
+ - f1
10
+ - matthews_correlation
11
+ base_model:
12
+ - allenai/biomed_roberta_base
13
+ tags:
14
+ - IBD
15
+ - cohort_identification
16
+ - case_finding
17
+ ---
18
+ # Model Card for BioClinicalBERT IBD
19
+
20
+ The model classifies documents as either IBD or Not IBD
21
+
22
+ ## Model Details
23
+
24
+ ### Model Description
25
+
26
+ As above. This is a model trained to detect IBD patients from clinical text
27
+
28
+ - **Developed by:** Matt Stammers
29
+ - **Funded by:** University Hospital Foundation NHS Trust
30
+ - **Shared by:** Matt Stammers - SETT Data and AI Clinical Lead
31
+ - **Model type:** BERT Transformer (Finetuned)
32
+ - **Language(s) (NLP):** English
33
+ - **License:** cc-by-nc-4.0
34
+ - **Finetuned from model:** allenai/biomed_roberta_base
35
+
36
+ ### Model Sources
37
+
38
+ - **Repository:** https://huggingface.co/MattStammers/RoBERTa_IBD
39
+ - **Paper:** MedRxiv- [MedRxiv Paper](https://www.medrxiv.org/content/10.1101/2025.07.06.25330961v1)
40
+ - **Demo:** https://huggingface.co/spaces/MattStammers/IBD_Cohort_Identification
41
+ - **GitHub:** https://github.com/MattStammers/An_Open_Source_Collection_Of_IBD_Cohort_Identification_Models
42
+
43
+ ## Uses
44
+
45
+ For document classification tasks to differentiate between documents likely to be for patients with IBD and those not suggestive of IBD.
46
+
47
+ ### Direct Use
48
+
49
+ A similar model can be tested directly at [Cohort Identification Demo](https://huggingface.co/spaces/MattStammers/IBD_Cohort_Identification)
50
+
51
+ ### Downstream Use
52
+
53
+ Others are encouraged to build on this model and improve it but only for non-commercial purposes.
54
+
55
+ ### Out-of-Scope Use
56
+
57
+ 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.
58
+
59
+ ## Bias, Risks, and Limitations
60
+
61
+ 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).
62
+
63
+ ### Recommendations
64
+
65
+ It will likely work best in a predominantly caucasian/Western population.
66
+
67
+ ## How to Get Started with the Model
68
+
69
+ Use the code below to get started with the model.
70
+
71
+ The model is best used with the transformers library.
72
+
73
+ ## Training Details
74
+
75
+ ### Training Data
76
+
77
+ 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.
78
+
79
+ ### Training Procedure
80
+
81
+ See the paper for more information on the training procedure
82
+
83
+ #### Training Hyperparameters
84
+
85
+ - **Training regime:** fp32
86
+
87
+ #### Speeds, Sizes, Times
88
+
89
+ This model (part of a set of models) took 228.29 minutes to train
90
+
91
+ ## Evaluation
92
+
93
+ The model was internally validated against a holdout set - Type 2a validation according to TRIPOD.
94
+
95
+ ### Testing Data, Factors & Metrics
96
+
97
+ #### Testing Data
98
+
99
+ The testing data cannot be revealed due to IG regulations and to remain compliant with GDPR, only the resulting model can be
100
+
101
+ #### Factors
102
+
103
+ IBD vs Not-IBD
104
+
105
+ #### Metrics
106
+
107
+ Full evaluation metrics are available in the paper with a summary below
108
+
109
+ ### Results
110
+
111
+ | Model | Doc Coverage | Accuracy | Precision | Recall | Specificity | NPV | F1 Score | MCC |
112
+ |------------|------------------|----------------------------------|----------------------------------|----------------------------------|----------------------------------|----------------------------------|----------------------------------|----------------------------------|
113
+ | DistilBERT | 768 (100.00%) | 80.99% (CI: 77.26% - 84.24%) | 80.31% (CI: 76.39% - 83.71%) | 99.18% (CI: 97.62% - 99.72%) | 24.58% (CI: 17.69% - 33.06%) | 90.62% (CI: 75.78% - 96.76%) | 88.75% (CI: 87.68% - 89.88%) | 0.4105 (CI: 0.3136 - 0.4976) |
114
+
115
+ #### Summary
116
+
117
+ Overall performance of the model is high but it has so far only been validated internally.
118
+
119
+ ## Environmental Impact
120
+
121
+ Training the model used 2.13kWh of energy emmitting 441.75 grams of CO2
122
+
123
+ - **Hardware Type:** L40S
124
+ - **Hours used:** 2
125
+ - **Carbon Emitted:** 0.442 Kg CO2
126
+
127
+ ## Citation
128
+
129
+ 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.
130
+ MedRxiv- [MedRxiv Paper](https://www.medrxiv.org/content/10.1101/2025.07.06.25330961v1)
131
+
132
+ ## Glossary
133
+
134
+ | Term | Description |
135
+ |-------------------------------------|-------------|
136
+ | **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. |
137
+ | **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. |
138
+ | **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. |
139
+ | **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. |
140
+ | **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. |
141
+ | **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. |
142
+ | **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. |
143
+ | **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. |
144
+ | **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. |
145
+ | **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. |
146
+ | **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. |
147
+ | **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. |
148
+
149
+ ## Model Card Authors
150
+
151
+ Matt Stammers - Computational Gastroenterologist
152
+
153
+ ## Model Card Contact
154
+
155
156
+
157
+ ## Legal
158
+
159
+ 1. No guarantee is given of model performance in any production capacity whatsoever.
160
+ 2. These models should be used in full accordance with the EU AI Act - Regulation 2024/1689.
161
+ 3. These models are not CE marked medical devices and are suitable at this point only for research and development / experimentation at users own discretion.
162
+ 4. They can be improved but any improvements should be published openly and shared openly with the community.
163
+ 5. 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.
config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "allenai/biomed_roberta_base",
3
+ "architectures": [
4
+ "RobertaForSequenceClassification"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "bos_token_id": 0,
8
+ "classifier_dropout": null,
9
+ "eos_token_id": 2,
10
+ "hidden_act": "gelu",
11
+ "hidden_dropout_prob": 0.1,
12
+ "hidden_size": 768,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 3072,
15
+ "layer_norm_eps": 1e-05,
16
+ "max_position_embeddings": 514,
17
+ "model_type": "roberta",
18
+ "num_attention_heads": 12,
19
+ "num_hidden_layers": 12,
20
+ "pad_token_id": 1,
21
+ "position_embedding_type": "absolute",
22
+ "problem_type": "single_label_classification",
23
+ "torch_dtype": "float32",
24
+ "transformers_version": "4.49.0",
25
+ "type_vocab_size": 1,
26
+ "use_cache": true,
27
+ "vocab_size": 50265
28
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:236a352fc8890ca16296de196fbb8d94346a67f3131c9ee26c93936431728c9c
3
+ size 498612824
special_tokens_map.json ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": true,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "cls_token": {
10
+ "content": "<s>",
11
+ "lstrip": false,
12
+ "normalized": true,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "eos_token": {
17
+ "content": "</s>",
18
+ "lstrip": false,
19
+ "normalized": true,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "mask_token": {
24
+ "content": "<mask>",
25
+ "lstrip": true,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "pad_token": {
31
+ "content": "<pad>",
32
+ "lstrip": false,
33
+ "normalized": true,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ },
37
+ "sep_token": {
38
+ "content": "</s>",
39
+ "lstrip": false,
40
+ "normalized": true,
41
+ "rstrip": false,
42
+ "single_word": false
43
+ },
44
+ "unk_token": {
45
+ "content": "<unk>",
46
+ "lstrip": false,
47
+ "normalized": true,
48
+ "rstrip": false,
49
+ "single_word": false
50
+ }
51
+ }
tokenizer_config.json ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "<s>",
6
+ "lstrip": false,
7
+ "normalized": true,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": "<pad>",
14
+ "lstrip": false,
15
+ "normalized": true,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "2": {
21
+ "content": "</s>",
22
+ "lstrip": false,
23
+ "normalized": true,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "3": {
29
+ "content": "<unk>",
30
+ "lstrip": false,
31
+ "normalized": true,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "50264": {
37
+ "content": "<mask>",
38
+ "lstrip": true,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ }
44
+ },
45
+ "bos_token": "<s>",
46
+ "clean_up_tokenization_spaces": false,
47
+ "cls_token": "<s>",
48
+ "eos_token": "</s>",
49
+ "errors": "replace",
50
+ "extra_special_tokens": {},
51
+ "mask_token": "<mask>",
52
+ "max_len": 512,
53
+ "model_max_length": 512,
54
+ "pad_token": "<pad>",
55
+ "sep_token": "</s>",
56
+ "tokenizer_class": "RobertaTokenizer",
57
+ "unk_token": "<unk>"
58
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff