Parse and convert stan code to a generalized format

I am a Python user trying to compare my library code with stan. Is there an obvious way to parse stan code and get all the relevant information automatically in such a way so that I can convert all the logic (e.g. parameter names, size, constraints) automatically in my Python code?

P.S.: I am also a GSoC 2022 contributor with TensorFlow and I am willing to create an open-source parser if I get some tips and support from the developers of stan.

I guess you want to have a look at the stan transpiler that is generating c++ code from stan model: GitHub - stan-dev/stanc3: The Stan transpiler (from Stan to C++ and beyond).

Edit: you can also check : GitHub - stan-dev/stan2tfp: Stan2TFP is a work-in-progress alternative backend for Stanc3 which targets TensorFlow Probability which generate TF code from stan model

1 Like

I suggest that you look at the YAPS project - GitHub - IBM/yaps: A surface language for programming Stan models using python syntax
It’s a system which translates Python code to Stan.

3 Likes

It also translates Stan to their Python representation, which is a neat feature, though it is probably outdated by now, given last commit is 4 yo.

There is also a fork at GitHub - deepppl/stanc3: Rewriting the Stan compiler in OCaml which targets Pyro/NumPyro (by @louis-mandel)

1 Like