MaziyarPanahi commited on
Commit
e40d97f
·
verified ·
1 Parent(s): 9fda47b

feat: Upload fine-tuned medical NER model OpenMed-NER-ProteinDetect-TinyMed-65M

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,259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ widget:
3
+ - text: "The Maillard reaction is responsible for the browning of many foods."
4
+ - text: "Casein micelles are the primary protein component of milk."
5
+ - text: "Starch gelatinization is a key process in cooking pasta and rice."
6
+ - text: "Polyphenols in green tea have antioxidant properties."
7
+ - text: "Omega-3 fatty acids are essential fats found in fish oil."
8
+ tags:
9
+ - token-classification
10
+ - named-entity-recognition
11
+ - biomedical-nlp
12
+ - transformers
13
+ - protein-interactions
14
+ - molecular-biology
15
+ - biochemistry
16
+ - systems-biology
17
+ - protein
18
+ - protein_complex
19
+ - protein_enum
20
+ - protein_familiy_or_group
21
+ - protein_variant
22
+ language:
23
+ - en
24
+ license: apache-2.0
25
+ ---
26
+
27
+ # 🧬 [OpenMed-NER-ProteinDetect-TinyMed-65M](https://huggingface.co/OpenMed/OpenMed-NER-ProteinDetect-TinyMed-65M)
28
+
29
+ **Specialized model for Biomedical Entity Recognition - Various biomedical entities**
30
+
31
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
32
+ [![Python](https://img.shields.io/badge/Python-3.8%2B-blue)]()
33
+ [![Transformers](https://img.shields.io/badge/🤗-Transformers-yellow)]()
34
+ [![OpenMed](https://img.shields.io/badge/🏥-OpenMed-green)](https://huggingface.co/OpenMed)
35
+
36
+ ## 📋 Model Overview
37
+
38
+ This model is a **state-of-the-art** fine-tuned transformer engineered to deliver **enterprise-grade accuracy** for biomedical entity recognition - various biomedical entities. 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.
39
+
40
+ ### 🎯 Key Features
41
+ - **High Precision**: Optimized for biomedical entity recognition
42
+ - **Domain-Specific**: Trained on curated FSU dataset
43
+ - **Production-Ready**: Validated on clinical benchmarks
44
+ - **Easy Integration**: Compatible with Hugging Face Transformers ecosystem
45
+
46
+ ### 🏷️ Supported Entity Types
47
+
48
+ This model can identify and classify the following biomedical entities:
49
+
50
+ - `B-protein`
51
+ - `B-protein_complex`
52
+ - `B-protein_enum`
53
+ - `B-protein_familiy_or_group`
54
+ - `B-protein_variant`
55
+
56
+ <details>
57
+ <summary>See 5 more entity types...</summary>
58
+
59
+ - `I-protein`
60
+ - `I-protein_complex`
61
+ - `I-protein_enum`
62
+ - `I-protein_familiy_or_group`
63
+ - `I-protein_variant`
64
+ </details>
65
+
66
+ ## 📊 Dataset
67
+
68
+ FSU corpus focuses on protein interactions and molecular biology entities for systems biology research.
69
+
70
+ The FSU (Florida State University) corpus is a biomedical NER dataset designed for protein interaction recognition and molecular biology entity extraction. This corpus contains annotations for proteins, protein complexes, protein families, protein variants, and molecular interaction entities relevant to systems biology and biochemistry research. The dataset supports the development of text mining systems for protein-protein interaction extraction, molecular pathway analysis, and systems biology applications. It is particularly valuable for identifying protein entities involved in cellular processes, signal transduction pathways, and molecular mechanisms. The corpus serves as a benchmark for evaluating NER systems used in proteomics research, drug discovery, and molecular biology informatics.
71
+
72
+
73
+ ## 📊 Performance Metrics
74
+
75
+ ### Current Model Performance
76
+ - **F1 Score**: `0.91`
77
+ - **Precision**: `0.91`
78
+ - **Recall**: `0.91`
79
+ - **Accuracy**: `0.97`
80
+
81
+ ### 🏆 Comparative Performance on FSU Dataset
82
+
83
+ | Rank | Model | F1 Score | Precision | Recall | Accuracy |
84
+ |------|-------|----------|-----------|--------|-----------|
85
+ | 🥇 1 | [OpenMed-NER-ProteinDetect-SnowMed-568M](https://huggingface.co/OpenMed/OpenMed-NER-ProteinDetect-SnowMed-568M) | **0.9609** | 0.9576 | 0.9642 | 0.9803 |
86
+ | 🥈 2 | [OpenMed-NER-ProteinDetect-ElectraMed-560M](https://huggingface.co/OpenMed/OpenMed-NER-ProteinDetect-ElectraMed-560M) | **0.9609** | 0.9581 | 0.9636 | 0.9802 |
87
+ | 🥉 3 | [OpenMed-NER-ProteinDetect-MultiMed-568M](https://huggingface.co/OpenMed/OpenMed-NER-ProteinDetect-MultiMed-568M) | **0.9579** | 0.9564 | 0.9595 | 0.9788 |
88
+ | 4 | [OpenMed-NER-ProteinDetect-BigMed-560M](https://huggingface.co/OpenMed/OpenMed-NER-ProteinDetect-BigMed-560M) | **0.9549** | 0.9520 | 0.9578 | 0.9778 |
89
+ | 5 | [OpenMed-NER-ProteinDetect-SuperMedical-355M](https://huggingface.co/OpenMed/OpenMed-NER-ProteinDetect-SuperMedical-355M) | **0.9547** | 0.9517 | 0.9576 | 0.9749 |
90
+ | 6 | [OpenMed-NER-ProteinDetect-EuroMed-212M](https://huggingface.co/OpenMed/OpenMed-NER-ProteinDetect-EuroMed-212M) | **0.9482** | 0.9482 | 0.9482 | 0.9770 |
91
+ | 7 | [OpenMed-NER-ProteinDetect-BigMed-278M](https://huggingface.co/OpenMed/OpenMed-NER-ProteinDetect-BigMed-278M) | **0.9466** | 0.9434 | 0.9499 | 0.9738 |
92
+ | 8 | [OpenMed-NER-ProteinDetect-SuperMedical-125M](https://huggingface.co/OpenMed/OpenMed-NER-ProteinDetect-SuperMedical-125M) | **0.9465** | 0.9423 | 0.9507 | 0.9714 |
93
+ | 9 | [OpenMed-NER-ProteinDetect-SuperClinical-434M](https://huggingface.co/OpenMed/OpenMed-NER-ProteinDetect-SuperClinical-434M) | **0.9412** | 0.9351 | 0.9474 | 0.9802 |
94
+ | 10 | [OpenMed-NER-ProteinDetect-TinyMed-82M](https://huggingface.co/OpenMed/OpenMed-NER-ProteinDetect-TinyMed-82M) | **0.9398** | 0.9331 | 0.9467 | 0.9680 |
95
+
96
+
97
+ *Rankings based on F1-score performance across all models trained on this dataset.*
98
+
99
+ ![OpenMed (open-source) vs. latest closed-source SOTA](https://huggingface.co/spaces/OpenMed/README/resolve/main/openmed_vs_sota_performance.png)
100
+
101
+ *Figure: OpenMed (Open-Source) vs. Latest SOTA (Closed-Source) performance comparison across biomedical NER datasets.*
102
+
103
+ ## 🚀 Quick Start
104
+
105
+ ### Installation
106
+
107
+ ```bash
108
+ pip install transformers torch
109
+ ```
110
+
111
+ ### Usage
112
+
113
+ ```python
114
+ from transformers import pipeline
115
+
116
+ # Load the model and tokenizer
117
+ # Model: https://huggingface.co/OpenMed/OpenMed-NER-ProteinDetect-TinyMed-65M
118
+ model_name = "OpenMed/OpenMed-NER-ProteinDetect-TinyMed-65M"
119
+
120
+ # Create a pipeline
121
+ medical_ner_pipeline = pipeline(
122
+ model=model_name,
123
+ aggregation_strategy="simple"
124
+ )
125
+
126
+ # Example usage
127
+ text = "The Maillard reaction is responsible for the browning of many foods."
128
+ entities = medical_ner_pipeline(text)
129
+
130
+ print(entities)
131
+
132
+ token = entities[0]
133
+ print(text[token["start"] : token["end"]])
134
+ ```
135
+
136
+ 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).
137
+
138
+ Here is a summary of the available strategies:
139
+ - **`none`**: Returns raw token predictions without any aggregation.
140
+ - **`simple`**: Groups adjacent tokens with the same entity type (e.g., `B-LOC` followed by `I-LOC`).
141
+ - **`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.
142
+ - **`average`**: For word-based models, this strategy averages the scores of tokens within a word and applies the label with the highest resulting score.
143
+ - **`max`**: For word-based models, the entity label from the token with the highest score within a word is assigned to the entire word.
144
+
145
+ ### Batch Processing
146
+
147
+ For efficient processing of large datasets, use proper batching with the `batch_size` parameter:
148
+
149
+ ```python
150
+ texts = [
151
+ "The Maillard reaction is responsible for the browning of many foods.",
152
+ "Casein micelles are the primary protein component of milk.",
153
+ "Starch gelatinization is a key process in cooking pasta and rice.",
154
+ "Polyphenols in green tea have antioxidant properties.",
155
+ "Omega-3 fatty acids are essential fats found in fish oil.",
156
+ ]
157
+
158
+ # Efficient batch processing with optimized batch size
159
+ # Adjust batch_size based on your GPU memory (typically 8, 16, 32, or 64)
160
+ results = medical_ner_pipeline(texts, batch_size=8)
161
+
162
+ for i, entities in enumerate(results):
163
+ print(f"Text {i+1} entities:")
164
+ for entity in entities:
165
+ print(f" - {entity['word']} ({entity['entity_group']}): {entity['score']:.4f}")
166
+ ```
167
+
168
+ ### Large Dataset Processing
169
+
170
+ For processing large datasets efficiently:
171
+
172
+ ```python
173
+ from transformers.pipelines.pt_utils import KeyDataset
174
+ from datasets import Dataset
175
+ import pandas as pd
176
+
177
+ # Load your data
178
+ # Load a medical dataset from Hugging Face
179
+ from datasets import load_dataset
180
+
181
+ # Load a public medical dataset (using a subset for testing)
182
+ medical_dataset = load_dataset("BI55/MedText", split="train[:100]") # Load first 100 examples
183
+ data = pd.DataFrame({"text": medical_dataset["Completion"]})
184
+ dataset = Dataset.from_pandas(data)
185
+
186
+ # Process with optimal batching for your hardware
187
+ batch_size = 16 # Tune this based on your GPU memory
188
+ results = []
189
+
190
+ for out in medical_ner_pipeline(KeyDataset(dataset, "text"), batch_size=batch_size):
191
+ results.extend(out)
192
+
193
+ print(f"Processed {len(results)} texts with batching")
194
+
195
+ ```
196
+
197
+ ### Performance Optimization
198
+
199
+ **Batch Size Guidelines:**
200
+ - **CPU**: Start with batch_size=1-4
201
+ - **Single GPU**: Try batch_size=8-32 depending on GPU memory
202
+ - **High-end GPU**: Can handle batch_size=64 or higher
203
+ - **Monitor GPU utilization** to find the optimal batch size for your hardware
204
+
205
+ **Memory Considerations:**
206
+ ```python
207
+ # For limited GPU memory, use smaller batches
208
+ medical_ner_pipeline = pipeline(
209
+ model=model_name,
210
+ aggregation_strategy="simple",
211
+ device=0 # Specify GPU device
212
+ )
213
+
214
+ # Process with memory-efficient batching
215
+ for batch_start in range(0, len(texts), batch_size):
216
+ batch = texts[batch_start:batch_start + batch_size]
217
+ batch_results = medical_ner_pipeline(batch, batch_size=len(batch))
218
+ results.extend(batch_results)
219
+ ```
220
+
221
+ ## 📚 Dataset Information
222
+
223
+ - **Dataset**: FSU
224
+ - **Description**: Biomedical Entity Recognition - Various biomedical entities
225
+
226
+ ### Training Details
227
+ - **Base Model**: distilbert-base-cased
228
+ - **Training Framework**: Hugging Face Transformers
229
+ - **Optimization**: AdamW optimizer with learning rate scheduling
230
+ - **Validation**: Cross-validation on held-out test set
231
+
232
+ ## 🔬 Model Architecture
233
+
234
+ - **Base Architecture**: distilbert-base-cased
235
+ - **Task**: Token Classification (Named Entity Recognition)
236
+ - **Labels**: Dataset-specific entity types
237
+ - **Input**: Tokenized biomedical text
238
+ - **Output**: BIO-tagged entity predictions
239
+
240
+ ## 💡 Use Cases
241
+
242
+ This model is particularly useful for:
243
+ - **Clinical Text Mining**: Extracting entities from medical records
244
+ - **Biomedical Research**: Processing scientific literature
245
+ - **Drug Discovery**: Identifying chemical compounds and drugs
246
+ - **Healthcare Analytics**: Analyzing patient data and outcomes
247
+ - **Academic Research**: Supporting biomedical NLP research
248
+
249
+ ## 📜 License
250
+
251
+ Licensed under the Apache License 2.0. See [LICENSE](https://www.apache.org/licenses/LICENSE-2.0) for details.
252
+
253
+ ## 🤝 Contributing
254
+
255
+ 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.
256
+
257
+ Follow [OpenMed Org](https://huggingface.co/OpenMed) on Hugging Face 🤗 and click "Watch" to stay updated on our latest releases and developments.
258
+
259
+
config.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "activation": "gelu",
3
+ "architectures": [
4
+ "DistilBertForTokenClassification"
5
+ ],
6
+ "attention_dropout": 0.1,
7
+ "dim": 768,
8
+ "dropout": 0.1,
9
+ "hidden_dim": 3072,
10
+ "id2label": {
11
+ "0": "B-protein",
12
+ "1": "B-protein_complex",
13
+ "2": "B-protein_enum",
14
+ "3": "B-protein_familiy_or_group",
15
+ "4": "B-protein_variant",
16
+ "5": "I-protein",
17
+ "6": "I-protein_complex",
18
+ "7": "I-protein_enum",
19
+ "8": "I-protein_familiy_or_group",
20
+ "9": "I-protein_variant",
21
+ "10": "O"
22
+ },
23
+ "initializer_range": 0.02,
24
+ "label2id": {
25
+ "B-protein": 0,
26
+ "B-protein_complex": 1,
27
+ "B-protein_enum": 2,
28
+ "B-protein_familiy_or_group": 3,
29
+ "B-protein_variant": 4,
30
+ "I-protein": 5,
31
+ "I-protein_complex": 6,
32
+ "I-protein_enum": 7,
33
+ "I-protein_familiy_or_group": 8,
34
+ "I-protein_variant": 9,
35
+ "O": 10
36
+ },
37
+ "max_position_embeddings": 512,
38
+ "model_type": "distilbert",
39
+ "n_heads": 12,
40
+ "n_layers": 6,
41
+ "output_past": true,
42
+ "pad_token_id": 0,
43
+ "qa_dropout": 0.1,
44
+ "seq_classif_dropout": 0.2,
45
+ "sinusoidal_pos_embds": false,
46
+ "tie_weights_": true,
47
+ "torch_dtype": "bfloat16",
48
+ "transformers_version": "4.53.2",
49
+ "vocab_size": 28996
50
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:80c1bd29a9c6289a9cbe248b02b1fd253ce76905f6d7c109d4210ae2546dc96d
3
+ size 130411078
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,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
test_results.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "eval_accuracy": 0.9704875933607169,
3
+ "eval_f1": 0.9096272763374369,
4
+ "eval_loss": 0.6000507473945618,
5
+ "eval_precision": 0.9051938276251411,
6
+ "eval_recall": 0.914104366994793
7
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "100": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "101": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "102": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "103": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": false,
45
+ "cls_token": "[CLS]",
46
+ "do_lower_case": false,
47
+ "extra_special_tokens": {},
48
+ "mask_token": "[MASK]",
49
+ "model_max_length": 512,
50
+ "pad_token": "[PAD]",
51
+ "sep_token": "[SEP]",
52
+ "strip_accents": null,
53
+ "tokenize_chinese_chars": true,
54
+ "tokenizer_class": "DistilBertTokenizer",
55
+ "unk_token": "[UNK]"
56
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff