Documentation

3.7 Ask Maxson, and where to go next

Everything in this chapter was done by typing commands. nlmx also has an assistant, Maxson, which turns a request in plain words into the same commands, runs them once you agree, and reports. This section shows one short session, gives the time budget of the tour, and points to the rest of the book.

3.7.1 One request to Maxson

Maxson needs a language model. The tests of the program use a scripted stand-in, the mock backend, which replays prepared replies; it is a rehearsal of the mechanism and not a model, so it is what this section uses. (Chapter 34 sets up a real model: a GGUF file in the embedded build, or a local model server.)

nlmx ask --llm-backend mock --llm-script replies.json "check the data" --yes -o out_ask

replies.json holds two replies: one that asks for a qc-data run, and one that sums up. --yes lets Maxson run the commands it proposes without asking each time; without it, each command waits for your answer. Maxson began by listing what it found in the folder (the datasets, with their record and subject counts and the candidate covariates; the control streams) and then did what was asked:

Maxson: Hello, I'm Maxson, the assistant built into nlmx 4.2.1.
        I turn what you ask in plain words into nlmx commands … run them once you say yes, read the results and report back.
        … I can only run nlmx commands, every result goes into a new session folder, and I never change your own files.

        Datasets I found:
          • data/analysis.csv — 2,200 records, 200 subjects, 200 dose records, 2,000 observations, possible covariates WT, SEX, EGFR, CRCL
          …
        You asked: “check the data”. Let's get started.
Maxson: I will check the dataset first.
  ✎ settings file out_ask/01_qc-data.qcd (the template of `nlmx qc-data`, its defaults)
  ▸ nlmx qc-data -c out_ask/01_qc-data.qcd data/analysis.csv --output out_ask/01_qc-data  (data check)
    │ … the console listing of qc-data, as in Section 3.2 …
    done in 0.8 s → out_ask/01_qc-data
Maxson: The dataset has 200 individuals and no failing checks; it is ready with warnings.

(The listing shortens the paths, which are absolute in the real output.) Three things are worth seeing. The command that Maxson ran is an ordinary nlmx command, shown in full: you can copy it and run it yourself. The settings file it wrote is the one you would have written, saved in the session folder. And the folder ends with three files:

File Content
transcript.md the conversation
commands.txt the commands that ran, to rerun without the assistant
ask_log.jsonl the audit log of the session

That is the design: the assistant is a front end, and what it does can be reproduced without it (Chapter 34 says what it is allowed and not allowed to do). Because the reply was scripted, nothing here says how a real model would judge your data; its text must be read as any other tool's.

3.7.2 The time budget of the tour

Table 3.7.1. Run time of each step on the demo project (Linux, two cores, release build without the embedded model).

Step Command Seconds
1 generate 2.6
2 inspect < 0.1
3 qc-data 0.8
4 qc-nm 0.1
5 eda 2.8
6 nca 2.5
7 autoinit 1.6
8 screen 30.3
9 fit (run101) 1.6
10 cov 5.7
11 vpc (base model) 0.7
12 sims 0.3
13 fit (run102) 4.2
14 forest 0.1
15 power (FIM) 0.1
16 power (SSE, 20 replicates, two sample sizes) 76.7

Everything but the screen and the SSE takes about 23 seconds in all; the whole table adds up to about two minutes and a quarter. The times belong to this dataset (200 subjects, 2,000 observations, one compartment) and this computer: a model with more compartments, an ODE system or a dataset ten times larger takes longer, and Chapters 9 and 20 says how much, and how to use threads.

3.7.3 The tour as a script

The tour, less the slow SSE run and the Maxson session, is one script, tour.sh, in the folder documents/ of this book (Example 3.1). It runs 15 commands in the order of this chapter and, after each step, checks one line that the chapter quotes (the verdict of qc-data, the base OFV, the final OFV, the 2 of 60 percentiles), ending with "all checkpoints passed" when your build reproduces them.

NLMX=/path/to/nlmx bash documents/tour.sh      # NLMX defaults to `nlmx` on the PATH; the work is done in ./tour_demo

The script creates (and replaces) the folder tour_demo, so run it where that is harmless. If a checkpoint fails, it stops and names the step. The checkpoints compare text, so they are tied to version 4.2.1; a later version may print other digits, and the script says so in its first lines.

3.7.4 Where to go next

The tour used 15 of the 22 commands, in the order of a typical project. The rest of the book takes the same path in depth.

If you want to… Go to
understand how the program behaves (folders, seeds, exit codes, options) Chapter 4, next
learn the data checks and exploratory tools in depth Part II (Chapters 5 to 10)
learn the models and the estimation Parts III and IV
select covariates, evaluate and simulate Parts V and VI
use the exposure-response, the assistant or the study simulation the later parts
look up an option, a file or an error the reference chapters and appendices

Common mistakes

  • Reading the OFV of two models fitted to different datasets as comparable. The base and the covariate model here use the same 2,000 observations; a difference of 259.5 means something only because of that.
  • Taking the draft control stream of cov as the final model. It is a draft, marked unconfirmed; the run102 fit is the confirmation.
  • Reading 20 SSE replicates as a power estimate. The interval (0.70 to 0.97) is the answer to "how sure", and it is wide.
  • Starting a second run in a folder that already has results. nlmx refuses (exit 3); give a new folder or --overwrite (Section 4.2).
  • Trusting a mock Maxson session as a model's opinion. It replays a script.

Checklist

  • nlmx version shows 4.2.1 (or the version you intend).
  • generate made the demo project; qc-data says ready with warnings with the four warnings of Section 3.2.
  • fit of run101 ends at OFV −2880.2130 and cov at −3139.705.
  • The pcVPC of run101 shows 46 of 60 percentiles outside, that of run102 shows 2 of 60.
  • bash documents/tour.sh (with NLMX set) ends with "all checkpoints passed".

Further reading

  • Chapter 4 for the behaviour shared by every command; Chapter 2 for the installation and the licence.
  • docs/COMMANDS.md of the program, for the options of each command.
  • The files in the output folders themselves: every command lists them at the end of its listing.