How can I access to model information in CmdStan?

I’m developing a CmdStan interface for Rust (see: orzAtalod/simple-cmdstan-rs; it’s still a work in progress). After getting some basic transformations working, I’m now aiming to build a more powerful and user-friendly interface.

One of the first challenges I’ve encountered is how to access the free parameters and data types defined in a Stan model. With this information, I could implement better argument checking and overall validation in Rust.

So my question is: Is there a way to access this kind of metadata directly via CmdStan, without having to manually parse the .stan file?

the Stan compiler can output some of this as a JSON if passed the —info flag

You may find Rust interface for CmdStan by andrewjradcliffe · Pull Request #51 · stan-dev/design-docs · GitHub GitHub - andrewjradcliffe/cmdstan-rs: Rust interface for CmdStan interesting

Thanks! This link is really inspiring. Are there any existing works on building a Rust interface for CmdStan?

Sorry for repeating reply this message — I’m still not very familiar with this forum.

I don’t know of any besides GitHub - andrewjradcliffe/cmdstan-rs: Rust interface for CmdStan

A lot of the interest in Stan in Rust has been around not using Stan’s algorithms, e.g. the nuts-rs project (which you can plug Stan models into using BridgeStan)

1 Like

I thought that was nutpie-rs, but Brian’s right, it’s nuts-rs.

This is technically an implementation of @aseyboldt’s Nutpie, not the vanilla and chocolate NUTs we have in Stan (we moved from slice sampling to multinomial sampling and added more granularity to U-turn conditions and also added a lot of adaptation to what was in the original paper). From everything I can see, Nutpie’s adaptation is better than Stan’s. After adaptation, I believe they use the same version of NUTS—the multinomial sampling one (though I don’t know if Adrian caught the more granular U-turns, which look a bit like his more granular Phase II adaptation).

1 Like