| Field | Value |
|---|---|
| Base model | meta-llama/Llama-3.2-8B-Instruct |
| Task | Biomedical Entity Linking |
| Dataset | SPACCC |
| Knowledge base | SNOMED CT Spanish Version (July 31, 2021 release) |
| Input | BigBio-like documents with mention spans and semantic groups |
| Output | Ranked SNOMED concept predictions |
| Decoding | Semantic-guided constrained decoding |
| Main metric | Recall@1 |
1import torch
2from transformers import AutoModelForCausalLM
3
4model = AutoModelForCausalLM.from_pretrained(
5 "AnonymousARR42/LongBEL_8B_SPACCC",
6 trust_remote_code=True,
7 torch_dtype=torch.bfloat16,
8 device_map="auto",
9)type field.1num_beams = 5
2
3bigbio_pages = [
4 {
5 "id": "001",
6 "document_id": "doc_001",
7 "passages": [
8 {
9 "id": "0",
10 "type": "paragraph",
11 "text": [
12 "Una mujer embarazada de 29 años consultó por hipertensión grave, "
13 "cefalea y dolor epigástrico. Las pruebas de laboratorio mostraron proteinuria. "
14 "Fue ingresada durante la noche por sospecha de PET y se inició tratamiento urgente."
15 ],
16 "offsets": [[0, 227]],
17 }
18 ],
19 "entities": [
20 {
21 "id": "T1",
22 "type": "ENFERMEDAD",
23 "text": ["hipertensión grave"],
24 "offsets": [[45, 63]],
25 },
26 {
27 "id": "T2",
28 "type": "ENFERMEDAD",
29 "text": ["proteinuria"],
30 "offsets": [[131, 142]],
31 },
32 {
33 "id": "T3",
34 "type": "ENFERMEDAD",
35 "text": ["PET"],
36 "offsets": [[191, 194]],
37 },
38 ],
39 "events": [],
40 "coreferences": [],
41 "relations": [],
42 }
43]
44
45predictions = model.sample(
46 bigbio_pages=bigbio_pages,
47 num_beams=num_beams,
48)
49
50for i in range(0, len(predictions), num_beams):
51 mention = predictions[i]["mention"]
52 print(f"## Mention {(i // num_beams) + 1}: {mention}")
53
54 for j in range(num_beams):
55 pred = predictions[i + j]
56 print(
57 f" - Beam {j + 1}:\n"
58 f" Predicted concept name: {pred['pred_concept_name']}\n"
59 f" Predicted code: {pred['pred_concept_code']}\n"
60 f" Beam score: {pred['beam_score']:.3f}\n"
61 )1## Mention 1: hipertensión grave
2 - Beam 1:
3 Predicted concept name: hipertensión arterial
4 Predicted code: 38341003
5 Beam score: 0.993
6
7 - Beam 2:
8 Predicted concept name: degeneración vascular hipertensiva
9 Predicted code: 38341003
10 Beam score: 0.249
11
12 - Beam 3:
13 Predicted concept name: hipertensión arterial maligna
14 Predicted code: 70272006
15 Beam score: 0.046
16
17 - Beam 4:
18 Predicted concept name: degeneración macular senil
19 Predicted code: 267718000
20 Beam score: 0.004
21
22 - Beam 5:
23 Predicted concept name: hipertensión maligna secundaria, SAI
24 Predicted code: 194784007
25 Beam score: 0.001
26
27## Mention 2: proteinuria
28 - Beam 1:
29 Predicted concept name: proteinuria de causa desconocida
30 Predicted code: 231860006
31 Beam score: 0.000
32
33 - Beam 2:
34 Predicted concept name: proteína de la membrana mitocondrial asociada con neurodegeneración
35 Predicted code: 709415008
36 Beam score: 0.000
37
38 - Beam 3:
39 Predicted concept name: proteinuria aislada concomitante con glomerulonefritis membranoproliferativa tipo III y debida a ella
40 Predicted code: 368931000119104
41 Beam score: 0.000
42
43 - Beam 4:
44 Predicted concept name: proteinosis alveolar pulmonar congénita
45 Predicted code: 707442002
46 Beam score: 0.000
47
48 - Beam 5:
49 Predicted concept name: proteinosis alveolar pulmonar
50 Predicted code: 10501004
51 Beam score: 0.000
52
53## Mention 3: PET
54 - Beam 1:
55 Predicted concept name: preeclampsia
56 Predicted code: 398254007
57 Beam score: 0.285
58
59 - Beam 2:
60 Predicted concept name: preeclampsia en el puerperio
61 Predicted code: 765182005
62 Beam score: 0.068
63
64 - Beam 3:
65 Predicted concept name: púrpura trombocitopénica
66 Predicted code: 302873008
67 Beam score: 0.000
68
69 - Beam 4:
70 Predicted concept name: púrpura de la vulva
71 Predicted code: 289487000
72 Beam score: 0.000
73
74 - Beam 5:
75 Predicted concept name: pústula maligna
76 Predicted code: 84980006
77 Beam score: 0.0001predictions, saliency_maps = model.sample(
2 bigbio_pages=bigbio_pages,
3 num_beams=num_beams,
4 with_saliency_maps=True,
5)
6
7model.display_saliency_map(saliency_maps[2])PET:
| Model | MM-ST21PV (English) | QUAERO-EMEA (French) | SympTEMIST (Spanish) | DisTEMIST (Spanish) | MedProcNER (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 | 77.2 ± 3.0 | 61.8 ± 2.5 | 64.3 ± 2.2 | 69.0 ± 2.0 |
| ⭐ LongBEL-8B | 79.3 ± 0.8 | 75.4 ± 3.4 | 62.0 ± 2.6 | 63.6 ± 2.1 | 69.0 ± 2.1 |
| LongBEL-8B + Ensemble | 80.0 ± 0.8 | 77.6 ± 3.0 | 63.3 ± 2.5 | 65.8 ± 2.2 | 71.0 ± 2.0 |
| Model | Model memory | Candidate memory | Speed |
|---|---|---|---|
| GENRE-Llama-8B baseline | 28.6 GB | 5.4 GB | 38.2 mentions/s |
| LongBEL-8B | 28.6 GB | 5.4 GB | 15.2 mentions/s |