From 614a10a31cdad027014bc531d51efdbaf3250880 Mon Sep 17 00:00:00 2001 From: Xuan Date: Sat, 5 Oct 2024 17:23:06 -0400 Subject: [PATCH] Reorganize documentation. --- docs/README.md | 21 +- docs/make.jl | 1 - docs/pages.jl | 76 +-- docs/src/api/inference/map.md | 4 - docs/src/api/inference/mcmc.md | 19 - docs/src/api/inference/pf.md | 10 - docs/src/api/inference/vi.md | 7 - docs/src/api/model/gfi.md | 55 -- docs/src/api/model/trace_translators.md | 20 - docs/src/assets/header.css | 138 ---- docs/src/assets/header.js | 98 --- docs/src/assets/theme.css | 27 - docs/src/explanations/combinator_design.md | 9 - docs/src/how_to/custom_derivatives.md | 25 - docs/src/how_to/custom_distributions.md | 163 +++-- docs/src/how_to/custom_dsl.md | 16 - docs/src/how_to/custom_gen_fns.md | 83 +++ docs/src/how_to/custom_gradients.md | 56 ++ .../how_to/custom_incremental_computation.md | 7 +- docs/src/how_to/extending_gen.md | 12 + docs/src/how_to/how_to.md | 3 - docs/src/index.md | 83 +-- docs/src/ref/core/change_hints.md | 30 + .../{api/model => ref/core}/choice_maps.md | 8 +- .../src/{tutorials/basics => ref/core}/gfi.md | 61 +- .../src/{api/model => ref/core}/selections.md | 6 +- docs/src/{api => ref}/inference/importance.md | 1 + docs/src/ref/inference/map.md | 9 + .../mcmc_kernels.md => ref/inference/mcmc.md} | 33 +- .../inference}/parameter_optimization.md | 27 +- docs/src/ref/inference/pf.md | 37 ++ .../inference}/trace_translators.md | 31 +- docs/src/ref/inference/vi.md | 8 + docs/src/ref/inference/wake_sleep.md | 10 + .../internals}/language_implementation.md | 8 +- .../model => ref/modeling}/combinators.md | 20 +- docs/src/ref/modeling/custom_gen_fns.md | 29 + .../model => ref/modeling}/distributions.md | 71 +- .../model/modeling.md => ref/modeling/dml.md} | 135 +--- docs/src/ref/modeling/sml.md | 115 ++++ docs/src/tutorials/basics/combinators.md | 114 ---- docs/src/tutorials/basics/vi.md | 10 - .../getting_started.md} | 5 +- .../learning_gen_fns.md} | 10 +- .../tutorials/{basics => }/modeling_in_gen.md | 605 ++++++------------ docs/src/tutorials/reversible_jump.md | 0 .../scaling_with_sml.md | 68 +- .../{basics/particle_filter.md => smc.md} | 146 ++--- src/inference/map_optimize.jl | 1 - src/inference/particle_filter.jl | 20 +- src/modeling_library/modeling_library.jl | 7 +- 51 files changed, 1070 insertions(+), 1488 deletions(-) delete mode 100644 docs/src/api/inference/map.md delete mode 100644 docs/src/api/inference/mcmc.md delete mode 100644 docs/src/api/inference/pf.md delete mode 100644 docs/src/api/inference/vi.md delete mode 100644 docs/src/api/model/gfi.md delete mode 100644 docs/src/api/model/trace_translators.md delete mode 100644 docs/src/assets/header.css delete mode 100644 docs/src/assets/header.js delete mode 100644 docs/src/assets/theme.css delete mode 100644 docs/src/explanations/combinator_design.md delete mode 100644 docs/src/how_to/custom_derivatives.md delete mode 100644 docs/src/how_to/custom_dsl.md create mode 100644 docs/src/how_to/custom_gen_fns.md create mode 100644 docs/src/how_to/custom_gradients.md create mode 100644 docs/src/how_to/extending_gen.md delete mode 100644 docs/src/how_to/how_to.md create mode 100644 docs/src/ref/core/change_hints.md rename docs/src/{api/model => ref/core}/choice_maps.md (96%) rename docs/src/{tutorials/basics => ref/core}/gfi.md (93%) rename docs/src/{api/model => ref/core}/selections.md (94%) rename docs/src/{api => ref}/inference/importance.md (98%) create mode 100644 docs/src/ref/inference/map.md rename docs/src/{how_to/mcmc_kernels.md => ref/inference/mcmc.md} (97%) rename docs/src/{api/model => ref/inference}/parameter_optimization.md (64%) create mode 100644 docs/src/ref/inference/pf.md rename docs/src/{tutorials => ref/inference}/trace_translators.md (97%) create mode 100644 docs/src/ref/inference/vi.md create mode 100644 docs/src/ref/inference/wake_sleep.md rename docs/src/{explanations => ref/internals}/language_implementation.md (92%) rename docs/src/{api/model => ref/modeling}/combinators.md (87%) create mode 100644 docs/src/ref/modeling/custom_gen_fns.md rename docs/src/{api/model => ref/modeling}/distributions.md (88%) rename docs/src/{api/model/modeling.md => ref/modeling/dml.md} (75%) create mode 100644 docs/src/ref/modeling/sml.md delete mode 100644 docs/src/tutorials/basics/combinators.md delete mode 100644 docs/src/tutorials/basics/vi.md rename docs/src/{getting_started/linear_regression.md => tutorials/getting_started.md} (97%) rename docs/src/{api/inference/learning.md => tutorials/learning_gen_fns.md} (99%) rename docs/src/tutorials/{basics => }/modeling_in_gen.md (90%) delete mode 100644 docs/src/tutorials/reversible_jump.md rename docs/src/tutorials/{model_optimizations => }/scaling_with_sml.md (84%) rename docs/src/tutorials/{basics/particle_filter.md => smc.md} (91%) diff --git a/docs/README.md b/docs/README.md index 78ddd3f69..fcda114d5 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,17 +1,18 @@ -# Website Docs -- `pages.jl` to find skeleton of website. -- `make.jl` to build the website index. +# Gen.jl Documentation -The docs are divided in roughly four sections: +- `pages.jl` to find skeleton of the Gen.jl documentation. +- `make.jl` to build the documentation website index. + +The documentation is divided into three sections: - Getting Started + Tutorials - How-to Guides -- API = Modeling API + Inference API -- Explanations + Internals - +- Reference Guides # Developing -To build the docs, run `julia --make.jl` or alternatively startup the Julia REPL and include `make.jl`. For debugging, consider setting `draft=true` in the `makedocs` function found in `make.jl`. -Currently you must write the tutorial directly in the docs rather than a source file (e.g. Quarto). See `getting_started` or `tutorials` for examples. + +To build the docs, run `julia --make.jl`. Alternatively, start the Julia REPL, activate the `Project.toml` in this directory, then include `make.jl`. For debugging, consider setting `draft=true` in the `makedocs` function found in `make.jl`. This will avoid running the `@example` blocks when generating the tutorials. + +Currently you must write the tutorial directly in the docs rather than in a source file. See `tutorials` for examples. Code snippets must use the triple backtick with a label to run. The environment carries over so long as the labels match. Example: @@ -21,4 +22,4 @@ x = rand() ```@example tutorial_1 print(x) -``` \ No newline at end of file +``` diff --git a/docs/make.jl b/docs/make.jl index 92a7cd065..e7b6b45c3 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -8,7 +8,6 @@ makedocs( clean = true, warnonly = true, format = Documenter.HTML(; - assets = String["assets/header.js", "assets/header.css", "assets/theme.css"], collapselevel=1, ), sitename = "Gen.jl", diff --git a/docs/pages.jl b/docs/pages.jl index dc340eb7e..d6b1f6c4f 100644 --- a/docs/pages.jl +++ b/docs/pages.jl @@ -1,53 +1,45 @@ pages = [ - "Home" => "index.md", - "Getting Started" => [ - "Example 1: Linear Regression" => "getting_started/linear_regression.md", - ], + "Gen.jl" => "index.md", "Tutorials" => [ - "Basics" => [ - "tutorials/basics/modeling_in_gen.md", - "tutorials/basics/gfi.md", - "tutorials/basics/combinators.md", - "tutorials/basics/particle_filter.md", - "tutorials/basics/vi.md", - ], - "Advanced" => [ - "tutorials/trace_translators.md", - ], - "Model Optmizations" => [ - "Speeding Inference with the Static Modeling Language" => "tutorials/model_optimizations/scaling_with_sml.md", - ], + "Getting Started" => "tutorials/getting_started.md", + "Introduction to Modeling in Gen" => "tutorials/modeling_in_gen.md", + "Object Tracking with SMC" => "tutorials/smc.md", + "Learning Generative Functions" => "tutorials/learning_gen_fns.md", + "Speeding Up Inference with the SML" => "tutorials/scaling_with_sml.md", ], "How-to Guides" => [ - "MCMC Kernels" => "how_to/mcmc_kernels.md", - "Custom Distributions" => "how_to/custom_distributions.md", - "Custom Modeling Languages" => "how_to/custom_dsl.md", - "Custom Gradients" => "how_to/custom_derivatives.md", - "Incremental Computation" => "how_to/custom_incremental_computation.md", + "Extending Gen" => "how_to/extending_gen.md", + "Adding New Distributions" => "how_to/custom_distributions.md", + "Adding New Generative Functions" => "how_to/custom_gen_fns.md", + "Custom Gradients" => "how_to/custom_gradients.md", + "Custom Incremental Computation" => "how_to/custom_incremental_computation.md", ], - "API Reference" => [ + "Reference" => [ + "Core Interfaces" => [ + "Generative Function Interface" => "ref/core/gfi.md", + "Choice Maps" => "ref/core/choice_maps.md", + "Selections" => "ref/core/selections.md", + "Change Hints" => "ref/core/change_hints.md", + ], "Modeling Library" => [ - "Generative Functions" => "api/model/gfi.md", - "Probability Distributions" => "api/model/distributions.md", - "Choice Maps" => "api/model/choice_maps.md", - "Built-in Modeling Languages" => "api/model/modeling.md", - "Combinators" => "api/model/combinators.md", - "Selections" => "api/model/selections.md", - "Optimizing Trainable Parameters" => "api/model/parameter_optimization.md", - "Trace Translators" => "api/model/trace_translators.md", + "Built-In Modeling Language" => "ref/modeling/dml.md", + "Static Modeling Language" => "ref/modeling/sml.md", + "Probability Distributions" => "ref/modeling/distributions.md", + "Combinators" => "ref/modeling/combinators.md", + "Custom Generative Functions" => "ref/modeling/custom_gen_fns.md", ], "Inference Library" => [ - "Importance Sampling" => "api/inference/importance.md", - "MAP Optimization" => "api/inference/map.md", - "Markov chain Monte Carlo" => "api/inference/mcmc.md", - "MAP Optimization" => "api/inference/map.md", - "Particle Filtering" => "api/inference/pf.md", - "Variational Inference" => "api/inference/vi.md", - "Learning Generative Functions" => "api/inference/learning.md" + "Importance Sampling" => "ref/inference/importance.md", + "Markov Chain Monte Carlo" => "ref/inference/mcmc.md", + "Particle Filtering & SMC" => "ref/inference/pf.md", + "Trace Translators" => "ref/inference/trace_translators.md", + "Parameter Optimization" => "ref/inference/parameter_optimization.md", + "MAP Optimization" => "ref/inference/map.md", + "Variational Inference" => "ref/inference/vi.md", + "Wake-Sleep Learning" => "ref/inference/wake_sleep.md", ], + "Internals" => [ + "Modeling Language Implementation" => "ref/internals/language_implementation.md", + ] ], - "Explanation and Internals" => [ - "Modeling Language Implementation" => "explanations/language_implementation.md", - "explanations/combinator_design.md" - ] ] diff --git a/docs/src/api/inference/map.md b/docs/src/api/inference/map.md deleted file mode 100644 index fcd1ba880..000000000 --- a/docs/src/api/inference/map.md +++ /dev/null @@ -1,4 +0,0 @@ -# MAP Optimization -```@docs -map_optimize -``` diff --git a/docs/src/api/inference/mcmc.md b/docs/src/api/inference/mcmc.md deleted file mode 100644 index bd6df6d00..000000000 --- a/docs/src/api/inference/mcmc.md +++ /dev/null @@ -1,19 +0,0 @@ -# Markov chain Monte Carlo (MCMC) - -Gen supports standard Markov Chain Monte Carlo algorithms and allows users to write their own custom kernels. -```@index -Pages = ["mcmc.md"] -``` - -```@docs -metropolis_hastings -mh -mala -hmc -elliptical_slice -@pkern -@kern -@rkern -reversal -involutive_mcmc -``` diff --git a/docs/src/api/inference/pf.md b/docs/src/api/inference/pf.md deleted file mode 100644 index a356a76d9..000000000 --- a/docs/src/api/inference/pf.md +++ /dev/null @@ -1,10 +0,0 @@ -# Particle Filtering -```@docs -initialize_particle_filter -particle_filter_step! -maybe_resample! -log_ml_estimate -get_traces -get_log_weights -sample_unweighted_traces -``` diff --git a/docs/src/api/inference/vi.md b/docs/src/api/inference/vi.md deleted file mode 100644 index 4d55fb43c..000000000 --- a/docs/src/api/inference/vi.md +++ /dev/null @@ -1,7 +0,0 @@ -## Variational inference -There are two procedures in the inference library for performing black box variational inference. -Each of these procedures can also train the model using stochastic gradient descent, as in a variational autoencoder. -```@docs -black_box_vi! -black_box_vimco! -``` diff --git a/docs/src/api/model/gfi.md b/docs/src/api/model/gfi.md deleted file mode 100644 index 0385988be..000000000 --- a/docs/src/api/model/gfi.md +++ /dev/null @@ -1,55 +0,0 @@ -## [Generative Functions](@id gfi_api) - -```@docs -GenerativeFunction -Trace -``` - -The complete set of methods in the generative function interface (GFI) is: - -```@docs -simulate -generate -update -regenerate -get_args -get_retval -get_choices -get_score -get_gen_fn -Base.getindex -project -propose -assess -has_argument_grads -has_submap -accepts_output_grad -accumulate_param_gradients! -choice_gradients -get_params -``` - -```@docs -Diff -NoChange -UnknownChange -SetDiff -Diffed -``` - -```@docs -CustomUpdateGF -apply_with_state -update_with_state -``` - -```@docs -CustomGradientGF -apply -gradient -``` - -```@docs -Gen.init_update_state -Gen.apply_update! -``` \ No newline at end of file diff --git a/docs/src/api/model/trace_translators.md b/docs/src/api/model/trace_translators.md deleted file mode 100644 index 14de30ec9..000000000 --- a/docs/src/api/model/trace_translators.md +++ /dev/null @@ -1,20 +0,0 @@ -## Trace Translators - -```@docs -@transform -@read -@write -@copy -@tcall -pair_bijections! -is_involution! -inverse -TraceTranslator -DeterministicTraceTranslator -GeneralTraceTranslator -SimpleExtendingTraceTranslator -SymmetricTraceTranslator -``` -```@docs -TraceTransformDSLProgram -``` diff --git a/docs/src/assets/header.css b/docs/src/assets/header.css deleted file mode 100644 index 155b10a3b..000000000 --- a/docs/src/assets/header.css +++ /dev/null @@ -1,138 +0,0 @@ - -@media all and (max-width: 560px) { - header.navigation { - position: fixed !important; - left:0; - top: 0; - width: 100%; - } - - header.navigation div.container { - margin-left: 0rem; - } - - header.navigation div.container nav.navbar { - min-height: 1rem !important; - } - - header.navigation div.container nav.navbar ul.navbar-nav { - min-height: 1rem !important; - margin-left: 0.5rem !important; - } - - header.navigation div.container nav.navbar ul.navbar-nav li.small-item { - visibility: visible !important; - display: block !important; - margin: 0.5rem; - } - - header.navigation div.container nav.navbar ul.navbar-nav li.nav-item { - visibility: hidden; - display: none; - } - - header.navigation div.container nav.navbar ul.navbar-nav li.nav-item a { - visibility: hidden; - display: none; - } - - html:not(.theme--documenter-dark) body #documenter .docs-main { - margin-top: 2rem !important; - } -} - -@media all and (max-width: 1055px) and (min-width: 561px){ - header.navigation { - position: fixed !important; - left:0; - top: 0; - width: 100%; - } - - header.navigation div.container { - margin-left: 0rem; - } - - header.navigation div.container nav.navbar ul.navbar-nav { - width: 80% !important; - } -} - -@media all and (min-width: 1056px) { - header.navigation { - position: fixed !important; - left:0; - top: 0; - width: 100%; - } - - header.navigation div.container { - margin-left: 18rem; - } - -} - -html.theme--documenter-dark header.navigation { - background-color: #1f2424 !important; -} - -html.theme--documenter-dark header.navigation div.container { - border-bottom: 1px solid #5e6d6f; -} - -html.theme--documenter-dark header.navigation div.container nav.navbar { - background-color: #1f2424 !important; -} - -html.theme--documenter-dark header.navigation div.container nav.navbar ul.navbar-nav li.nav-item a.nav-link { - color: white; - transition: color 100ms; -} - -html.theme--documenter-dark header.navigation div.container nav.navbar ul.navbar-nav li.nav-item a.nav-link:hover { - color: #0aa8a7 -} - -html header.navigation { - background-color: white !important; -} - -html header.navigation div.container { - border-bottom: 1px solid #dbdbdb; -} - -html header.navigation div.container nav.navbar ul.navbar-nav li.nav-item a.nav-link { - color: #222; - transition: color 100ms; -} - -html header.navigation div.container nav.navbar ul.navbar-nav li.nav-item a.nav-link:hover { - color: #0aa8a7 -} - -header.navigation { - z-index: 3; -} - -header.navigation div.container nav.navbar ul.navbar-nav { - margin-left: 4rem; - min-height: 3.25rem; - width: 70%; - display: flex; - align-self: auto; - flex-direction: row; - justify-content: space-around; -} - -header.navigation div.container nav.navbar ul.navbar-nav li.nav-item { - align-self: stretch; - align-content: space-around; - justify-content: center; - display: flex; - flex-direction: column; -} - -header.navigation div.container nav.navbar ul.navbar-nav li.small-item { - visibility: hidden; - display: none; -} \ No newline at end of file diff --git a/docs/src/assets/header.js b/docs/src/assets/header.js deleted file mode 100644 index 2f211b385..000000000 --- a/docs/src/assets/header.js +++ /dev/null @@ -1,98 +0,0 @@ -// Source: -// https://github.com/ReactiveBayes/RxInfer.jl/blob/246b196a3ea29d0b5744ce241a923c7a3b30eaf4/docs/src/assets/header.js#L4 - -// We add a simple `onload` hook to inject the custom header for our `HTML`-generated pages -window.onload = function() { - //