MaziyarPanahi commited on
Commit
d02cbde
·
verified ·
1 Parent(s): 42fa698

feat: Upload fine-tuned medical NER model OpenMed-NER-OrganismDetect-ElectraMed-560M

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ 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
37
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ widget:
3
+ - text: "Caenorhabditis elegans is a model organism for genetic studies."
4
+ - text: "The research focused on Drosophila melanogaster development."
5
+ - text: "Arabidopsis thaliana serves as a model for plant biology."
6
+ - text: "The zebrafish, Danio rerio, is widely used for studying vertebrate development."
7
+ - text: "Neurospora crassa is a type of red bread mold used in genetic research."
8
+ tags:
9
+ - token-classification
10
+ - named-entity-recognition
11
+ - biomedical-nlp
12
+ - transformers
13
+ - species-recognition
14
+ - taxonomy
15
+ - organism-identification
16
+ - biodiversity
17
+ - species
18
+ language:
19
+ - en
20
+ license: apache-2.0
21
+ ---
22
+
23
+ # 🧬 [OpenMed-NER-OrganismDetect-ElectraMed-560M](https://huggingface.co/OpenMed/OpenMed-NER-OrganismDetect-ElectraMed-560M)
24
+
25
+ **Specialized model for Species Entity Recognition - Species names from the Species-800 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 species entity recognition - species names from the species-800 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 SPECIES800 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-SPECIES`
47
+ - `I-SPECIES`
48
+
49
+ ## 📊 Dataset
50
+
51
+ Species800 is a corpus for species recognition and taxonomy classification in biomedical texts.
52
+
53
+ The Species800 corpus is a manually annotated dataset designed for species recognition and taxonomic classification in biomedical literature. This corpus contains 800 abstracts with comprehensive annotations for organism mentions, supporting biodiversity informatics and biological taxonomy research. The dataset includes both scientific names and common names of species, making it valuable for developing NER systems that can handle the complexity of biological nomenclature. It serves as a benchmark for evaluating species identification models used in ecological studies, conservation biology, and systematic biology research. The corpus is particularly useful for text mining applications in biodiversity databases and biological literature analysis.
54
+
55
+
56
+ ## 📊 Performance Metrics
57
+
58
+ ### Current Model Performance
59
+ - **F1 Score**: `0.80`
60
+ - **Precision**: `0.77`
61
+ - **Recall**: `0.83`
62
+ - **Accuracy**: `0.97`
63
+
64
+ ### 🏆 Comparative Performance on SPECIES800 Dataset
65
+
66
+ | Rank | Model | F1 Score | Precision | Recall | Accuracy |
67
+ |------|-------|----------|-----------|--------|-----------|
68
+ | 🥇 1 | [OpenMed-NER-OrganismDetect-BioMed-335M](https://huggingface.co/OpenMed/OpenMed-NER-OrganismDetect-BioMed-335M) | **0.8639** | 0.8557 | 0.8722 | 0.9715 |
69
+ | 🥈 2 | [OpenMed-NER-OrganismDetect-PubMed-335M](https://huggingface.co/OpenMed/OpenMed-NER-OrganismDetect-PubMed-335M) | **0.8550** | 0.8370 | 0.8737 | 0.9698 |
70
+ | 🥉 3 | [OpenMed-NER-OrganismDetect-PubMed-109M](https://huggingface.co/OpenMed/OpenMed-NER-OrganismDetect-PubMed-109M) | **0.8458** | 0.8287 | 0.8637 | 0.9690 |
71
+ | 4 | [OpenMed-NER-OrganismDetect-MultiMed-335M](https://huggingface.co/OpenMed/OpenMed-NER-OrganismDetect-MultiMed-335M) | **0.8441** | 0.8352 | 0.8532 | 0.9670 |
72
+ | 5 | [OpenMed-NER-OrganismDetect-SuperClinical-434M](https://huggingface.co/OpenMed/OpenMed-NER-OrganismDetect-SuperClinical-434M) | **0.8435** | 0.8291 | 0.8585 | 0.9670 |
73
+ | 6 | [OpenMed-NER-OrganismDetect-PubMed-109M](https://huggingface.co/OpenMed/OpenMed-NER-OrganismDetect-PubMed-109M) | **0.8349** | 0.8082 | 0.8634 | 0.9685 |
74
+ | 7 | [OpenMed-NER-OrganismDetect-MultiMed-568M](https://huggingface.co/OpenMed/OpenMed-NER-OrganismDetect-MultiMed-568M) | **0.8313** | 0.8053 | 0.8592 | 0.9703 |
75
+ | 8 | [OpenMed-NER-OrganismDetect-ElectraMed-335M](https://huggingface.co/OpenMed/OpenMed-NER-OrganismDetect-ElectraMed-335M) | **0.8288** | 0.8176 | 0.8404 | 0.9631 |
76
+ | 9 | [OpenMed-NER-OrganismDetect-BioPatient-108M](https://huggingface.co/OpenMed/OpenMed-NER-OrganismDetect-BioPatient-108M) | **0.8154** | 0.8140 | 0.8169 | 0.9591 |
77
+ | 10 | [OpenMed-NER-OrganismDetect-ElectraMed-33M](https://huggingface.co/OpenMed/OpenMed-NER-OrganismDetect-ElectraMed-33M) | **0.8121** | 0.7772 | 0.8503 | 0.9600 |
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-OrganismDetect-ElectraMed-560M
101
+ model_name = "OpenMed/OpenMed-NER-OrganismDetect-ElectraMed-560M"
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 = "Caenorhabditis elegans is a model organism for genetic studies."
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
+ "Caenorhabditis elegans is a model organism for genetic studies.",
135
+ "The research focused on Drosophila melanogaster development.",
136
+ "Arabidopsis thaliana serves as a model for plant biology.",
137
+ "The zebrafish, Danio rerio, is widely used for studying vertebrate development.",
138
+ "Neurospora crassa is a type of red bread mold used in genetic research.",
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**: SPECIES800
207
+ - **Description**: Species Entity Recognition - Species names from the Species-800 dataset
208
+
209
+ ### Training Details
210
+ - **Base Model**: multilingual-e5-large-instruct
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**: multilingual-e5-large-instruct
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
+
config.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "XLMRobertaForTokenClassification"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.2,
6
+ "bos_token_id": 0,
7
+ "classifier_dropout": 0.2,
8
+ "eos_token_id": 2,
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.2,
11
+ "hidden_size": 1024,
12
+ "id2label": {
13
+ "0": "O",
14
+ "1": "B-SPECIES",
15
+ "2": "I-SPECIES"
16
+ },
17
+ "initializer_range": 0.02,
18
+ "intermediate_size": 4096,
19
+ "label2id": {
20
+ "B-SPECIES": 1,
21
+ "I-SPECIES": 2,
22
+ "O": 0
23
+ },
24
+ "layer_norm_eps": 1e-07,
25
+ "max_position_embeddings": 514,
26
+ "model_type": "xlm-roberta",
27
+ "num_attention_heads": 16,
28
+ "num_hidden_layers": 24,
29
+ "output_past": true,
30
+ "pad_token_id": 1,
31
+ "position_embedding_type": "absolute",
32
+ "torch_dtype": "bfloat16",
33
+ "transformers_version": "4.53.2",
34
+ "type_vocab_size": 1,
35
+ "use_cache": true,
36
+ "vocab_size": 250002
37
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2c27f573bb287856628e359c718f04f968958dc87b6d97c9b36e18f73ae35838
3
+ size 1117736094
openmed_vs_sota_grouped_bars.png ADDED

Git LFS Details

  • SHA256: 626b37d9b20c44e26c92a8b5bf774107393ae0ad0b482d8e7cb3dc31d960f611
  • Pointer size: 131 Bytes
  • Size of remote file: 497 kB
sentencepiece.bpe.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cfc8146abe2a0488e9e2a0c56de7952f7c11ab059eca145a0a727afce0db2865
3
+ size 5069051
special_tokens_map.json ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "cls_token": {
10
+ "content": "<s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "eos_token": {
17
+ "content": "</s>",
18
+ "lstrip": false,
19
+ "normalized": false,
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": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ },
37
+ "sep_token": {
38
+ "content": "</s>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false
43
+ },
44
+ "unk_token": {
45
+ "content": "<unk>",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false
50
+ }
51
+ }
test_results.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "eval_accuracy": 0.965210982126405,
3
+ "eval_f1": 0.8001101321585903,
4
+ "eval_loss": 0.3848467469215393,
5
+ "eval_precision": 0.7708222811671087,
6
+ "eval_recall": 0.8317115054378935
7
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3ffb37461c391f096759f4a9bbbc329da0f36952f88bab061fcf84940c022e98
3
+ size 17082999
tokenizer_config.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "<s>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "<pad>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "</s>",
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": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "250001": {
36
+ "content": "<mask>",
37
+ "lstrip": true,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "additional_special_tokens": [],
45
+ "bos_token": "<s>",
46
+ "clean_up_tokenization_spaces": true,
47
+ "cls_token": "<s>",
48
+ "eos_token": "</s>",
49
+ "extra_special_tokens": {},
50
+ "mask_token": "<mask>",
51
+ "model_max_length": 512,
52
+ "pad_token": "<pad>",
53
+ "sep_token": "</s>",
54
+ "tokenizer_class": "XLMRobertaTokenizer",
55
+ "unk_token": "<unk>"
56
+ }