Inspiration

When I was an aspiring medical doctor doing my master's thesis I first encountered pharmacometrics - pharmacological modelling and simulation. I quickly realised the field's tremendous potential: extracting knowledge from clinical data, improving clinical-trial design, and optimising treatment for individual patients. However, the pharmacometrics software landscape was and continues to be fragmented across closed-source commercial platforms and less efficient tools operating in separate environments, without a unified design philosophy or easy-to-use interfaces. Over the years since my master thesis, I learned the algorithms and techniques underpinning these tools. I developed an understanding of what needed to change, and how to do it. Since then, I started to develop prototype code to address their shortcomings. These prototypes worked well but were relatively limited in their scope, and my regular work and daily responsibilities did not allow me to develop these prototypes into full software suites. More recently I started to test out coding with LLMs, and over the past few weeks I have used AI to extend these prototypes into LibeR: a free, open-source ecosystem designed to combine scientific capability with intuitive workflows, high performance, security, and enterprise-oriented software design.

What it does

LibeR provides a family of applications that aim to make model building workflows, optimal study design and individualised treatment easier by providing a wide selection of established algorithms built into easy-to-use but feature-rich interfaces that can easily be adapted to local requirements. LibeR (currently) consists of 6 packages:

  • LibeRtAD provides the core automatic-differentiation and numerical infrastructure that enables the other packages.
  • LibeRation supports pharmacometric model development, parameter estimation, simulation, diagnostics, and workflow management.
  • LibeRality supports optimal clinical-trial and experimental design.
  • LibeRator provides model-informed adaptive therapeutic optimisation
  • LibeRary searches the scientific literature and uses large language and vision-language models to identify, extract, validate, and catalogue published pharmacometric models.
  • LibeRties provides persistent local and remote job queues for secure, scalable model execution.

Together, these packages create a connected workflow in which models can be discovered in the literature, implemented and estimated, used to optimise study designs, and ultimately translated into individualised treatment recommendations.

By exposing the complex underlying algorithms in convenient GUIs, the bar for adoption and implementation of these algorithms is lowered, while power users retain the option to tweak algorithms to their needs either through GUI-exposed configurations or R-script level function arguments. In addition, due to the efficient engines under the hood, these packages provided results faster, allowing for less time spent on model runs and more time on development and deployment of model-informed drug development or clinical implementation. Finally, the large model repository that is being created with LibeRary will provide a significant source for established models, which may be used for simulations, or could be integrated for further model and data synthesis.

How I built it

LibeR is built around LibeRtAD, which provides efficient automatic differentiation from R through direct integration with CppAD and Eigen, while its computationally intensive numerical engines run in C++. LibeRation includes specialised analytical propagators for common one-, two-, and three-compartment pharmacokinetic models, alongside solvers for ordinary, differential-algebraic, delayed, and stochastic differential equations. It also supports Markov and hidden Markov models, time-to-event models, nonlinear mixed-effects estimation, and more complex models used in quantitative systems pharmacology and physiologically based pharmacokinetics. The graphical interfaces combine Shiny and React to deliver browser-based applications that can run directly within a user's local R environment or be deployed through a remote server. For remote execution, LibeRties is designed to operate behind HTTPS/TLS and encrypted host storage. Authentication uses cryptographically random 256-bit bearer tokens, of which only SHA-256 digests are retained. Jobs are submitted through non-executable typed contracts and run in fresh R worker processes with scrubbed environments, per-user namespaces, and isolated per-job working directories. Configurable limits govern runtime, CPU and memory use, payload and result sizes, queue length, and storage, while SHA-256 checksums verify payload and result integrity. Production deployments can add dedicated operating-system accounts or containers for stronger host-level isolation.

Challenges I ran into

I initially expanded my proof-of-concept code using several other LLMs. This worked reasonably well for early development, but progress stalled as the numerical engine and its algorithms became more complex and the other LLMs could not cope. I subsequently restarted the architecture using GPT-5.6 Sol. It produced working first-pass implementations of much of the core infrastructure and required considerably less hand-holding when implementing advanced algorithms. This allowed the project to progress much further and much faster than I had initially thought possible. The greatest continuing challenge is the user interface. Even with browser-based inspection and stress-testing, subtle performance problems and mismatches between intended and actual behaviour can remain difficult for an LLM to identify independently. Consequently, much of my time is now spent refining the human-facing experience and ensuring that complex modelling workflows remain intuitive, responsive, and reliable.

Accomplishments that I'm proud of

The LibeR ecosystem now spans all relevant functionality provided by individual pharmacometric tools across the pharmacometric landscape. It provides a coherent, free, and open-source workflow spanning model discovery, development, estimation, simulation, optimal design, therapeutic optimisation, and distributed execution. Seeing LibeR perform so efficiently, and receiving positive feedback from earlier adopters at University College London (UCL), has validated the ideas I first developed during my master thesis. It has been rewarding seeing my early proof of concept code evolve into a functional, enterprise-level software ecosystem within only a few weeks of working with GPT-5.6 Sol.

What I learned

My initial scepticism regarding the use of LLMs for such an ambitious project has been replaced with enthousiasm for exploring other ideas I have that could benefit from LLM-supported development. Given the complexity and expansive nature of LibeR, it would not have been feasible for me to implement its functionality to its current degree without the aid of an LLM. I also learned that LLMs do not remove the need for human expertise. Instead, they shift much of the work towards architecture, scientific verification, validation, usability, and deciding what the software should ultimately become.

What's next for LibeR

The immediate next milestone is a WebAssembly-enabled package, extending LibeR towards secure, portable, browser-native execution. In addition, LLM integration in model run evaluation through LibeRation's Help function and Report builder function will be further refined, including distillation of fit-for-purpose SLMs.

LibeR's numerical algorithms have already been benchmarked and cross-validated against established tools including NONMEM, PopED, and PFIM for a range of representative use cases. In collaboration with early adopters at UCL, the ecosystem will now be applied to real modelling workflows to uncover bugs, stress-test performance, and broaden its validation base. Further optimisation, documentation, testing, and deployment hardening will lay the groundwork for the longer-term goal: establishing LibeR as a leading open pharmacometrics platform suitable for academic, industrial, regulatory, and eventually clinical environments.

Built With

Share this project:

Updates