File size: 11,226 Bytes
8dac99d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8928877
8dac99d
 
 
 
 
 
 
 
 
aee4a29
8dac99d
 
 
 
 
 
 
 
 
 
 
 
 
 
aee4a29
8dac99d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aee4a29
 
 
 
 
8dac99d
aee4a29
8dac99d
 
 
 
 
 
aee4a29
 
8dac99d
 
 
 
aee4a29
 
8dac99d
 
 
 
aee4a29
 
8dac99d
 
 
 
 
aee4a29
8dac99d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8928877
8dac99d
8928877
 
 
8dac99d
 
8928877
 
 
8dac99d
 
8928877
 
 
8dac99d
 
8928877
 
 
8dac99d
 
8928877
 
 
8dac99d
8928877
8dac99d
8928877
 
 
8dac99d
 
8928877
 
 
8dac99d
 
8928877
 
 
8dac99d
 
8928877
 
 
8dac99d
 
8928877
 
 
8dac99d
8928877
8dac99d
8928877
 
 
8dac99d
 
8928877
 
 
8dac99d
 
8928877
 
 
8dac99d
 
8928877
 
 
8dac99d
 
8928877
 
 
8dac99d
 
 
8928877
 
 
8dac99d
 
8928877
 
 
8dac99d
 
8928877
 
 
8dac99d
 
8928877
 
 
8dac99d
 
8928877
 
 
8dac99d
 
8928877
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8dac99d
 
8928877
8dac99d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8928877
8dac99d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8928877
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
---
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`:

<p align="center">
  <img src="saliency_map.png" alt="Saliency map for PET prediction" width="900">
</p>

## Evaluation

Entity linking performance is reported using Recall@1 with bootstrap confidence intervals. The best result is shown in **bold**, and the second-best result is <u>underlined</u> ⭐ marks the main LongBEL-1B model.

| Model | MM-ST21PV<br>(English) | QUAERO-EMEA<br>(French) | SympTEMIST<br>(Spanish) | DisTEMIST<br>(Spanish) | MedProcNER<br>(Spanish) |
| :--- | :---: | :---: | :---: | :---: | :---: |
| **Context-Free BEL** ||||| |
| SciSpacy | 53.8 ± 1.0 | 37.1 ± 4.3 | 9.8 ± 1.3 | 21.1 ± 1.9 | 10.3 ± 1.2 |
| SapBERT | 65.6 ± 1.0 | 59.7 ± 3.8 | 34.2 ± 2.0 | 38.6 ± 2.6 | 30.4 ± 2.1 |
| CODER-all | 62.9 ± 1.1 | 66.9 ± 4.0 | 42.2 ± 2.2 | 47.0 ± 2.6 | 42.7 ± 2.1 |
| SapBERT-all | 64.6 ± 1.1 | 67.9 ± 3.9 | 49.8 ± 2.4 | 49.6 ± 2.6 | 45.1 ± 2.2 |
| BERGAMOT | 60.9 ± 1.1 | 63.8 ± 4.9 | 48.0 ± 2.7 | 48.9 ± 2.4 | 42.3 ± 2.2 |
| **Local-Context BEL** ||||| |
| ArboEL | 76.9 ± 0.9 | 63.0 ± 3.9 | 55.4 ± 2.5 | 54.7 ± 2.6 | 59.7 ± 2.6 |
| GENRE / mBART-large | 69.6 ± 1.0 | 69.3 ± 5.4 | 59.8 ± 2.7 | 58.7 ± 2.7 | 66.0 ± 2.3 |
| GENRE / Llama-1B | 73.1 ± 1.0 | 75.1 ± 3.6 | 60.5 ± 2.4 | 62.5 ± 2.3 | 67.4 ± 2.1 |
| GENRE / Llama-8B | 75.0 ± 0.9 | 73.8 ± 4.0 | 61.7 ± 2.5 | 63.2 ± 2.5 | 68.3 ± 2.2 |
| **Global-Context BEL: LongBEL** ||||| |
| **⭐ LongBEL-1B** | 77.6 ± 0.9 | 74.5 ± 3.7 | 59.8 ± 2.5 | 61.9 ± 2.4 | 66.6 ± 2.1 |
| LongBEL-1B + Ensemble | 78.6 ± 0.8 | <u>77.2 ± 3.0</u> | 61.8 ± 2.5 | <u>64.3 ± 2.2</u> | <u>69.0 ± 2.0</u> |
| LongBEL-8B | <u>79.3 ± 0.8</u> | 75.4 ± 3.4 | <u>62.0 ± 2.6</u> | 63.6 ± 2.1 | <u>69.0 ± 2.1</u> |
| LongBEL-8B + Ensemble | **80.0 ± 0.8** | **77.6 ± 3.0** | **63.3 ± 2.5** | **65.8 ± 2.2** | **71.0 ± 2.0** |

The score reported for this checkpoint is the **single LongBEL-1B model**. The ensemble result requires fusing several LongBEL input configurations and is not produced by this checkpoint alone.

## Speed and Memory

Measured on a single NVIDIA H100 80GB GPU.

| Model                   | Model memory | Candidate memory |           Speed |
| ----------------------- | -----------: | ---------------: | --------------: |
| GENRE-Llama-1B baseline |      2.4 GB  |           5.4 GB | 69.6 mentions/s |
| LongBEL-1B              |      2.4 GB  |           5.4 GB | 48.5 mentions/s |

LongBEL has the same model memory footprint as the sentence-level Llama-1B baseline, but it is slower because it processes longer contexts and updates document-level memory during inference.

## Limitations

This model assumes that mention spans and semantic groups are given. It does not perform mention detection.

LongBEL is most useful when concepts recur within a document. When most concepts appear only once, the memory mechanism has less information to exploit.

Because LongBEL uses previous predictions as memory, early mistakes can still influence later predictions. Robust memory training reduces this risk but does not remove it completely.

This model is intended for research use. It should not be used for clinical decision-making without additional validation and human oversight.

## Reproducibility

Code and evaluation scripts are available in this [GitHub repository](https://anonymous.4open.science/r/LongBEL-31AD).

Trained model checkpoints and processed datasets are available in the anonymous Hugging Face collection associated with LongBEL.