Instructions to use OpenMed/Inkling2-Mini-TrialCriteria-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenMed/Inkling2-Mini-TrialCriteria-v1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="OpenMed/Inkling2-Mini-TrialCriteria-v1")# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("OpenMed/Inkling2-Mini-TrialCriteria-v1") model = AutoModelForMultimodalLM.from_pretrained("OpenMed/Inkling2-Mini-TrialCriteria-v1", device_map="auto") - Notebooks
- Google Colab
- Kaggle
OpenMed Inkling 2 Mini Trial Criteria v1
OpenMed's fine-tune of Inkling 2 Mini for clinical trial eligibility text. Give it one criterion from a trial registration and it tells you which list the criterion belongs to: inclusion or exclusion. On 200 criteria from 76 trials whose sponsors it never saw in training, macro F1 rose from 76.19 for the original Inkling 2 Mini to 86.99, a gain of +10.81 points. It ships as one standalone checkpoint of about 19.5 GB in the same mixed NVFP4 and MXFP8 format as the original, under Apache-2.0.
| Developed by | OpenMed |
|---|---|
| Base model | Inkling 2 Mini by Thinking Machines Lab (Apache-2.0) |
| Task | Sort one clinical trial eligibility criterion into the inclusion or the exclusion list |
| Input | One English criterion, up to 160 tokens |
| Output | inclusion or exclusion, the label with the higher score |
| Evaluated on | 200 criteria (100 per label) from 76 ClinicalTrials.gov registrations by 67 sponsors, none of them in training; macro F1 86.99 (original Inkling 2 Mini 76.19) |
| Training | 400 criteria from 181 registrations; rank-8 LoRA on the query and value projections of the last four layers (278,528 trained parameters), 67 steps, then merged into this checkpoint |
| Language | English |
| License | Apache-2.0 |
About OpenMed
OpenMed builds open models and open-source tools for clinical and biomedical text that run on your own hardware.
- 2,300+ open models on Hugging Face for clinical NER, de-identification, clinical trials and more.
- The OpenMed Python SDK, Apache-2.0:
pip install openmedfor de-identification, clinical NER, and FHIR and HL7 tooling, all local. - New models every week: follow OpenMed on Hugging Face and @OpenMed_AI on X.
Quick start
The checkpoint loads directly with Transformers on one CUDA GPU. The code below was checked against this repository with the tested Transformers revision.
pip install -U accelerate torch https://github.com/huggingface/transformers/archive/046bdb8cc2cee29d233964bb77fe6fd37cfe4aa3.zip
import torch
from transformers import AutoModelForMultimodalLM, AutoTokenizer
repo = "OpenMed/Inkling2-Mini-TrialCriteria-v1"
tokenizer = AutoTokenizer.from_pretrained(repo)
model = AutoModelForMultimodalLM.from_pretrained(
repo, dtype=torch.bfloat16, device_map={"": "cuda"},
attn_implementation="eager", experts_implementation="eager",
).eval()
labels = ["inclusion", "exclusion"]
codes = "ABCDE"[:len(labels)]
instruction = "Classify this clinical trial criterion by the registry section it belongs to."
legend = "\n".join(f"{code} = {label}" for code, label in zip(codes, labels))
def encode(text):
return tokenizer.encode(text, add_special_tokens=False)
text = "Participants must be at least 18 years old."
ids = encode(instruction + "\n" + legend + "\nText: ") + encode(text)[:160] + encode("\nAnswer:")
inputs = torch.tensor([ids], device=model.device)
choices = [encode(" " + code)[0] for code in codes]
with torch.inference_mode():
logits = model(input_ids=inputs, attention_mask=torch.ones_like(inputs),
use_cache=False, logits_to_keep=1).logits
print(labels[logits[0, -1, choices].argmax().item()])
How it decides
- One forward pass, no generation. The prompt lists the two labels as answer codes
AandB, and the model's next-token scores for those two codes pick the label. Nothing is sampled. - Use this exact prompt. The instruction, the label legend, the
Text:andAnswer:markers and the 160-token cap are the ones used in training and evaluation. - Many criteria: loop over them with the same prompt; each call scores one criterion.
- Memory: the weights are decoded to BF16 on load; the reference run used one GPU with 96 GB of memory.
Evaluation
200 eligibility criteria from 76 ClinicalTrials.gov registrations, 100 inclusion and 100 exclusion. Their 67 sponsors are all different from the sponsors in the training data, and duplicate and near-duplicate criterion templates were removed. The model trained for one fixed epoch, with no checkpoint chosen on these criteria, and every model below scored the same 200 criteria with the same prompt.
| Model | Macro F1 | Accuracy | Inclusion precision / recall | Exclusion precision / recall |
|---|---|---|---|---|
| OpenMed Inkling 2 Mini Trial Criteria v1 (this model) | 86.99 | 87.00 | 88.54 / 85.00 | 85.58 / 89.00 |
| Before OpenMed fine-tuning: thinkingmachines/Inkling-2-Mini | 76.19 | 76.50 | 71.54 / 88.00 | 84.42 / 65.00 |
| TF-IDF and logistic regression trained on the same 400 criteria | 78.97 | 79.00 | 81.52 / 75.00 | 76.85 / 83.00 |
- OpenMed's fine-tuning added +10.81 macro F1 points over the original Inkling 2 Mini (95% interval +5.96 to +15.87, paired bootstrap over trials, 2,000 resamples), and +8.03 points over the TF-IDF baseline (+0.97 to +15.46).
- The biggest change is on exclusion criteria: the original model found 65 of 100, this model finds 89 of 100.
- This standalone checkpoint gives the same label as the trained adapter on all 200 criteria.
What it is for
It sorts the text of a trial protocol, for example to rebuild the inclusion and exclusion lists when a registry entry or a protocol PDF runs them together, or to check that a criterion sits in the right list before a person reviews it. It reads one criterion at a time. It does not decide whether a patient qualifies for a trial, and it has been evaluated on English registry text only.
Built on
OpenMed fine-tuned this model from Inkling 2 Mini by Thinking Machines Lab (Apache-2.0), using the fixed-loop release. Training and evaluation used sponsor-entered eligibility criteria from ClinicalTrials.gov, U.S. National Library of Medicine; every registration used is listed in NOTICE.txt. Thank you to Thinking Machines Lab for releasing Inkling 2 Mini openly.
This model is released under Apache-2.0. No registry text or training data is included in this repository.
Citation
@misc{panahi2025openmedner,
title={OpenMed NER: Open-Source, Domain-Adapted State-of-the-Art Transformers for Biomedical NER Across 12 Public Datasets},
author={Maziyar Panahi},
year={2025},
eprint={2508.01630},
archivePrefix={arXiv}
}
OpenMed · Hugging Face · GitHub · PyPI · X
- Downloads last month
- 32
Model tree for OpenMed/Inkling2-Mini-TrialCriteria-v1
Base model
thinkingmachines/Inkling-2-MiniPaper for OpenMed/Inkling2-Mini-TrialCriteria-v1
Evaluation results
- Macro F1 on ClinicalTrials.gov eligibility criteria (200 criteria, 76 registrations, sponsors not in training)self-reported86.990
- Accuracy on ClinicalTrials.gov eligibility criteria (200 criteria, 76 registrations, sponsors not in training)self-reported87.000
- Exclusion recall on ClinicalTrials.gov eligibility criteria (200 criteria, 76 registrations, sponsors not in training)self-reported89.000
- Inclusion precision on ClinicalTrials.gov eligibility criteria (200 criteria, 76 registrations, sponsors not in training)self-reported88.540