Downloads · 30 days
114
19% of all-time downloads
Rumiii/Trion_8B-FHIR_R4
Trion_8B-FHIR_R4 is a text generation model from Rumiii. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
Downloads · 30 days
114
19% of all-time downloads
All-time downloads
594
Public
Parameters
8B
16.1 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors16.1 GB · 100%
From the Hugging Face model README

A fine-tuned Llama-3.1-8B-Instruct model specialized for multi-turn clinical tool-calling over FHIR R4 APIs. Given a clinical instruction, the model plans and issues a sequence of structured function calls (patient lookup, lab queries, vital sign recording, medication ordering, referrals) and terminates with a final structured answer.
Unlike the source dataset's raw GET / POST / FINISH text-action format, this model was trained to emit calls using Llama 3.1's native JSON tool-calling chat template, making it a drop-in fit for standard transformers / chat_template tool-calling pipelines.
| Attribute | Value |
|---|---|
| Base model | meta-llama/Llama-3.1-8B-Instruct |
| Quantized base used for training | unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit |
| Fine-tuning method | QLoRA (4-bit), merged to fp16 for release |
| LoRA rank / alpha | 16 / 32 |
| LoRA target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| LoRA dropout | 0 |
| Trainable parameters | 41,943,040 (~0.52% of base) |
| Max sequence length | 3072 tokens |
| Training hardware | Single Kaggle T4 (16GB VRAM) |
| Training framework | Unsloth + TRL/Transformers Trainer |
| Dataset | Nadhari/MedToolCalling (284 examples, 10 clinical task types) |
| License | Apache 2.0 |

Trion-8B-FHIR-R4 was evaluated across 10 EHR tool-calling task categories using 1,100 synthetic test scenarios. Strong performance (90–100%) was achieved in patient lookup by name and date of birth (Task 1: 99%), age calculation (Task 2: 97%), blood pressure recording (Task 3: 100%), and orthopedic referrals (Task 8: 100%). Moderate performance (40–89%) appeared in magnesium checks and conditional IV orders (Task 5: 45%), latest blood glucose readings (Task 7: 50%), potassium checks with conditional orders and lab requests (Task 9: 51%), and latest magnesium readings (Task 4: 44%). Weak performance was observed in average blood glucose over the previous 24 hours (Task 6: 7%) and HbA1c checks with conditional lab requests (Task 10: 26%). On two additional unseen task combinations, accuracy was 56% for latest potassium readings and 20% for average magnesium readings. Overall, the model achieved 61.9% success on core tasks and 38% on unseen scenarios. It produced valid tool-call formats in all 1,100 episodes, but needs improvement in historical lab-result retrieval, conditional clinical workflows, and generalization to unfamiliar tasks.
The raw dataset ships every row with a repeated, ~2,000+ token FHIR documentation block as the system prompt (conversation[0]), and tool responses returned as full, unabridged FHIR JSON resources (often 3,000+ tokens for a single observation or bundle). Training directly on this would blow past most sequence budgets and waste the model's attention on boilerplate rather than the clinical reasoning that actually matters.
This model's training pipeline instead:
instruction field as the user turn.Pat:123 John Doe 1980-01-01, Obs:Magnesium=1.2 mg/dL) instead of the full resource payload — typically ~3,000 tokens compressed to ~50.GET / POST / FINISH action strings into proper OpenAI/Llama-style tool_calls with structured name + arguments, mapped against a fixed 6-function tool schema (below).The model was trained against a fixed set of six callable functions:
| Function | Purpose |
|---|---|
search_patient | Search for a patient by given name, family name, and birthdate to retrieve their MRN. |
get_observation | Query lab results or vital signs for a patient (e.g. magnesium, potassium, CBG, HbA1c, blood pressure) via LOINC code or category. |
record_vital_sign | Record a new vital sign Observation resource for a patient. |
order_medication | Place a medication order via a MedicationRequest resource (e.g. IV magnesium or potassium replacement). |
order_service_request | Order a referral or follow-up lab/service via a ServiceRequest resource. |
finish | Submit the final structured answer once the task is complete. |
Each conversation in training ends with a finish call, and the model was taught to alternate correctly between assistant tool calls and tool/user responses.
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_id = "Rumiii/Trion_8B-FHIR_R4"
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16,
device_map="auto",
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
tools = [
{
"name": "search_patient",
"description": "Search for a patient by name and date of birth to retrieve their MRN.",
"parameters": {
"type": "object",
"properties": {
"given": {"type": "string", "description": "Patient's given (first) name"},
"family": {"type": "string", "description": "Patient's family (last) name"},
"birthdate": {"type": "string", "description": "Date of birth, YYYY-MM-DD"},
},
"required": ["given", "family", "birthdate"],
},
},
# ... include get_observation, record_vital_sign, order_medication,
# order_service_request, and finish as defined in the Tool Schema above
]
messages = [
{
"role": "system",
"content": "You are a clinical assistant with access to FHIR R4 tools. "
"Use them to complete the task, then call finish().",
},
{
"role": "user",
"content": "Look up patient John Doe, born 1980-01-01, and retrieve his most recent magnesium level.",
},
]
prompt = tokenizer.apply_chat_template(
messages, tools=tools, tokenize=False, add_generation_prompt=True,
)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
The model should respond with a tool_calls block invoking search_patient, followed (after you return a tool result) by get_observation, and eventually finish.
Nadhari/MedToolCalling — 284 multi-turn clinical tool-calling conversations spanning 10 task types, each requiring the model to plan and execute a sequence of FHIR R4 API calls to satisfy a clinical instruction.
FastLanguageModel + Hugging Face Traineradamw_8bit, cosine LR schedule, learning rate 2e-4, weight decay 0.01If you use this model, please cite the base model and dataset it builds on:
@misc{trion8bfhirr4,
title = {Trion-8B-FHIR-R4: A Llama-3.1-8B Tool-Calling Model for FHIR R4 Clinical Workflows},
author = {Rumi},
year = {2026},
url = {https://huggingface.co/Rumiii/Trion_8B-FHIR_R4}
}
Base model: meta-llama/Llama-3.1-8B-Instruct Dataset: Nadhari/MedToolCalling