Skip to content

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

Grouped and latent-variable models

State-space and time-series models

Neural and language models

Weighted parsing

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.