Maxson 1
Maxson 1 (he/him) is a small, offline pharmacometrics assistant built for nlmx, the population PK/PD software. He is a 1.7B-parameter model trained from SmolLM2-1.7B-Instruct to work the way a clinical pharmacologist and pharmacometrician works: plan the analysis, build and QC the dataset, write and repair the control stream, run it in nlmx, read the results and decide what to do next.
He runs on a laptop, needs no internet connection and sends no data anywhere, so he can be used with confidential study data.
He is trained to say what he doesn't know before he suggests anything. Ask him about a compound he has never seen and he says so, instead of making up a half-life.
What he does
- Plans nlmx analyses. Turns a plain-language request, including long, casual or misspelled multi-step ones, into a JSON plan of nlmx workflow steps (generate, qc-data, eda, nca, autoinit, screen, fit, vpc, cov, sims, power, er, report and more).
- Writes and repairs NONMEM control streams, and explains or comments them line by line.
- Builds and checks NONMEM datasets: finds wrong EVID/MDV/AMT records, dosing and sampling errors, BLQ handling and broken time columns.
- Writes and fixes nlmx command lines and settings files, and turns a study design into an
nlmx generatecommand. - Interprets fits: computes RSE, CV and shrinkage from the estimates, flags what limits the model and proposes the next run (for example, a likelihood-ratio test for a covariate).
- Drafts analysis plans and report sections in which every number comes from the evidence he was given.
- Says when he doesn't know, and points to where the answer can be found.
Results
A fixed set of 593 held-out tasks, none of them seen in training, each scored by an automatic check (for example: does the plan match, does the control stream pass QC, are the computed values right, does he refuse to invent a number). Scores run from 0 to 1.
| Task | SmolLM2-1.7B-Instruct | Maxson 1 | Change |
|---|---|---|---|
| nlmx plans | 0.03 | 0.97 | +0.94 |
| Report sections (numbers from evidence) | 0.51 | 0.99 | +0.48 |
| Control streams written | 0.00 | 0.95 | +0.95 |
| Control streams repaired | 0.14 | 0.83 | +0.69 |
| Dataset QC | 0.00 | 0.76 | +0.76 |
| Honesty (says when he doesn't know) | 0.34 | 0.93 | +0.60 |
| Identity (answers as Maxson) | 0.32 | 0.70 | +0.38 |
| Analysis plans (structure) | 0.12 | 1.00 | +0.88 |
| Casework (held-out benchmark projects) | 0.22 | 0.81 | +0.60 |
| nlmx options (which option does this) | 0.00 | 0.30 | +0.30 |
| nlmx command lines fixed | 0.00 | 0.67 | +0.67 |
| nlmx generate from a design | 0.00 | 0.92 | +0.92 |
| nlmx settings keys | 0.42 | 1.00 | +0.58 |
| Benchmark dataset records QC | 0.00 | 0.87 | +0.87 |
| Overall | 0.15 | 0.84 | +0.69 |
Example
Q: What's the PK of LJ-30634?
SmolLM2-1.7B-Instruct: To determine the PK of LJ-30634, I would need more information about the drug's physicochemical properties, such as its molecular weight, molecular weight distribution, and molecular weight distribution standard deviation...
Maxson 1: I don't know LJ-30634. It isn't something I've learned about; it may be an internal code or a new compound. I won't guess its properties. If you share what is known (modality, route, half-life from phase 1, elimination pathway), I can help you plan the analysis around it.
How he was trained
Each stage starts from the model the previous stage produced:
- Literature. Continued pretraining of SmolLM2-1.7B-Instruct on open-access clinical pharmacology and pharmacometrics articles licensed CC BY or CC0, together with the nlmx 4.31 documentation.
- nlmx. Supervised fine-tuning on synthetic nlmx tasks: plans, commands, documentation questions, reading nlmx outputs, computed pharmacometric examples and report sections, with every number checked against its scenario.
- Maxson. Fine-tuning on analysis planning, NONMEM dataset construction and QC, control-stream writing and repair, judgement calls on diagnostics and a pharmacometrics knowledge base, with a replay of earlier data so the nlmx skills are kept.
- Casework. Fine-tuning on 200 simulated population PK and PK/PD benchmark projects with a known truth (writing, explaining and annotating their control streams, interpreting the fits, comparing them with the truth, covariate models, dataset QC), on the nlmx validation package, and on his own earlier answers that passed the automatic checks.
- Preference training. Direct preference optimization (DPO) on pairs of his own answers to automatically graded nlmx and casework tasks, preferring the answer that passed over the one that failed.
All fine-tuning data are synthetic. No clinical records and no patient data were used at any stage.
Intended use
- A working assistant for pharmacometricians and clinical pharmacologists using nlmx.
- Drafting analysis plans, control streams, dataset checks and report text for an analyst to review.
- Teaching and exploring population PK/PD with synthetic projects.
Out of scope
- Dosing individual patients, prescribing or any clinical decision. He is trained to refuse these requests.
- Regulatory conclusions without qualified review of the data, the model and the diagnostics.
- General chat outside pharmacometrics. At 1.7B parameters, general knowledge and long reasoning are limited.
Limitations
- He is a small model and makes mistakes. Check every specific value he gives against its source, and review every control stream and dataset change before you use it.
- He is weakest at naming the nlmx option that does a described job (0.30) and at fixing nlmx command lines (0.67).
Check those against
nlmx <command> --helpor the documentation. - His fine-tuning data are synthetic. Real datasets and unusual designs may be handled worse than the test set suggests.
- English only. Trained with conversations of up to 4,096 tokens.
How to use
The best results come from the system prompt he was trained with and greedy decoding.
Transformers (Python)
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "YOUR_USERNAME/maxson1"
tok = AutoTokenizer.from_pretrained(repo, subfolder="hf/lm")
model = AutoModelForCausalLM.from_pretrained(repo, subfolder="hf/lm", torch_dtype=torch.bfloat16)
system = ("You are Maxson (he/him), a senior clinical pharmacologist and pharmacometrician who works with nlmx. "
"You think through problems methodically: you state the question, plan the analysis in order, build and "
"QC NONMEM datasets and control streams, run and repair analyses in nlmx, and make judgement calls with "
"your reasons. You say plainly what you do not know before you suggest anything, and you never invent "
"numbers, references or results.")
messages = [{"role": "system", "content": system},
{"role": "user", "content": "Write a NONMEM control stream for a one-compartment oral model with "
"first-order absorption and a proportional plus additive error."}]
ids = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
out = model.generate(ids, max_new_tokens=900, do_sample=False)
print(tok.decode(out[0, ids.shape[1]:], skip_special_tokens=True))
llama.cpp
llama-cli -m gguf/nlmx-assistant-Q4_K_M.gguf -cnv
Ollama
cat > Modelfile <<'EOF'
FROM ./gguf/nlmx-assistant-Q4_K_M.gguf
PARAMETER temperature 0
SYSTEM """You are Maxson (he/him), a senior clinical pharmacologist and pharmacometrician who works with nlmx. You think through problems methodically: you state the question, plan the analysis in order, build and QC NONMEM datasets and control streams, run and repair analyses in nlmx, and make judgement calls with your reasons. You say plainly what you do not know before you suggest anything, and you never invent numbers, references or results."""
EOF
ollama create maxson1 -f Modelfile
ollama run maxson1
Browser (Transformers.js / ONNX Runtime Web)
onnx/lm/ is in the Transformers.js layout (config, tokenizer and onnx/model*.onnx). Transformers.js loads a
model from the root of a repository, so publish that folder as its own repository, for example
YOUR_USERNAME/maxson1-onnx. model.onnx is fp32, model_quantized.onnx is int8 and model_q4.onnx has 4-bit
weights.
Files
| Path | Contents |
|---|---|
hf/lm/ |
Maxson 1, safetensors (Transformers) |
hf/router/ |
Request router, a fine-tune of all-MiniLM-L6-v2 that sends a request to one of the nlmx workflows (safetensors) |
onnx/lm/ |
Maxson 1, ONNX (fp32, int8, 4-bit) |
onnx/router/ |
Request router, ONNX |
gguf/ |
Maxson 1, GGUF (f16, q8_0, Q4_K_M, Q5_K_M) for llama.cpp, Ollama and LM Studio |
ATTRIBUTION.csv |
The articles read in the literature stage, with their authors and licences |
Licence
Apache-2.0, the same as SmolLM2-1.7B-Instruct and all-MiniLM-L6-v2. The literature stage used only articles under
CC BY or CC0 licences; licence-restricted articles (NC, ND, SA) were not used. The articles are credited in
ATTRIBUTION.csv. nlmx itself is a separate program with its own licence.
Links
- nlmx: hyperpkpd.com