Spec file

The declarative spec format that describes a model, its data, and the sampler.

A spec file declares a complete inference job: the backend, the model, the sampler, the data, and a seed. TOML is the primary format; JSON is also accepted. The spec is validated with zod before anything runs.

A complete example

schema_version = "0"
seed = 42

[backend]
id = "turing"

[model]
kind = "file"
path = "./model.jl"
entry = "build_model"

[sampler]
algorithm = "NUTS"
draws = 1000
warmup = 1000
chains = 4
adapt_delta = 0.8

[data]
N = 10
x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
y = [5.2, 7.7, 11.1, 13.8, 17.4, 19.9, 23.3, 25.6, 29.2, 31.8]

Fields

Top level

FieldTypeRequiredNotes
schema_versionstringyesmust be "0" today
seedintegeryes0 to Number.MAX_SAFE_INTEGER, bounded so it survives JSON without precision loss

[backend]

FieldTypeDefaultNotes
id"turing" | "juliabugs" | "stan"requiredthe probabilistic-programming backend
runtime"julia" | "cmdstan"per backend"julia" for turing and juliabugs, "cmdstan" for stan
versionstringper runtimeJulia: the juliaup channel to run, e.g. "1.12.6" (default: the toolchain’s pinned channel); Stan: a CmdStan version, e.g. "2.39.0", or "installed" (the default), which resolves the newest local CmdStan
packagestable of name to versionoptionalJulia-only: version pins for managed Julia packages, e.g. Turing = "0.45"

Pinned packages provision into their own managed environment, so different pins can be compared without interfering.

[model]

FieldTypeDefaultNotes
kind"file"requiredonly file-based models today
pathstringrequiredpath to the model file, resolved relative to the spec’s directory
entrystring"build_model"the model entry function (Julia backends; ignored for Stan)

[sampler]

FieldTypeDefaultNotes
algorithm"NUTS""NUTS"the sampler
drawspositive integerrequiredposterior draws per chain
warmupnon-negative integer1000warmup iterations
chainspositive integer4number of chains
adapt_deltanumber in (0, 1)0.8NUTS target acceptance rate

Data

Provide data inline or by reference, but not both.

FieldTypeNotes
[data]tableinline data, keyed by variable name
data_filestringpath to a .csv or .json data file, relative to the spec’s directory

data_file records the reference (path plus hash), not the contents, so large datasets are not copied into the spec or the run store.

[output]

FieldTypeDefaultNotes
format"mcmcchains-json""mcmcchains-json"the samples-file format written

[predict]

Optional; used by mcmc predict.

FieldTypeNotes
targetsarray of strings (at least one)outcome variables to predict, by base name; Turing blanks each to missing, Stan keeps the matching generated quantities
datatableoptional data overrides applied on top of [data] for the prediction
[predict]
targets = ["y"]

JSON form

The same spec as JSON:

{
  "schema_version": "0",
  "seed": 42,
  "backend": { "id": "turing" },
  "model": { "kind": "file", "path": "./model.jl", "entry": "build_model" },
  "sampler": { "algorithm": "NUTS", "draws": 1000, "warmup": 1000, "chains": 4, "adapt_delta": 0.8 },
  "data": {}
}

A Stan example

The same schema drives the Stan backend.

schema_version = "0"
seed = 42
data_file = "./data.json"

[backend]
id = "stan"

[model]
kind = "file"
path = "./model.stan"

[sampler]
algorithm = "NUTS"
draws = 1000

[predict]
targets = ["y_rep"]

version defaults to "installed", the newest local CmdStan; a concrete version such as "2.39.0" pins it. For Stan, [predict].targets selects which generated quantities to keep, and the model must declare them in a generated quantities block.

The schema_version lets the format evolve without silently breaking consumers. A spec with an unknown version is rejected rather than misread.