--- license: llama3.2 base_model: - meta-llama/Llama-3.2-1B-Instruct language: - fr tags: - biomedical-entity-linking - entity-linking - entity-disambiguation - named-entity-linking - biomedical - healthcare - umls - quaero - emea - text-generation - constrained-decoding - causal-lm - llm library_name: transformers pipeline_tag: text-generation datasets: - AnonymousARR42/EMEA finetuning_task: - entity-linking metrics: - recall model-index: - name: LongBEL-1B-QUAERO-EMEA results: - task: type: entity-linking name: Biomedical Entity Linking dataset: type: AnonymousARR42/EMEA name: QUAERO-EMEA metrics: - type: recall name: Recall@1 value: 0.745 --- # 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 (QUAERO-EMEA Edition) This is a **finetuned version of LLaMA-3-1B** trained on **QUAERO-EMEA**, applying the LongBEL framework to enable long context and robust memory predictions. | Field | Value | |---|---| | Base model | `meta-llama/Llama-3.2-1B-Instruct` | | Task | Biomedical Entity Linking | | Dataset | QUAERO-EMEA | | Knowledge base | UMLS 2014AA | | 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_1B_QUAERO_EMEA", trust_remote_code=True, torch_dtype=torch.bfloat16, 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": [ "Une femme enceinte de 29 ans s'est présentée avec une hypertension sévère, " "des céphalées et une douleur épigastrique. Les analyses biologiques ont montré " "une protéinurie et une légère élévation des enzymes hépatiques. Elle a été " "hospitalisée pendant la nuit avec une suspicion de PET et un traitement urgent " "a été débuté." ], "offsets": [[0, 321]], } ], "entities": [ { "id": "T1", "type": "Living Beings", "text": ["femme enceinte"], "offsets": [[4, 18]], }, { "id": "T2", "type": "Disorders", "text": ["hypertension sévère"], "offsets": [[54, 73]], }, { "id": "T3", "type": "Disorders", "text": ["protéinurie"], "offsets": [[158, 169]], }, { "id": "T4", "type": "Disorders", "text": ["PET"], "offsets": [[280, 283]], }, ], "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: femme enceinte - Beam 1: Predicted concept name: Femmes enceintes Predicted code: C0033011 Beam score: 0.825 - Beam 2: Predicted concept name: Femmes qui travaillent Predicted code: C0043215 Beam score: 0.001 - Beam 3: Predicted concept name: Femmes en période de post-partum Predicted code: C0032804 Beam score: 0.000 - Beam 4: Predicted concept name: Femmes en péripartum Predicted code: C2936492 Beam score: 0.000 - Beam 5: Predicted concept name: Femme battue Predicted code: C0413330 Beam score: 0.000 ## Mention 2: hypertension sévère - Beam 1: Predicted concept name: Hypertension pulmonaire Predicted code: C0020542 Beam score: 0.016 - Beam 2: Predicted concept name: Hypertension aggravée Predicted code: C0235750 Beam score: 0.009 - Beam 3: Predicted concept name: Hypertension systolique Predicted code: C0221155 Beam score: 0.009 - Beam 4: Predicted concept name: Hypertension pulmonaire aggravée Predicted code: C0853930 Beam score: 0.008 - Beam 5: Predicted concept name: Hypertension du nouveau-né Predicted code: C0452204 Beam score: 0.005 ## Mention 3: protéinurie - Beam 1: Predicted concept name: Protéinurie Predicted code: C0033687 Beam score: 1.000 - Beam 2: Predicted concept name: Protéinurie - aggravée Predicted code: C0856146 Beam score: 0.004 - Beam 3: Predicted concept name: Protozoan infection (disorder) Predicted code: C0033740 Beam score: 0.003 - Beam 4: Predicted concept name: Protozoan infection Predicted code: C0033740 Beam score: 0.001 - Beam 5: Predicted concept name: Protozoal infection Predicted code: C0033740 Beam score: 0.000 ## Mention 4: PET - Beam 1: Predicted concept name: Petrol sniffing Predicted code: C1658398 Beam score: 0.000 - Beam 2: Predicted concept name: Petrol inhalation Predicted code: C1662227 Beam score: 0.000 - Beam 3: Predicted concept name: PET - Pre-eclamptic toxemia Predicted code: C0032914 Beam score: 0.000 - Beam 4: Predicted concept name: Petits reins bilatéraux Predicted code: C0156246 Beam score: 0.000 - Beam 5: Predicted concept name: PET - Pre-eclamptic toxaemia Predicted code: C0032914 Beam score: 0.000 ``` ### 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`: