MaziyarPanahi commited on
Commit
0281f88
·
verified ·
1 Parent(s): c1d4fd6

feat: Upload fine-tuned medical NER model OpenMed-NER-DiseaseDetect-SuperClinical-184M

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ openmed_vs_sota_grouped_bars.png filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ widget:
3
+ - text: "The patient was diagnosed with diabetes mellitus type 2."
4
+ - text: "Symptoms of Alzheimer's disease became apparent over several months."
5
+ - text: "Treatment for hypertension was initiated immediately."
6
+ - text: "A possible link between Crohn's disease and gut microbiota is being investigated."
7
+ - text: "The patient has a family history of cystic fibrosis."
8
+ tags:
9
+ - token-classification
10
+ - named-entity-recognition
11
+ - biomedical-nlp
12
+ - transformers
13
+ - disease-entity-recognition
14
+ - medical-diagnosis
15
+ - pathology
16
+ - biocuration
17
+ - disease
18
+ language:
19
+ - en
20
+ license: apache-2.0
21
+ ---
22
+
23
+ # 🧬 [OpenMed-NER-DiseaseDetect-SuperClinical-184M](https://huggingface.co/OpenMed/OpenMed-NER-DiseaseDetect-SuperClinical-184M)
24
+
25
+ **Specialized model for Disease Entity Recognition - Disease entities from the BC5CDR dataset**
26
+
27
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
28
+ [![Python](https://img.shields.io/badge/Python-3.8%2B-blue)]()
29
+ [![Transformers](https://img.shields.io/badge/🤗-Transformers-yellow)]()
30
+ [![OpenMed](https://img.shields.io/badge/🏥-OpenMed-green)](https://huggingface.co/OpenMed)
31
+
32
+ ## 📋 Model Overview
33
+
34
+ This model is a **state-of-the-art** fine-tuned transformer engineered to deliver **enterprise-grade accuracy** for disease entity recognition - disease entities from the bc5cdr dataset. This specialized model excels at identifying and extracting biomedical entities from clinical texts, research papers, and healthcare documents, enabling applications such as **drug interaction detection**, **medication extraction from patient records**, **adverse event monitoring**, **literature mining for drug discovery**, and **biomedical knowledge graph construction** with **production-ready reliability** for clinical and research applications.
35
+
36
+ ### 🎯 Key Features
37
+ - **High Precision**: Optimized for biomedical entity recognition
38
+ - **Domain-Specific**: Trained on curated BC5CDR_DISEASE dataset
39
+ - **Production-Ready**: Validated on clinical benchmarks
40
+ - **Easy Integration**: Compatible with Hugging Face Transformers ecosystem
41
+
42
+ ### 🏷️ Supported Entity Types
43
+
44
+ This model can identify and classify the following biomedical entities:
45
+
46
+ - `B-DISEASE`
47
+ - `I-DISEASE`
48
+
49
+ ## 📊 Dataset
50
+
51
+ BC5CDR-Disease targets disease entity recognition from the BioCreative V Chemical-Disease Relation extraction corpus.
52
+
53
+ The BC5CDR-Disease corpus is the disease-focused component of the BioCreative V Chemical-Disease Relation (CDR) task, containing 1,500 PubMed abstracts with 5,818 annotated disease entities. This manually curated dataset is designed to advance automated disease name recognition for medical diagnosis, pathology research, and clinical decision support systems. The corpus includes annotations for various disease types, medical conditions, and pathological states mentioned in biomedical literature. It serves as a benchmark for evaluating NER models in clinical and biomedical applications where accurate disease entity identification is crucial for medical informatics and healthcare analytics.
54
+
55
+
56
+ ## 📊 Performance Metrics
57
+
58
+ ### Current Model Performance
59
+ - **F1 Score**: `0.89`
60
+ - **Precision**: `0.87`
61
+ - **Recall**: `0.92`
62
+ - **Accuracy**: `0.98`
63
+
64
+ ### 🏆 Comparative Performance on BC5CDR_DISEASE Dataset
65
+
66
+ | Rank | Model | F1 Score | Precision | Recall | Accuracy |
67
+ |------|-------|----------|-----------|--------|-----------|
68
+ | 🥇 1 | [OpenMed-NER-DiseaseDetect-SuperClinical-434M](https://huggingface.co/OpenMed/OpenMed-NER-DiseaseDetect-SuperClinical-434M) | **0.9118** | 0.9028 | 0.9211 | 0.9839 |
69
+ | 🥈 2 | [OpenMed-NER-DiseaseDetect-PubMed-335M](https://huggingface.co/OpenMed/OpenMed-NER-DiseaseDetect-PubMed-335M) | **0.9097** | 0.8932 | 0.9268 | 0.9849 |
70
+ | 🥉 3 | [OpenMed-NER-DiseaseDetect-MultiMed-335M](https://huggingface.co/OpenMed/OpenMed-NER-DiseaseDetect-MultiMed-335M) | **0.9022** | 0.8890 | 0.9159 | 0.9758 |
71
+ | 4 | [OpenMed-NER-DiseaseDetect-BioMed-335M](https://huggingface.co/OpenMed/OpenMed-NER-DiseaseDetect-BioMed-335M) | **0.9005** | 0.8887 | 0.9126 | 0.9838 |
72
+ | 5 | [OpenMed-NER-DiseaseDetect-BioClinical-108M](https://huggingface.co/OpenMed/OpenMed-NER-DiseaseDetect-BioClinical-108M) | **0.8999** | 0.8862 | 0.9140 | 0.9723 |
73
+ | 6 | [OpenMed-NER-DiseaseDetect-PubMed-109M](https://huggingface.co/OpenMed/OpenMed-NER-DiseaseDetect-PubMed-109M) | **0.8994** | 0.8899 | 0.9091 | 0.9839 |
74
+ | 7 | [OpenMed-NER-DiseaseDetect-BioPatient-108M](https://huggingface.co/OpenMed/OpenMed-NER-DiseaseDetect-BioPatient-108M) | **0.8991** | 0.8864 | 0.9121 | 0.9721 |
75
+ | 8 | [OpenMed-NER-DiseaseDetect-SuperClinical-184M](https://huggingface.co/OpenMed/OpenMed-NER-DiseaseDetect-SuperClinical-184M) | **0.8943** | 0.8687 | 0.9214 | 0.9812 |
76
+ | 9 | [OpenMed-NER-DiseaseDetect-SuperClinical-141M](https://huggingface.co/OpenMed/OpenMed-NER-DiseaseDetect-SuperClinical-141M) | **0.8921** | 0.8686 | 0.9170 | 0.9809 |
77
+ | 10 | [OpenMed-NER-DiseaseDetect-MultiMed-568M](https://huggingface.co/OpenMed/OpenMed-NER-DiseaseDetect-MultiMed-568M) | **0.8909** | 0.8803 | 0.9017 | 0.9776 |
78
+
79
+
80
+ *Rankings based on F1-score performance across all models trained on this dataset.*
81
+
82
+ ![OpenMed (open-source) vs. latest closed-source SOTA](https://huggingface.co/spaces/OpenMed/README/resolve/main/openmed_vs_sota_performance.png)
83
+
84
+ *Figure: OpenMed (Open-Source) vs. Latest SOTA (Closed-Source) performance comparison across biomedical NER datasets.*
85
+
86
+ ## 🚀 Quick Start
87
+
88
+ ### Installation
89
+
90
+ ```bash
91
+ pip install transformers torch
92
+ ```
93
+
94
+ ### Usage
95
+
96
+ ```python
97
+ from transformers import pipeline
98
+
99
+ # Load the model and tokenizer
100
+ # Model: https://huggingface.co/OpenMed/OpenMed-NER-DiseaseDetect-SuperClinical-184M
101
+ model_name = "OpenMed/OpenMed-NER-DiseaseDetect-SuperClinical-184M"
102
+
103
+ # Create a pipeline
104
+ medical_ner_pipeline = pipeline(
105
+ model=model_name,
106
+ aggregation_strategy="simple"
107
+ )
108
+
109
+ # Example usage
110
+ text = "The patient was diagnosed with diabetes mellitus type 2."
111
+ entities = medical_ner_pipeline(text)
112
+
113
+ print(entities)
114
+
115
+ token = entities[0]
116
+ print(text[token["start"] : token["end"]])
117
+ ```
118
+
119
+ NOTE: The `aggregation_strategy` parameter defines how token predictions are grouped into entities. For a detailed explanation, please refer to the [Hugging Face documentation](https://huggingface.co/docs/transformers/en/main_classes/pipelines#transformers.TokenClassificationPipeline.aggregation_strategy).
120
+
121
+ Here is a summary of the available strategies:
122
+ - **`none`**: Returns raw token predictions without any aggregation.
123
+ - **`simple`**: Groups adjacent tokens with the same entity type (e.g., `B-LOC` followed by `I-LOC`).
124
+ - **`first`**: For word-based models, if tokens within a word have different entity tags, the tag of the first token is assigned to the entire word.
125
+ - **`average`**: For word-based models, this strategy averages the scores of tokens within a word and applies the label with the highest resulting score.
126
+ - **`max`**: For word-based models, the entity label from the token with the highest score within a word is assigned to the entire word.
127
+
128
+ ### Batch Processing
129
+
130
+ For efficient processing of large datasets, use proper batching with the `batch_size` parameter:
131
+
132
+ ```python
133
+ texts = [
134
+ "The patient was diagnosed with diabetes mellitus type 2.",
135
+ "Symptoms of Alzheimer's disease became apparent over several months.",
136
+ "Treatment for hypertension was initiated immediately.",
137
+ "A possible link between Crohn's disease and gut microbiota is being investigated.",
138
+ "The patient has a family history of cystic fibrosis.",
139
+ ]
140
+
141
+ # Efficient batch processing with optimized batch size
142
+ # Adjust batch_size based on your GPU memory (typically 8, 16, 32, or 64)
143
+ results = medical_ner_pipeline(texts, batch_size=8)
144
+
145
+ for i, entities in enumerate(results):
146
+ print(f"Text {i+1} entities:")
147
+ for entity in entities:
148
+ print(f" - {entity['word']} ({entity['entity_group']}): {entity['score']:.4f}")
149
+ ```
150
+
151
+ ### Large Dataset Processing
152
+
153
+ For processing large datasets efficiently:
154
+
155
+ ```python
156
+ from transformers.pipelines.pt_utils import KeyDataset
157
+ from datasets import Dataset
158
+ import pandas as pd
159
+
160
+ # Load your data
161
+ # Load a medical dataset from Hugging Face
162
+ from datasets import load_dataset
163
+
164
+ # Load a public medical dataset (using a subset for testing)
165
+ medical_dataset = load_dataset("BI55/MedText", split="train[:100]") # Load first 100 examples
166
+ data = pd.DataFrame({"text": medical_dataset["Completion"]})
167
+ dataset = Dataset.from_pandas(data)
168
+
169
+ # Process with optimal batching for your hardware
170
+ batch_size = 16 # Tune this based on your GPU memory
171
+ results = []
172
+
173
+ for out in medical_ner_pipeline(KeyDataset(dataset, "text"), batch_size=batch_size):
174
+ results.extend(out)
175
+
176
+ print(f"Processed {len(results)} texts with batching")
177
+
178
+ ```
179
+
180
+ ### Performance Optimization
181
+
182
+ **Batch Size Guidelines:**
183
+ - **CPU**: Start with batch_size=1-4
184
+ - **Single GPU**: Try batch_size=8-32 depending on GPU memory
185
+ - **High-end GPU**: Can handle batch_size=64 or higher
186
+ - **Monitor GPU utilization** to find the optimal batch size for your hardware
187
+
188
+ **Memory Considerations:**
189
+ ```python
190
+ # For limited GPU memory, use smaller batches
191
+ medical_ner_pipeline = pipeline(
192
+ model=model_name,
193
+ aggregation_strategy="simple",
194
+ device=0 # Specify GPU device
195
+ )
196
+
197
+ # Process with memory-efficient batching
198
+ for batch_start in range(0, len(texts), batch_size):
199
+ batch = texts[batch_start:batch_start + batch_size]
200
+ batch_results = medical_ner_pipeline(batch, batch_size=len(batch))
201
+ results.extend(batch_results)
202
+ ```
203
+
204
+ ## 📚 Dataset Information
205
+
206
+ - **Dataset**: BC5CDR_DISEASE
207
+ - **Description**: Disease Entity Recognition - Disease entities from the BC5CDR dataset
208
+
209
+ ### Training Details
210
+ - **Base Model**: deberta-v3-base
211
+ - **Training Framework**: Hugging Face Transformers
212
+ - **Optimization**: AdamW optimizer with learning rate scheduling
213
+ - **Validation**: Cross-validation on held-out test set
214
+
215
+ ## 🔬 Model Architecture
216
+
217
+ - **Base Architecture**: deberta-v3-base
218
+ - **Task**: Token Classification (Named Entity Recognition)
219
+ - **Labels**: Dataset-specific entity types
220
+ - **Input**: Tokenized biomedical text
221
+ - **Output**: BIO-tagged entity predictions
222
+
223
+ ## 💡 Use Cases
224
+
225
+ This model is particularly useful for:
226
+ - **Clinical Text Mining**: Extracting entities from medical records
227
+ - **Biomedical Research**: Processing scientific literature
228
+ - **Drug Discovery**: Identifying chemical compounds and drugs
229
+ - **Healthcare Analytics**: Analyzing patient data and outcomes
230
+ - **Academic Research**: Supporting biomedical NLP research
231
+
232
+ ## 📜 License
233
+
234
+ Licensed under the Apache License 2.0. See [LICENSE](https://www.apache.org/licenses/LICENSE-2.0) for details.
235
+
236
+ ## 🤝 Contributing
237
+
238
+ We welcome contributions of all kinds! Whether you have ideas, feature requests, or want to join our mission to advance open-source Healthcare AI, we'd love to hear from you.
239
+
240
+ Follow [OpenMed Org](https://huggingface.co/OpenMed) on Hugging Face 🤗 and click "Watch" to stay updated on our latest releases and developments.
241
+
242
+
added_tokens.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "[MASK]": 128000
3
+ }
config.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "DebertaV2ForTokenClassification"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.2,
6
+ "hidden_act": "gelu",
7
+ "hidden_dropout_prob": 0.2,
8
+ "hidden_size": 768,
9
+ "id2label": {
10
+ "0": "O",
11
+ "1": "B-DISEASE",
12
+ "2": "I-DISEASE"
13
+ },
14
+ "initializer_range": 0.02,
15
+ "intermediate_size": 3072,
16
+ "label2id": {
17
+ "B-DISEASE": 1,
18
+ "I-DISEASE": 2,
19
+ "O": 0
20
+ },
21
+ "layer_norm_eps": 1e-07,
22
+ "legacy": true,
23
+ "max_position_embeddings": 512,
24
+ "max_relative_positions": -1,
25
+ "model_type": "deberta-v2",
26
+ "norm_rel_ebd": "layer_norm",
27
+ "num_attention_heads": 12,
28
+ "num_hidden_layers": 12,
29
+ "pad_token_id": 0,
30
+ "pooler_dropout": 0,
31
+ "pooler_hidden_act": "gelu",
32
+ "pooler_hidden_size": 768,
33
+ "pos_att_type": [
34
+ "p2c",
35
+ "c2p"
36
+ ],
37
+ "position_biased_input": false,
38
+ "position_buckets": 256,
39
+ "relative_attention": true,
40
+ "share_att_key": true,
41
+ "torch_dtype": "bfloat16",
42
+ "transformers_version": "4.53.2",
43
+ "type_vocab_size": 0,
44
+ "vocab_size": 128100
45
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a35dfc4030f67b6e6745938a75e0b6853ba5adec64494be6c14d9e748b300eba
3
+ size 367692286
openmed_vs_sota_grouped_bars.png ADDED

Git LFS Details

  • SHA256: 626b37d9b20c44e26c92a8b5bf774107393ae0ad0b482d8e7cb3dc31d960f611
  • Pointer size: 131 Bytes
  • Size of remote file: 497 kB
special_tokens_map.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "[CLS]",
3
+ "cls_token": "[CLS]",
4
+ "eos_token": "[SEP]",
5
+ "mask_token": "[MASK]",
6
+ "pad_token": "[PAD]",
7
+ "sep_token": "[SEP]",
8
+ "unk_token": {
9
+ "content": "[UNK]",
10
+ "lstrip": false,
11
+ "normalized": true,
12
+ "rstrip": false,
13
+ "single_word": false
14
+ }
15
+ }
spm.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c679fbf93643d19aab7ee10c0b99e460bdbc02fedf34b92b05af343b4af586fd
3
+ size 2464616
test_results.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "eval_accuracy": 0.9811835106382979,
3
+ "eval_f1": 0.8942794528829442,
4
+ "eval_loss": 0.3396190106868744,
5
+ "eval_precision": 0.8687417413008369,
6
+ "eval_recall": 0.9213640610401744
7
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "[CLS]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "[SEP]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "[UNK]",
29
+ "lstrip": false,
30
+ "normalized": true,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "128000": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "bos_token": "[CLS]",
45
+ "clean_up_tokenization_spaces": false,
46
+ "cls_token": "[CLS]",
47
+ "do_lower_case": false,
48
+ "eos_token": "[SEP]",
49
+ "extra_special_tokens": {},
50
+ "mask_token": "[MASK]",
51
+ "model_max_length": 1000000000000000019884624838656,
52
+ "pad_token": "[PAD]",
53
+ "sep_token": "[SEP]",
54
+ "sp_model_kwargs": {},
55
+ "split_by_punct": false,
56
+ "tokenizer_class": "DebertaV2Tokenizer",
57
+ "unk_token": "[UNK]",
58
+ "vocab_type": "spm"
59
+ }