from transformers import pipeline # Load the model and tokenizer # Model: https://huggingface.co/OpenMed/OpenMed-NER-GenomeDetect-BigMed-278M model_name = "OpenMed/OpenMed-NER-GenomeDetect-BigMed-278M" # Create a pipeline medical_ner_pipeline = pipeline( model=model_name, aggregation_strategy="simple" ) # Example usage text = "The EGFR gene mutation was identified in lung cancer patients." entities = medical_ner_pipeline(text) print(entities) token = entities[0] print(text[token["start"] : token["end"]])