Views
No views yet
B-Amino_acidB-Anatomical_systemB-CancerB-CellB-Cellular_componentB-Developing_anatomical_structureB-Gene_or_gene_productB-Immaterial_anatomical_entityB-Multi-tissue_structureB-OrganB-OrganismB-Organism_subdivisionB-Organism_substanceB-Pathological_formationB-Simple_chemicalB-TissueI-Amino_acidI-Anatomical_systemI-CancerI-CellI-Cellular_componentI-Developing_anatomical_structureI-Gene_or_gene_productI-Immaterial_anatomical_entityI-Multi-tissue_structureI-OrganI-OrganismI-Organism_subdivisionI-Organism_substanceI-Pathological_formationI-Simple_chemicalI-Tissue0.860.860.860.95| Rank | Model | F1 Score | Precision | Recall | Accuracy |
|---|---|---|---|---|---|
| 🥇 1 | OpenMed-NER-OncologyDetect-SuperMedical-355M | 0.8990 | 0.8926 | 0.9056 | 0.9416 |
| 🥈 2 | OpenMed-NER-OncologyDetect-ElectraMed-560M | 0.8841 | 0.8788 | 0.8895 | 0.9390 |
| 🥉 3 | OpenMed-NER-OncologyDetect-SnowMed-568M | 0.8801 | 0.8774 | 0.8828 | 0.9366 |
| 4 | OpenMed-NER-OncologyDetect-PubMed-335M | 0.8782 | 0.8834 | 0.8730 | 0.9539 |
| 5 | OpenMed-NER-OncologyDetect-MultiMed-568M | 0.8766 | 0.8749 | 0.8784 | 0.9351 |
| 6 | OpenMed-NER-OncologyDetect-SuperClinical-434M | 0.8684 | 0.8602 | 0.8768 | 0.9495 |
| 7 | OpenMed-NER-OncologyDetect-BioMed-335M | 0.8660 | 0.8540 | 0.8783 | 0.9516 |
| 8 | OpenMed-NER-OncologyDetect-PubMed-109M | 0.8606 | 0.8604 | 0.8608 | 0.9503 |
| 9 | OpenMed-NER-OncologyDetect-BigMed-560M | 0.8556 | 0.8582 | 0.8530 | 0.9250 |
| 10 | OpenMed-NER-OncologyDetect-ModernClinical-395M | 0.8471 | 0.8465 | 0.8476 | 0.9411 |

pip install transformers torch1from transformers import pipeline
2
3# Load the model and tokenizer
4# Model: https://huggingface.co/OpenMed/OpenMed-NER-OncologyDetect-PubMed-109M
5model_name = "OpenMed/OpenMed-NER-OncologyDetect-PubMed-109M"
6
7# Create a pipeline
8medical_ner_pipeline = pipeline(
9 model=model_name,
10 aggregation_strategy="simple"
11)
12
13# Example usage
14text = "Mutations in KRAS gene drive oncogenic transformation."
15entities = medical_ner_pipeline(text)
16
17print(entities)
18
19token = entities[0]
20print(text[token["start"] : token["end"]])aggregation_strategy parameter defines how token predictions are grouped into entities. For a detailed explanation, please refer to the Hugging Face documentation.none: Returns raw token predictions without any aggregation.simple: Groups adjacent tokens with the same entity type (e.g., B-LOC followed by I-LOC).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.average: For word-based models, this strategy averages the scores of tokens within a word and applies the label with the highest resulting score.max: For word-based models, the entity label from the token with the highest score within a word is assigned to the entire word.batch_size parameter:1texts = [
2 "Mutations in KRAS gene drive oncogenic transformation.",
3 "The tumor suppressor p53 pathway was disrupted.",
4 "EGFR amplification promotes cancer cell proliferation.",
5 "Loss of function of the PTEN gene is common in many cancers.",
6 "The PI3K/AKT/mTOR pathway is a critical regulator of cell growth.",
7]
8
9# Efficient batch processing with optimized batch size
10# Adjust batch_size based on your GPU memory (typically 8, 16, 32, or 64)
11results = medical_ner_pipeline(texts, batch_size=8)
12
13for i, entities in enumerate(results):
14 print(f"Text {i+1} entities:")
15 for entity in entities:
16 print(f" - {entity['word']} ({entity['entity_group']}): {entity['score']:.4f}")1from transformers.pipelines.pt_utils import KeyDataset
2from datasets import Dataset
3import pandas as pd
4
5# Load your data
6# Load a medical dataset from Hugging Face
7from datasets import load_dataset
8
9# Load a public medical dataset (using a subset for testing)
10medical_dataset = load_dataset("BI55/MedText", split="train[:100]") # Load first 100 examples
11data = pd.DataFrame({"text": medical_dataset["Completion"]})
12dataset = Dataset.from_pandas(data)
13
14# Process with optimal batching for your hardware
15batch_size = 16 # Tune this based on your GPU memory
16results = []
17
18for out in medical_ner_pipeline(KeyDataset(dataset, "text"), batch_size=batch_size):
19 results.extend(out)
20
21print(f"Processed {len(results)} texts with batching")
221# For limited GPU memory, use smaller batches
2medical_ner_pipeline = pipeline(
3 model=model_name,
4 aggregation_strategy="simple",
5 device=0 # Specify GPU device
6)
7
8# Process with memory-efficient batching
9for batch_start in range(0, len(texts), batch_size):
10 batch = texts[batch_start:batch_start + batch_size]
11 batch_results = medical_ner_pipeline(batch, batch_size=len(batch))
12 results.extend(batch_results)1@misc{panahi2025openmedneropensourcedomainadapted,
2 title={OpenMed NER: Open-Source, Domain-Adapted State-of-the-Art Transformers for Biomedical NER Across 12 Public Datasets},
3 author={Maziyar Panahi},
4 year={2025},
5 eprint={2508.01630},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={https://arxiv.org/abs/2508.01630},
9}