MaziyarPanahi commited on
Commit
f99eb93
·
verified ·
1 Parent(s): 0bc395a

feat: Upload fine-tuned medical NER model OpenMed-ZeroShot-NER-DNA-Small-166M

Browse files
README.md ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ widget:
3
+ - text: "The p53 protein plays a crucial role in tumor suppression."
4
+ - text: "Expression of BRCA1 gene was significantly upregulated in breast tissue."
5
+ - text: "The NF-kB pathway regulates inflammatory responses."
6
+ - text: "Activation of the STAT3 signaling pathway is observed in many cancers."
7
+ - text: "The experiment involved transfecting HeLa cells with a plasmid containing the target gene."
8
+ tags:
9
+ - token-classification
10
+ - entity recognition
11
+ - named-entity-recognition
12
+ - zero-shot
13
+ - zero-shot-ner
14
+ - zero shot
15
+ - biomedical-nlp
16
+ - gliner
17
+ - protein-recognition
18
+ - gene-recognition
19
+ - molecular-biology
20
+ - genomics
21
+ - protein
22
+ - dna
23
+ - rna
24
+ - cell_line
25
+ - cell_type
26
+ language:
27
+ - en
28
+ license: apache-2.0
29
+ ---
30
+
31
+ # 🧬 [OpenMed-ZeroShot-NER-DNA-Small-166M](https://huggingface.co/OpenMed/OpenMed-ZeroShot-NER-DNA-Small-166M)
32
+
33
+ **Specialized model for Biomedical Entity Recognition - Proteins, DNA, RNA, cell lines, and cell types**
34
+
35
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
36
+ [![Python](https://img.shields.io/badge/Python-3.11%2B-blue)]()
37
+ [![GliNER](https://img.shields.io/badge/🤗-GliNER-yellow)]()
38
+ [![OpenMed](https://img.shields.io/badge/🏥-OpenMed-green)](https://huggingface.co/OpenMed)
39
+
40
+ ## 📋 Model Overview
41
+
42
+ Targets **molecular biology entities**: proteins, DNA/RNA, cell lines, and cell types in biomedical research content.Great for **pathway curation**, **molecular interaction mining**, and **omics-aware information extraction**.
43
+
44
+ OpenMed ZeroShot NER is an advanced, domain-adapted Named Entity Recognition (NER) model designed specifically for medical, biomedical, and clinical text mining. Leveraging state-of-the-art zero-shot learning, this model empowers researchers, clinicians, and data scientists to extract expert-level biomedical entities—such as diseases, chemicals, genes, species, and clinical findings—directly from unstructured text, without the need for task-specific retraining.
45
+
46
+ Built on the robust GLiNER architecture and fine-tuned on curated biomedical corpora, OpenMed ZeroShot NER delivers high-precision entity recognition for critical healthcare and life sciences applications. Its zero-shot capability means you can flexibly define and extract any entity type relevant to your workflow, from standard biomedical categories to custom clinical concepts, supporting rapid adaptation to new research domains and regulatory requirements.
47
+
48
+ Whether you are working on clinical NLP, biomedical research, electronic health record (EHR) de-identification, or large-scale literature mining, OpenMed ZeroShot NER provides a production-ready, open-source solution that combines expert-level accuracy with unmatched flexibility. Join the OpenMed community to accelerate your medical text analytics with cutting-edge, zero-shot NER technology.
49
+
50
+ ### 🎯 Key Features
51
+ - **Zero-Shot Capability**: Can recognize any entity type without specific training
52
+ - **High Precision**: Optimized for biomedical entity recognition
53
+ - **Domain-Specific**: Fine-tuned on curated JNLPBA dataset
54
+ - **Production-Ready**: Validated on clinical benchmarks
55
+ - **Easy Integration**: Compatible with Hugging Face Transformers ecosystem
56
+ - **Flexible Entity Recognition**: Add custom entity types without retraining
57
+
58
+ ### 🏷️ Supported Entity Types
59
+
60
+ This zero-shot model can identify and classify biomedical entities, including but not limited to these entity types. **You can also add custom entity types without retraining the model**:
61
+
62
+ - `DNA`
63
+ - `RNA`
64
+ - `cell_line`
65
+ - `cell_tyle`
66
+ - `protein`
67
+
68
+ **💡 Zero-Shot Flexibility**: As a GliNER-based model, you can specify any entity types you want to detect, even if they weren't part of the original training. Simply provide the entity labels when using the model, and it will adapt to recognize them.
69
+
70
+ ## 📊 Dataset
71
+
72
+ JNLPBA corpus focuses on biomedical named entity recognition for protein, DNA, RNA, cell line, and cell type entities.
73
+
74
+ The JNLPBA (Joint Workshop on Natural Language Processing in Biomedicine and its Applications) corpus is a widely-used biomedical NER dataset derived from the GENIA corpus for the 2004 bio-entity recognition task. It contains annotations for five entity types: protein, DNA, RNA, cell line, and cell type, making it essential for molecular biology and genomics research applications. The corpus consists of MEDLINE abstracts annotated with biomedical entities relevant to gene and protein recognition tasks. It has been extensively used as a benchmark for evaluating biomedical NER systems and continues to be a standard evaluation dataset for developing machine learning models in computational biology and bioinformatics.
75
+
76
+
77
+ ## 📊 Performance Metrics
78
+
79
+ ### Current Model Performance
80
+
81
+ - **Finetuned F1 vs. Base Model (on test dataset excluded from training)**: `0.76`
82
+ - **F1 Improvement vs Base Model**: `20.5%`
83
+
84
+ ### 🏆 Top F1 Improvements on JNLPBA Dataset
85
+
86
+ | Rank | Model | Base F1 | Finetuned F1 | ΔF1 | ΔF1 % |
87
+ |------|-------|--------:|------------:|----:|------:|
88
+ | 🥇 1 | [OpenMed-ZeroShot-NER-DNA-Large-459M](https://huggingface.co/OpenMed/OpenMed-ZeroShot-NER-DNA-Large-459M) | 0.7006 | 0.8220 | 0.1214 | 17.3% |
89
+ | 🥈 2 | [OpenMed-ZeroShot-NER-DNA-Medium-209M](https://huggingface.co/OpenMed/OpenMed-ZeroShot-NER-DNA-Medium-209M) | 0.6928 | 0.8208 | 0.1280 | 18.5% |
90
+ | 🥉 3 | [OpenMed-ZeroShot-NER-DNA-XLarge-770M](https://huggingface.co/OpenMed/OpenMed-ZeroShot-NER-DNA-XLarge-770M) | 0.5271 | 0.8106 | 0.2835 | 53.8% |
91
+ | 4 | [OpenMed-ZeroShot-NER-DNA-Base-220M](https://huggingface.co/OpenMed/OpenMed-ZeroShot-NER-DNA-Base-220M) | 0.4896 | 0.7907 | 0.3011 | 61.5% |
92
+ | 5 | [OpenMed-ZeroShot-NER-DNA-Multi-209M](https://huggingface.co/OpenMed/OpenMed-ZeroShot-NER-DNA-Multi-209M) | 0.6660 | 0.7750 | 0.1090 | 16.4% |
93
+
94
+
95
+ *Rankings are sorted by finetuned F1 and show ΔF1% over base model. Test dataset is excluded from training.*
96
+
97
+ ![OpenMed ZeroShot Clinical & Biomedical NER vs. Original GLiNER models](https://huggingface.co/spaces/OpenMed/README/resolve/main/openmed-zero-shot-clinical-ner-finetuned.png)
98
+
99
+ *Figure: OpenMed ZeroShot Clinical & Biomedical NER vs. Original GLiNER models.*
100
+
101
+ ## 🚀 Quick Start
102
+
103
+ ### Installation
104
+
105
+ ```bash
106
+ pip install gliner==0.2.21
107
+ ```
108
+
109
+ ### Usage
110
+
111
+ ```python
112
+ from transformers import pipeline
113
+
114
+ # Load the model and tokenizer
115
+ # Model: https://huggingface.co/OpenMed/OpenMed-ZeroShot-NER-DNA-Small-166M
116
+ model_name = "OpenMed/OpenMed-ZeroShot-NER-DNA-Small-166M"
117
+
118
+ from gliner import GLiNER
119
+ model = GLiNER.from_pretrained("OpenMed-ZeroShot-NER-DNA-Small-166M")
120
+
121
+ # Example usage with default entity types
122
+ text = "The p53 protein plays a crucial role in tumor suppression."
123
+
124
+ labels = ['DNA', 'RNA', 'cell_line', 'cell_tyle', 'protein']
125
+ entities = model.predict_entities(text, labels, flat_ner=True, threshold=0.5)
126
+ for entity in entities:
127
+ print(entity)
128
+ ```
129
+
130
+ ### Zero-Shot Usage with Custom Entity Types
131
+ 💡 **Tip:** If you want to extract entities that are not present in the original training set (i.e., use custom or rare entity types), you may get better results by lowering the `threshold` parameter in `model.predict_entities`. For example, try `threshold=0.3` or even lower, depending on your use case:
132
+
133
+ ```python
134
+ # You can specify custom entity types for zero-shot recognition - for instance:
135
+ custom_entities = ["MISC", "DNA", "PERSON", "LOCATION", "MEDICATION", "PROCEDURE"]
136
+
137
+ entities = model.predict_entities(text, custom_entities, flat_ner=True, threshold=0.1)
138
+ for entity in entities:
139
+ print(entity)
140
+ ```
141
+
142
+ > Lowering the threshold makes the model more permissive and can help it recognize new or less common entity types, but may also increase false positives. Adjust as needed for your application.
143
+
144
+ ## 📚 Dataset Information
145
+
146
+ - **Dataset**: JNLPBA
147
+ - **Description**: Biomedical Entity Recognition - Proteins, DNA, RNA, cell lines, and cell types
148
+
149
+ ### Training Details
150
+ - **Base Model**: gliner_small-v2.1
151
+ - **Training Framework**: Hugging Face Transformers
152
+ - **Optimization**: AdamW optimizer with learning rate scheduling
153
+ - **Validation**: Cross-validation on held-out test set
154
+
155
+ ## 💡 Use Cases
156
+
157
+ This model is particularly useful for:
158
+ - **Clinical Text Mining**: Extracting entities from medical records
159
+ - **Biomedical Research**: Processing scientific literature
160
+ - **Drug Discovery**: Identifying chemical compounds and drugs
161
+ - **Healthcare Analytics**: Analyzing patient data and outcomes
162
+ - **Academic Research**: Supporting biomedical NLP research
163
+ - **Custom Entity Recognition**: Zero-shot detection of domain-specific entities
164
+
165
+ ## 🔬 Model Architecture
166
+
167
+ - **Task**: Zero-Shot Classification (Named Entity Recognition)
168
+ - **Labels**: Dataset-specific entity types
169
+ - **Input**: Biomedical text
170
+ - **Output**: Named entity predictions
171
+
172
+ ## 📜 License
173
+
174
+ Licensed under the Apache License 2.0. See [LICENSE](https://www.apache.org/licenses/LICENSE-2.0) for details.
175
+
176
+ ## 🤝 Contributing
177
+
178
+ I welcome contributions of all kinds! Whether you have ideas, feature requests, or want to join my mission to advance open-source Healthcare AI, I'd love to hear from you.
179
+
180
+ Follow [OpenMed Org](https://huggingface.co/OpenMed) on Hugging Face 🤗 and click "Watch" to stay updated on my latest releases and developments.
181
+
182
+ ## Citation
183
+
184
+ If you use this model in your research or applications, please cite the following paper:
185
+
186
+ ```latex
187
+ @misc{panahi2025openmedneropensourcedomainadapted,
188
+ title={OpenMed NER: Open-Source, Domain-Adapted State-of-the-Art Transformers for Biomedical NER Across 12 Public Datasets},
189
+ author={Maziyar Panahi},
190
+ year={2025},
191
+ eprint={2508.01630},
192
+ archivePrefix={arXiv},
193
+ primaryClass={cs.CL},
194
+ url={https://arxiv.org/abs/2508.01630},
195
+ }
196
+ ```
197
+
198
+ Proper citation helps support and acknowledge my work. Thank you!
199
+
added_tokens.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "<<ENT>>": 128002,
3
+ "<<SEP>>": 128003,
4
+ "[FLERT]": 128001,
5
+ "[MASK]": 128000
6
+ }
gliner_config.json ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "class_token_index": 128002,
3
+ "dropout": 0.4,
4
+ "embed_ent_token": true,
5
+ "encoder_config": {
6
+ "_name_or_path": "microsoft/deberta-v3-small",
7
+ "add_cross_attention": false,
8
+ "architectures": null,
9
+ "attention_probs_dropout_prob": 0.1,
10
+ "bad_words_ids": null,
11
+ "begin_suppress_tokens": null,
12
+ "bos_token_id": null,
13
+ "chunk_size_feed_forward": 0,
14
+ "cross_attention_hidden_size": null,
15
+ "decoder_start_token_id": null,
16
+ "diversity_penalty": 0.0,
17
+ "do_sample": false,
18
+ "early_stopping": false,
19
+ "encoder_no_repeat_ngram_size": 0,
20
+ "eos_token_id": null,
21
+ "exponential_decay_length_penalty": null,
22
+ "finetuning_task": null,
23
+ "forced_bos_token_id": null,
24
+ "forced_eos_token_id": null,
25
+ "hidden_act": "gelu",
26
+ "hidden_dropout_prob": 0.1,
27
+ "hidden_size": 768,
28
+ "id2label": {
29
+ "0": "LABEL_0",
30
+ "1": "LABEL_1"
31
+ },
32
+ "initializer_range": 0.02,
33
+ "intermediate_size": 3072,
34
+ "is_decoder": false,
35
+ "is_encoder_decoder": false,
36
+ "label2id": {
37
+ "LABEL_0": 0,
38
+ "LABEL_1": 1
39
+ },
40
+ "layer_norm_eps": 1e-07,
41
+ "legacy": true,
42
+ "length_penalty": 1.0,
43
+ "max_length": 20,
44
+ "max_position_embeddings": 512,
45
+ "max_relative_positions": -1,
46
+ "min_length": 0,
47
+ "model_type": "deberta-v2",
48
+ "no_repeat_ngram_size": 0,
49
+ "norm_rel_ebd": "layer_norm",
50
+ "num_attention_heads": 12,
51
+ "num_beam_groups": 1,
52
+ "num_beams": 1,
53
+ "num_hidden_layers": 6,
54
+ "num_return_sequences": 1,
55
+ "output_attentions": false,
56
+ "output_hidden_states": false,
57
+ "output_scores": false,
58
+ "pad_token_id": 0,
59
+ "pooler_dropout": 0,
60
+ "pooler_hidden_act": "gelu",
61
+ "pooler_hidden_size": 768,
62
+ "pos_att_type": [
63
+ "p2c",
64
+ "c2p"
65
+ ],
66
+ "position_biased_input": false,
67
+ "position_buckets": 256,
68
+ "prefix": null,
69
+ "problem_type": null,
70
+ "pruned_heads": {},
71
+ "relative_attention": true,
72
+ "remove_invalid_values": false,
73
+ "repetition_penalty": 1.0,
74
+ "return_dict": true,
75
+ "return_dict_in_generate": false,
76
+ "sep_token_id": null,
77
+ "share_att_key": true,
78
+ "suppress_tokens": null,
79
+ "task_specific_params": null,
80
+ "temperature": 1.0,
81
+ "tf_legacy_loss": false,
82
+ "tie_encoder_decoder": false,
83
+ "tie_word_embeddings": true,
84
+ "tokenizer_class": null,
85
+ "top_k": 50,
86
+ "top_p": 1.0,
87
+ "torch_dtype": null,
88
+ "torchscript": false,
89
+ "type_vocab_size": 0,
90
+ "typical_p": 1.0,
91
+ "use_bfloat16": false,
92
+ "vocab_size": 128004
93
+ },
94
+ "ent_token": "<<ENT>>",
95
+ "eval_every": 5000,
96
+ "fine_tune": true,
97
+ "fuse_layers": false,
98
+ "has_rnn": true,
99
+ "hidden_size": 512,
100
+ "labels_encoder": null,
101
+ "labels_encoder_config": null,
102
+ "lr_encoder": "1e-5",
103
+ "lr_others": "5e-5",
104
+ "max_len": 384,
105
+ "max_neg_type_ratio": 1,
106
+ "max_types": 25,
107
+ "max_width": 12,
108
+ "model_name": "microsoft/deberta-v3-small",
109
+ "model_type": "gliner",
110
+ "name": "correct",
111
+ "num_post_fusion_layers": 1,
112
+ "num_steps": 30000,
113
+ "post_fusion_schema": "",
114
+ "random_drop": true,
115
+ "sep_token": "<<SEP>>",
116
+ "shuffle_types": true,
117
+ "size_sup": -1,
118
+ "span_mode": "markerV0",
119
+ "subtoken_pooling": "first",
120
+ "train_batch_size": 8,
121
+ "transformers_version": "4.53.2",
122
+ "vocab_size": 128004,
123
+ "warmup_ratio": 3000,
124
+ "words_splitter_type": "whitespace"
125
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d7371dc78e0ee46cc72df4c28e6bd7b3874638eb7b546c0096e13e8696c5b565
3
+ size 610640455
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_loss": 527.4877319335938,
3
+ "seqeval_accuracy": 0.9269973878321308,
4
+ "seqeval_f1": 0.7575472683589262,
5
+ "seqeval_precision": 0.6917207172834796,
6
+ "seqeval_recall": 0.8372200415608404
7
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "128001": {
44
+ "content": "[FLERT]",
45
+ "lstrip": false,
46
+ "normalized": true,
47
+ "rstrip": false,
48
+ "single_word": false,
49
+ "special": false
50
+ },
51
+ "128002": {
52
+ "content": "<<ENT>>",
53
+ "lstrip": false,
54
+ "normalized": true,
55
+ "rstrip": false,
56
+ "single_word": false,
57
+ "special": false
58
+ },
59
+ "128003": {
60
+ "content": "<<SEP>>",
61
+ "lstrip": false,
62
+ "normalized": true,
63
+ "rstrip": false,
64
+ "single_word": false,
65
+ "special": false
66
+ }
67
+ },
68
+ "bos_token": "[CLS]",
69
+ "clean_up_tokenization_spaces": false,
70
+ "cls_token": "[CLS]",
71
+ "do_lower_case": false,
72
+ "eos_token": "[SEP]",
73
+ "extra_special_tokens": {},
74
+ "mask_token": "[MASK]",
75
+ "model_max_length": 1000000000000000019884624838656,
76
+ "pad_token": "[PAD]",
77
+ "sep_token": "[SEP]",
78
+ "sp_model_kwargs": {},
79
+ "split_by_punct": false,
80
+ "tokenizer_class": "DebertaV2Tokenizer",
81
+ "unk_token": "[UNK]",
82
+ "vocab_type": "spm"
83
+ }