Why rietx?
rietx

Why rietx?

I started doing powder diffraction work in 2007. During my PhD I used Rietica, a Rietveld engine rarely used now. The appeal was its rudimentary scripting engine, RietBASIC, that let me script refinements for variable-temperature datasets. Soon afterwards, I learned Python to wrangle more complicated datasets.

Around 2021, I started to build and train machine learning models. What struck me was the pace of progress enabled by the openness in that field: new ideas on arXiv, not paywalled journals; open-source libraries like scikit-learn, TensorFlow, and PyTorch one terminal command away; model weights shared on Hugging Face.

Vast edifices of the modern scientific enterprise are built on specialised data analysis software. They represent the distillation of years of expertise, often written and maintained as passion projects by poorly paid academics in their spare time. They can lack polish and adherence to industry best practices, but are still essential.

In the past, academia has rarely been able to compete with industry for software engineering talent. However, we’ve suddenly reached a situation where high-quality software engineering is available on tap. At the same time, using language models and agents to analyse data has become central to many researchers’ day-to-day work. rietx is an experiment in how we develop scientific software in this new world—both with AI agents, and for them.

The shape of rietx is inspired by open-source efforts in the computer science community. It has a well-documented API that follows common Python idioms. It can be installed in seconds on Linux, Mac or Windows. It has an extensive test suite and runs CI with validation on real data. It’s MIT licensed.

I believe what sets rietx apart from most scientific software is that it’s designed from the ground up for working scientists to easily control with natural language via AI coding agents. That means token efficiency (read: you can do many refinements within a standard AI subscription plan quota) and standard harnesses (e.g. Claude Code, Codex, Copilot, pi).

How does rietx achieve this? Firstly, output interpretability. Rietveld practitioners compare model and data by eye to judge a fit, not just by using numerical metrics. Standard Rietveld engines provide outputs made for the human eye, so an agent has to burn more tokens to really understand what’s going on (if it can at all).

Without using tokens, rietx creates a FitReport after each refinement: a structured list of annotated numerical proxies and suggested actions covering a large number of human expert heuristics. Reflecting the ideas of universal design, some users note that the FitReport is also very useful in guiding manual usage.

Secondly, the rietx agent skill. Skills in AI parlance are simply bundles of text documents that provide instructions on a specific task; agents can install them automatically. The rietx skill is written alongside the rietx source code and anchored on a large corpus of peer-reviewed literature. It explains to an agent how to use rietx to do high-quality refinements and avoid pitfalls.

Asking an agent to first learn how to do Rietveld refinement every time you want to use it is expensive and mostly unverified. We pay everyone’s tab for this up front via the agent skill. This allows users to use cheaper, lower-strength models for routine tasks with confidence, and run frontier models for longer on difficult problems.

This leads to what I believe is a difference of ethos in the development of rietx compared to most other AI approaches to powder diffraction analysis: there is a clear separation between refinement engine and AI models. While other approaches strengthen the AI side, we strengthen the engine. This means that the ability to solve complex refinement problems scales with the improvement of AI models. In our testing, current frontier models using rietx can, for example, refine complex sequential multi-phase datasets. I imagine in time, almost all use cases could be addressed with little human intervention.

My hope is that combining these elements will democratise the usage of autonomous Rietveld analysis in a way that empowers individual scientists. Moreover, I think that this is a template for future development of scientific software.

Thank you for your interest! If you try rietx, I’d love to hear how it goes. Drop me a line at yue@rietx.org

—Yue