--- license: llama3.1 base_model: - meta-llama/Llama-3.1-8B-Instruct language: - en tags: - biomedical-entity-linking - entity-linking - entity-disambiguation - named-entity-linking - biomedical - healthcare - umls - medmentions - text-generation - constrained-decoding - causal-lm - llm library_name: transformers pipeline_tag: text-generation datasets: - AnonymousARR42/MedMentions finetuning_task: - entity-linking metrics: - recall model-index: - name: LongBEL-8B-MedMentions-ST21pv results: - task: type: entity-linking name: Biomedical Entity Linking dataset: type: AnonymousARR42/MedMentions name: MedMentions-ST21pv metrics: - type: recall name: Recall@1 value: 0.793 --- # LongBEL: Long-Context and Document-Consistent Biomedical Entity Linking ## LongBEL **LongBEL** is a novel document-level framework for biomedical entity linking (BEL). Instead of normalizing each mention independently, LongBEL conditions each prediction on the document context and on previous normalizations produced in the same document. This design enforces document-level consistency and is enhanced by our **robust memory** mechanism. The method is introduced in our paper, currently under review. ## LongBEL (MedMentions Edition) This is a **finetuned version of LLaMA-3-8B** trained on **MedMentions**, applying the LongBEL framework to enable long context and robust memory predictions. | Field | Value | |---|---| | Base model | `meta-llama/Llama-3.1-8B-Instruct` | | Task | Biomedical Entity Linking | | Dataset | MedMentions-ST21pv | | Knowledge base | UMLS 2017AA, ST21pv subset | | Input | BigBio-like documents with mention spans and semantic groups | | Output | Ranked UMLS concept predictions | | Decoding | Semantic-guided constrained decoding | | Main metric | Recall@1 | ## Intended Use This model is intended for research on biomedical entity linking and document-level consistency. It assumes that mention spans and semantic groups are already provided. It does **not** perform named entity recognition. In a full pipeline, a NER model should first detect mentions and assign semantic groups, then LongBEL can normalize these mentions to UMLS concepts. ## Usage ### Loading the model ```python import torch from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained( "AnonymousARR42/LongBEL_8B_MedMentions_st21pv", trust_remote_code=True, device_map="auto", ) ```` ### Inference example The model expects BigBio-like documents. Each entity should include a mention text, character offsets, and a semantic group in the `type` field. ```python num_beams = 5 bigbio_pages = [ { "id": "001", "document_id": "doc_001", "passages": [ { "id": "0", "type": "paragraph", "text": [ "A 29-year-old pregnant woman presented with severe-range hypertension, " "headache, and epigastric pain. Laboratory testing showed proteinuria " "and mildly elevated liver enzymes. She was admitted overnight with " "suspected PET and was started on urgent treatment." ], "offsets": [[0, 257]], } ], "entities": [ { "id": "T1", "type": "Living Beings", "text": ["pregnant woman"], "offsets": [[14, 28]], }, { "id": "T2", "type": "Disorders", "text": ["severe-range hypertension"], "offsets": [[44, 69]], }, { "id": "T3", "type": "Disorders", "text": ["proteinuria"], "offsets": [[128, 139]], }, { "id": "T4", "type": "Disorders", "text": ["PET"], "offsets": [[217, 220]], }, ], "events": [], "coreferences": [], "relations": [], } ] predictions = model.sample( bigbio_pages=bigbio_pages, num_beams=num_beams, ) for i in range(0, len(predictions), num_beams): mention = predictions[i]["mention"] print(f"## Mention {(i // num_beams) + 1}: {mention}") for j in range(num_beams): pred = predictions[i + j] print( f" - Beam {j + 1}:\n" f" Predicted concept name: {pred['pred_concept_name']}\n" f" Predicted code: {pred['pred_concept_code']}\n" f" Beam score: {pred['beam_score']:.3f}\n" ) ``` **Example Output:** ```text ## Mention 1: pregnant woman - Beam 1: - Predicted concept name:Pregnant Woman - Predicted code: C0033011 - Beam score: 1.000 - Beam 2: - Predicted concept name:Pregnant woman - Predicted code: C0033011 - Beam score: 0.003 - Beam 3: - Predicted concept name:Pregnant woman (person) - Predicted code: C0033011 - Beam score: 0.001 - Beam 4: - Predicted concept name:Pregnancy Partner - Predicted code: C3538996 - Beam score: 0.000 - Beam 5: - Predicted concept name:Pregnant woman (person) - Predicted code: C0033011 - Beam score: 0.000 ## Mention 2: severe-range hypertension - Beam 1: - Predicted concept name:Hypertensive disease - Predicted code: C0020538 - Beam score: 0.078 - Beam 2: - Predicted concept name:Hypertension (in some patients) - Predicted code: C3280936 - Beam score: 0.022 - Beam 3: - Predicted concept name:Hypertensive disease (disorder) - Predicted code: C0020538 - Beam score: 0.010 - Beam 4: - Predicted concept name:Hypertension, severe - Predicted code: C4013784 - Beam score: 0.010 - Beam 5: - Predicted concept name:Hypertension (patient A) - Predicted code: C4313262 - Beam score: 0.004 ## Mention 3: proteinuria - Beam 1: - Predicted concept name:Proteinurias - Predicted code: C0033687 - Beam score: 1.000 - Beam 2: - Predicted concept name:Proteinuric diabetic nephropathy (disorder) - Predicted code: C0403519 - Beam score: 0.003 - Beam 3: - Predicted concept name:Proteinuria - Predicted code: C0033687 - Beam score: 0.003 - Beam 4: - Predicted concept name:Proteinuric diabetic nephropathy - Predicted code: C0403519 - Beam score: 0.002 - Beam 5: - Predicted concept name:Proteinuric hypertension of pregnancy (disorder) - Predicted code: C0032914 - Beam score: 0.001 ## Mention 4: PET - Beam 1: - Predicted concept name:PET - Pre-eclamptic toxemia - Predicted code: C0032914 - Beam score: 0.075 - Beam 2: - Predicted concept name:PET - Pre-eclamptic toxaemia - Predicted code: C0032914 - Beam score: 0.039 - Beam 3: - Predicted concept name:Preeclamptic toxemia - Predicted code: C2931877 - Beam score: 0.027 - Beam 4: - Predicted concept name:Preeclampsia - Predicted code: C0032914 - Beam score: 0.023 - Beam 5: - Predicted concept name:Preeclampsia with Severe Features - Predicted code: C0341950 - Beam score: 0.019 ``` ### Saliency map example The model can also return token-level saliency maps during inference. ```python predictions, saliency_maps = model.sample( bigbio_pages=bigbio_pages, num_beams=num_beams, with_saliency_maps=True, ) model.display_saliency_map(saliency_maps[3]) ```` Example saliency map for the mention `PET`: