Instructions to use Aremaki/LongBEL_1B_MedMentions_ST21pv with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Aremaki/LongBEL_1B_MedMentions_ST21pv with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Aremaki/LongBEL_1B_MedMentions_ST21pv", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Aremaki/LongBEL_1B_MedMentions_ST21pv", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Aremaki/LongBEL_1B_MedMentions_ST21pv with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Aremaki/LongBEL_1B_MedMentions_ST21pv" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Aremaki/LongBEL_1B_MedMentions_ST21pv", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Aremaki/LongBEL_1B_MedMentions_ST21pv
- SGLang
How to use Aremaki/LongBEL_1B_MedMentions_ST21pv with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Aremaki/LongBEL_1B_MedMentions_ST21pv" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Aremaki/LongBEL_1B_MedMentions_ST21pv", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Aremaki/LongBEL_1B_MedMentions_ST21pv" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Aremaki/LongBEL_1B_MedMentions_ST21pv", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Aremaki/LongBEL_1B_MedMentions_ST21pv with Docker Model Runner:
docker model run hf.co/Aremaki/LongBEL_1B_MedMentions_ST21pv
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-1B trained on MedMentions, 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 | 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
import torch
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained(
"AnonymousARR42/LongBEL_1B_MedMentions_st21pv",
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.
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:
## Mention 1: pregnant woman
- Beam 1:
Predicted concept name: Pregnant Woman
Predicted code: C0033011
Beam score: 0.997
- Beam 2:
Predicted concept name: Pregnant Women
Predicted code: C0033011
Beam score: 0.024
- Beam 3:
Predicted concept name: Pregnancy Partner
Predicted code: C3538996
Beam score: 0.000
- Beam 4:
Predicted concept name: Pregnant Woman
Predicted code: C0033011
Beam score: 0.000
- Beam 5:
Predicted concept name: Pregnant Women
Predicted code: C0033011
Beam score: 0.000
## Mention 2: severe-range hypertension
- Beam 1:
Predicted concept name: Hypertensive crisis
Predicted code: C0020546
Beam score: 0.312
- Beam 2:
Predicted concept name: Hypertensive crisis (disorder)
Predicted code: C0020546
Beam score: 0.235
- Beam 3:
Predicted concept name: Hypertensive disease (disorder)
Predicted code: C0020538
Beam score: 0.203
- Beam 4:
Predicted concept name: Hypertensive disease
Predicted code: C0020538
Beam score: 0.168
- Beam 5:
Predicted concept name: Hypertension arterial
Predicted code: C0020538
Beam score: 0.114
## Mention 3: proteinuria
- Beam 1:
Predicted concept name: Proteinurias
Predicted code: C0033687
Beam score: 0.999
- Beam 2:
Predicted concept name: Proteinuric diabetic nephropathy (disorder)
Predicted code: C0403519
Beam score: 0.030
- Beam 3:
Predicted concept name: Proteinuria
Predicted code: C0033687
Beam score: 0.012
- Beam 4:
Predicted concept name: Proteinuria (disorder)
Predicted code: C0033687
Beam score: 0.006
- Beam 5:
Predicted concept name: Proteinuric diabetic nephropathy
Predicted code: C0403519
Beam score: 0.006
## Mention 4: PET
- Beam 1:
Predicted concept name: Investigation Finding
Predicted code: C0243095
Beam score: 0.081
- Beam 2:
Predicted concept name: PET - Pre-eclamptic toxemia
Predicted code: C0032914
Beam score: 0.017
- Beam 3:
Predicted concept name: PET - Pre-eclamptic toxaemia
Predicted code: C0032914
Beam score: 0.010
- Beam 4:
Predicted concept name: PET - Severe pre-eclamptic toxemia
Predicted code: C0341950
Beam score: 0.005
- Beam 5:
Predicted concept name: PET - Severe pre-eclamptic toxaemia
Predicted code: C0341950
Beam score: 0.004
Saliency map example
The model can also return token-level saliency maps during inference.
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:
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 underlined and ⭐ marks the main LongBEL-1B model.
| 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 |
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.
Trained model checkpoints and processed datasets are available in the anonymous Hugging Face collection associated with LongBEL.
- Downloads last month
- 44
Model tree for Aremaki/LongBEL_1B_MedMentions_ST21pv
Base model
meta-llama/Llama-3.2-1B-InstructDataset used to train Aremaki/LongBEL_1B_MedMentions_ST21pv
Collection including Aremaki/LongBEL_1B_MedMentions_ST21pv
Evaluation results
- Recall@1 on MedMentions-ST21pvself-reported0.776