Examples Gallery¶
Start with a regression or a two-group comparison. The gallery then moves through models that share parameters, infer latent variables, or sum over state paths. The examples that combine parsing, semantics, and inference come last.
Choose a first example¶
Bayesian linear regression introduces coefficients, observations, and posterior draws. The Beta-Binomial A/B test estimates conversion rates in two arms. Try partial pooling when several groups share information, or a Gaussian mixture when several components can generate a response.
The conceptual introduction defines the probability and composition vocabulary used here. The checked model fitting tutorial shows how QVR source determines the inputs, observation roles, and dimensions of a model.
Regressions and A/B tests¶
- Bayesian Linear Regression: Normal likelihood with Normal-prior coefficients and a HalfCauchy noise scale, recovered by SVI (stochastic variational inference) and NUTS (No-U-Turn Sampler).
- Beta-Binomial A/B Test: per-arm Beta-Binomial conversion counts.
- Linear Regression with Logistic Noise: Logistic observation noise in place of Normal.
- Multi-Output Beta Regression: Beta response on the unit interval with a logit-link mean and a per-output precision.
- Gamma Regression: log-link Gamma GLM with a per-category intercept, slope, and shape.
- Bounded-Outcome Regression via Kumaraswamy: a Kumaraswamy likelihood for a response on the unit interval.
- Multi-Output Negative Binomial Regression: the NB2 model, with a log-link mean and a per-output dispersion.
- Weibull Survival Regression: a proportional-hazards Weibull model with right-censored follow-up, censored rows scored by their survival function.
Grouped and latent-variable models¶
- Parametric Partial Pooling: Rubin's parallel-experiments model through a program template, with a labeled return tuple and export selection.
- Hierarchical regression with a HalfStudentT scale prior: group intercepts with heavy-tailed priors on both scales.
- Horseshoe Sparse Regression: dense multiple regression whose coefficients carry the horseshoe's global-local shrinkage, recovering a sparse truth.
- Bayesian Gaussian Mixture Model: mixing weights, locations, and scales inferred under a closed-form mixture likelihood.
- Multi-output zero-inflated Poisson regression: a logistic regression for the structural-zero probability and a log-linear one for the rate, with the zero branch marginalized exactly.
- Correlation-Matrix Prior via LKJCholesky: an LKJ prior over a correlation matrix's Cholesky factor.
- Probabilistic Principal Component Analysis: the factor model with one isotropic noise scale, checked against its principal-subspace solution.
- Bayesian Factor Analysis: latent factors and loadings with a free uniqueness per observed coordinate.
- Two-Parameter Logistic IRT: respondent abilities with item difficulties and positive item discriminations.
- Probabilistic Matrix Factorization: low-rank Bayesian completion of a sparse rating matrix, evaluated on held-out ratings.
- Latent Dirichlet Allocation: one topic per token, summed out exactly. Checked against a per-token mixture and separated from a document-level one.
- Vowel Inventories fits a determinantal distribution over discrete subsets of vowels.
- Tree-Structured Categorical Model: class probabilities from a binary tree of splits, with per-verb random effects on each split.
- Language Modeling Difficulty estimates language and intent effects from partly aligned sentence surprisals.
State-space and time-series models¶
- AR(1) Time Series: the first-order autoregressive model under its likelihood conditional on the first observation.
- Bayesian Change-Point Detection: a Poisson rate switching at a discrete change point that is marginalized exactly.
- Hidden Markov Model: a discrete chain summed out by the forward algorithm, checked against path enumeration and fitted by maximum likelihood.
- Linear-Gaussian State-Space Model: a scanned state path whose NUTS posterior matches the Rauch-Tung-Striebel smoother.
- Stochastic Volatility: a coupled log-volatility path from a stationary start. The joint is checked, parameter recovery is not demonstrated.
- Continuous State-Space Model: a Gaussian Markov chain with state-dependent noise, whose posterior mode matches the smoother at linear-Gaussian weights.
- Finite-State Dirichlet Allocation fits separate document transition matrices under a shared prior.
- Deep Markov Model: network-parameterized transition and emission kernels threaded by a scan. The joint is checked, inference is not demonstrated.
- Path-Dependent Particle Smoothing samples recurrent alignment paths with an observed-suffix proposal.
Neural and language models¶
- Bayesian Neural Network: a one-hidden-layer tanh regression network whose weights are sample sites.
- Vanilla RNN Language Model: an Elman network with learned weights, scoring the next token at every position.
- Stacked RNN Language Model: a second recurrent layer reading the trajectory the first scan returns.
- GRU Language Model: learned reset and update gates with the reset gate inside the candidate.
- LSTM Language Model: learned input, forget, and output gates with the hidden and cell states threaded together.
- Bidirectional RNN Language Model: a forward scan that scores each next token and a reversed scan that scores each previous one, with sampled weights.
- Variational Autoencoder: a neural decoder fitted with an amortized encoder guide.
- Bilinear Tensor Contraction: neural-tensor-layer scoring of predicate-argument pairs through an operadic three-way contraction.
- Causal Transformer Language Model: one pre-LN block of two-head causal self-attention, checked by hand and fitted on a task that needs attention.
- Sequence-to-Sequence Transformer: encoder self-attention, causal decoder self-attention, and cross-attention over fixed windows, with Bayesian weights.
Weighted parsing¶
- Probabilistic Context-Free Grammar: a normalized grammar fitted by maximum likelihood and, with Dirichlet priors, sampled against its conjugate posterior.
- Custom Sequent Rules: an AB grammar with harmonic composition declared as sequents in the DSL.
- Weighted Combinatory Categorial Grammar: forward and backward application, harmonic and crossed composition, each needed by some sentence of the lexicon.
- Schema-Bundled Chart Parser: pattern-polymorphic rule schemas bundled into a differentiable CKY chart parser.
- Type-Logical Grammar (Lambek calculus): a chart parser whose every rule is a theorem of the associative Lambek calculus.
- Weighted Multiple Context-Free Grammar: rank-2 nonterminals deriving Swiss German cross-serial verb clusters.
- Multimodal Type-Logical Grammar: the Lambek calculus with residuated diamond and box modalities and one controlled structural postulate.
- Variational Information Bottleneck for Parsing learns noisy token representations with a projective dependency parser and analytic Gaussian KL penalties.
String models and morphology¶
- A Noisy Deletion Channel computes the posterior mean of the source length from the surviving symbols. The source length has no fixed upper bound.
- A Contextual Edit Channel learns edit probabilities from the input context by summing the alignments of observed word pairs.
- Contrastive Estimation fits a latent string model by comparing an observed word with a finite edit neighborhood.
- Minimum-Risk Annealing fits a latent alignment model under a schedule of tempered expected-loss objectives.
- Name Phylogeny fits a transducer by summing over directed trees of observed name types.
- Mention Phylogeny estimates entity clusters over mention tokens by sampling latent orders and copying histories.
- Latent Morphs and Phonology learns a phonological transducer from words with shared latent stems and suffixes.
- Collapsed Paradigm Reanalysis reassigns tokens to morphological lexeme tables and inflectional slots using finite-state spell-out scores.
Semantics and integrated examples¶
- Quantifier Scope: surface and inverse readings from the continuation monad's two applicative orders.
- Montague NLI: Montague-style lambda-term logical forms plus a syllogistic entailment prover.
- Referent Choice and Pronoun Judgments: two weighted choices enclose a state handler in a judgment model, with exact posterior derivatives for both logits.
- Term Autoencoder: a signature, encoder, decoder, and loss compressing typed lambda terms.
- Lexical-Uncertainty RSA: the specificity model of (Bergen et al., 2016), with a literal listener nested inside a pragmatic speaker and a listener that traverses and marginalizes over three lexica.
- Bayesian Semantics Case Study: four views of one reading experiment in a checked module: a schema-backed categorial parser summing over derivations, a structural logical-form autoencoder, an indexed family separating observed from missing reading times under a contamination measure, and a hierarchical reading-time model with grouped exact marginalization.
Language feature map¶
Find an example by the QVR construct it uses.
| Feature | Primary example | What to inspect |
|---|---|---|
| program templates and subprogram calls | Parametric Partial Pooling | static object arguments, prefixed sites, labeled tuple return |
| per-row exact marginalization with gathered weights | Latent Dirichlet Allocation | over, via, a gathered prior, and the per-token reduction |
| network kernel computation | Bayesian Neural Network | MLP parameter source and reference-machine boundary |
| learned deterministic functions threaded by a scan | Vanilla RNN LM | per-position observation sites and maximum-likelihood training |
| direct deduction, learned rule weights, program-to-deduction call | PCFG and CCG | inside weights, parameter store, scored parser call |
| schema and bundle elaboration, generated search and weight effects | Schema-Bundled Chart Parser | classic chart against run_deduction |
| structural signature, encoder, decoder, loss, typed PyTorch attachments | Term Autoencoder | Program.run("reconstruct", term) and autograd |
| finite collection traversal, indexed effects, nested computation calls, lexical uncertainty | Lexical-Uncertainty RSA | map/fold normalization, traverse over worlds and lexica, lexical marginalization, observed-or-predicted interpretation |
| measure-algebra families | Bayesian Semantics Case Study | heterogeneous Mixture value used for scoring and prediction |
| indexed families, authored handlers, computation calls, parser search, structural attachments, grouped marginalization | Bayesian Semantics Case Study | mixed entry list, effect trace, target-capability diagnostics |
Execution by the reference evaluator and translation to a backend require different capabilities. A source can run in the reference evaluator even when a target cannot translate one of its operations.
The transpilation support matrix records which backends accept the programs under docs/examples/source/. The reference evaluator runs the QIEC programs.
Cited sources¶
Leon Bergen, Roger Levy, and Noah Goodman. Pragmatic reasoning through semantic inference. Semantics and Pragmatics, 2016. URL: https://semprag.org/index.php/sp/article/view/sp.9.20, doi:10.3765/sp.9.20.