Text Classification
Transformers
Safetensors
English
inkling2_loop
image-text-to-text
medical
biomedical
pubmed
abstracts
rhetorical-roles
inkling
openmed
Eval Results (legacy)
8-bit precision
modelopt
Instructions to use OpenMed/Inkling2-Mini-BiomedicalSections-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenMed/Inkling2-Mini-BiomedicalSections-v1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="OpenMed/Inkling2-Mini-BiomedicalSections-v1")# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("OpenMed/Inkling2-Mini-BiomedicalSections-v1") model = AutoModelForMultimodalLM.from_pretrained("OpenMed/Inkling2-Mini-BiomedicalSections-v1", device_map="auto") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from OpenMed/Inkling2-Mini-BiomedicalSections-v1: direct link, hf CLI and curl.
- Browser
- Download file 9.32 kB
-
https://huggingface.co/OpenMed/Inkling2-Mini-BiomedicalSections-v1/resolve/main/README.md
- Command line
-
hf download hf://OpenMed/Inkling2-Mini-BiomedicalSections-v1/README.md
-
curl -L -o README.md https://huggingface.co/OpenMed/Inkling2-Mini-BiomedicalSections-v1/resolve/main/README.md
9.32 kB
| license: apache-2.0 | |
| language: | |
| - en | |
| library_name: transformers | |
| pipeline_tag: text-classification | |
| base_model: thinkingmachines/Inkling-2-Mini | |
| tags: | |
| - medical | |
| - biomedical | |
| - pubmed | |
| - abstracts | |
| - rhetorical-roles | |
| - text-classification | |
| - inkling | |
| - openmed | |
| model-index: | |
| - name: Inkling2-Mini-BiomedicalSections-v1 | |
| results: | |
| - task: | |
| type: text-classification | |
| name: Biomedical abstract sentence role | |
| dataset: | |
| name: Sentences from structured biomedical abstracts (300 sentences, 181 articles, not in training) | |
| type: biomedical-abstract-sections | |
| split: development | |
| metrics: | |
| - type: f1 | |
| value: 78.4 | |
| name: Macro F1 (five roles) | |
| - type: accuracy | |
| value: 78.67 | |
| name: Accuracy | |
| - type: f1 | |
| value: 88.19 | |
| name: F1 methods | |
| - type: f1 | |
| value: 84.38 | |
| name: F1 results | |
| <p align="center"> | |
| <a href="https://huggingface.co/OpenMed"><img src="https://cdn-avatars.huggingface.co/v1/production/uploads/5fd5e18a90b6dc4633f6d292/qWeFUOCMgN4q-ET102lRZ.png" alt="OpenMed" width="110"></a> | |
| </p> | |
| <h1 align="center">OpenMed Inkling 2 Mini Biomedical Sections v1</h1> | |
| <p align="center"> | |
| <a href="https://huggingface.co/OpenMed"><img alt="OpenMed on Hugging Face" src="https://img.shields.io/badge/OpenMed-2%2C300%2B%20open%20models-ff9d00"></a> | |
| <a href="https://github.com/maziyarpanahi/openmed"><img alt="OpenMed SDK on GitHub" src="https://img.shields.io/github/stars/maziyarpanahi/openmed?label=OpenMed%20SDK&logo=github"></a> | |
| <a href="https://pypi.org/project/openmed/"><img alt="pip install openmed" src="https://img.shields.io/pypi/v/openmed?label=pip%20install%20openmed&color=3775a9"></a> | |
| <img alt="License Apache-2.0" src="https://img.shields.io/badge/license-Apache--2.0-blue"> | |
| </p> | |
| **OpenMed's fine-tune of Inkling 2 Mini for reading biomedical abstracts.** Give it one sentence from an abstract and it names the sentence's role: **background**, **objective**, **methods**, **results** or **conclusions**. On 300 sentences from 181 articles not used in training, it scores **78.40 macro F1**, better than the original Inkling 2 Mini on **all five roles**, and it finds **93.3% of methods sentences** and **90.0% of results sentences**. 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](https://huggingface.co/OpenMed) | | |
| |---|---| | |
| | Base model | [Inkling 2 Mini](https://huggingface.co/thinkingmachines/Inkling-2-Mini) by Thinking Machines Lab (Apache-2.0) | | |
| | Task | Name the role of one sentence in a biomedical abstract | | |
| | Input | One English sentence, up to 160 tokens | | |
| | Output | `background`, `objective`, `methods`, `results` or `conclusions`, the label with the highest score | | |
| | Evaluated on | 300 sentences (60 per role) from 181 articles, none of them in training; macro F1 78.40 (original Inkling 2 Mini 77.13) | | |
| | Training | 600 labeled sentences from 509 open-access trial abstracts; rank-8 LoRA on the query and value projections of the last four layers (278,528 trained parameters), 100 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](https://huggingface.co/OpenMed)** for clinical NER, de-identification, literature search and more. | |
| - **[The OpenMed Python SDK](https://github.com/maziyarpanahi/openmed)**, Apache-2.0: `pip install openmed` for de-identification, clinical NER, and FHIR and HL7 tooling, all local. | |
| - New models every week: follow [OpenMed on Hugging Face](https://huggingface.co/OpenMed) and [@OpenMed_AI on X](https://x.com/OpenMed_AI). | |
| ## 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](https://github.com/huggingface/transformers/commit/046bdb8cc2cee29d233964bb77fe6fd37cfe4aa3). | |
| ```bash | |
| pip install -U accelerate torch https://github.com/huggingface/transformers/archive/046bdb8cc2cee29d233964bb77fe6fd37cfe4aa3.zip | |
| ``` | |
| ```python | |
| import torch | |
| from transformers import AutoModelForMultimodalLM, AutoTokenizer | |
| repo = "OpenMed/Inkling2-Mini-BiomedicalSections-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 = ["background", "objective", "methods", "results", "conclusions"] | |
| codes = "ABCDE"[:len(labels)] | |
| instruction = "Classify the role of this sentence in a biomedical abstract." | |
| 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 = "We randomly assigned volunteers to two groups." | |
| 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 five roles as answer codes `A` to `E`, and the model's next-token scores for those codes pick the role. Nothing is sampled. | |
| - **Use this exact prompt.** The instruction, the role legend, the `Text:` and `Answer:` markers and the 160-token cap are the ones used in training and evaluation. | |
| - **A whole abstract:** split it into sentences and score each one with the same prompt. | |
| - **Memory:** the weights are decoded to BF16 on load; the reference run used one GPU with 96 GB of memory. | |
| ## Evaluation | |
| **300 sentences from 181 biomedical articles**, 60 for each role, from an independently sourced 2024 set of abstracts. None of these articles is in the training data. Each sentence's role comes from the heading its authors gave it in a structured abstract, and the headings were removed before scoring. The model trained for one fixed epoch, with no checkpoint chosen on these sentences, and every model below scored the same 300 sentences. | |
| | Model | Macro F1 | Accuracy | | |
| |---|---:|---:| | |
| | **OpenMed Inkling 2 Mini Biomedical Sections v1** (this model) | **78.40** | **78.67** | | |
| | Before OpenMed fine-tuning: [thinkingmachines/Inkling-2-Mini](https://huggingface.co/thinkingmachines/Inkling-2-Mini) | 77.13 | 77.33 | | |
| | TF-IDF and logistic regression trained on the same 600 sentences | 66.14 | 66.33 | | |
| F1 by role: | |
| | Role | This model | Before OpenMed fine-tuning | This model's precision / recall | | |
| |---|---:|---:|---:| | |
| | Methods | **88.19** | 85.94 | 83.58 / 93.33 | | |
| | Results | **84.38** | 83.46 | 79.41 / 90.00 | | |
| | Conclusions | **81.08** | 79.63 | 88.24 / 75.00 | | |
| | Background | **69.84** | 68.75 | 66.67 / 73.33 | | |
| | Objective | **68.52** | 67.89 | 77.08 / 61.67 | | |
| - OpenMed's fine-tuning added **+1.27 macro F1 points** over the original Inkling 2 Mini (95% interval +0.19 to +2.65, paired bootstrap over articles, 2,000 resamples) and raised F1 on every role. It is **+12.26 points** over the TF-IDF baseline (+7.02 to +17.40). | |
| - Methods, results and conclusions are the strongest roles. Background and objective sentences are the ones it most often confuses with each other. | |
| - This standalone checkpoint gives the same role as the trained adapter on all 300 sentences. | |
| ## What it is for | |
| It adds structure to abstracts that have none: tag each sentence, then pull the methods and results sentences for screening, evidence tables or search. It has been evaluated on English abstracts of biomedical studies. | |
| For CPU-sized models on the same task, see [OpenMed/ModernBERT-BiomedicalSections-Base-v1](https://huggingface.co/OpenMed/ModernBERT-BiomedicalSections-Base-v1) and [OpenMed/GLiNER2.5-BiomedicalSections-Small-v1](https://huggingface.co/OpenMed/GLiNER2.5-BiomedicalSections-Small-v1). | |
| ## Built on | |
| OpenMed fine-tuned this model from [Inkling 2 Mini](https://huggingface.co/thinkingmachines/Inkling-2-Mini) by Thinking Machines Lab (Apache-2.0), using the fixed-loop release. Training used sentences from 509 CC BY abstracts of randomized controlled trials; every article, with its authors and DOI, is credited in [NOTICE.txt](NOTICE.txt). Thank you to Thinking Machines Lab for releasing Inkling 2 Mini openly, and to the authors who published their work open access. | |
| This model is released under Apache-2.0. No abstract text or training data is included in this repository. | |
| ## Citation | |
| ```bibtex | |
| @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} | |
| } | |
| ``` | |
| <p align="center"><b>OpenMed</b> · <a href="https://huggingface.co/OpenMed">Hugging Face</a> · <a href="https://github.com/maziyarpanahi/openmed">GitHub</a> · <a href="https://pypi.org/project/openmed/">PyPI</a> · <a href="https://x.com/OpenMed_AI">X</a></p> | |