Skip to content

Commit a833c6e

Browse files
Update README with badges and comprehensive content
- Add CI, docs, PyPI, Python version, and license badges - Add stochastic morphisms and QVR DSL quick start examples - Add project structure overview - Add documentation links - Update all repo URLs from aaronstevenwhite to FACTSlab - Update Python requirement to 3.13+
1 parent 5f2d2a6 commit a833c6e

6 files changed

Lines changed: 117 additions & 31 deletions

File tree

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This guide covers setting up a development environment, understanding the projec
1515
Clone the repository and install in development mode:
1616

1717
```bash
18-
git clone https://github.com/aaronstevenwhite/quivers
18+
git clone https://github.com/FACTSlab/quivers
1919
cd quivers
2020
pip install -e ".[dev]"
2121
```
@@ -267,4 +267,4 @@ Add the distribution to the API reference with usage examples and parameter desc
267267

268268
## Questions and Issues
269269

270-
Open an issue on the [GitHub repository](https://github.com/aaronstevenwhite/quivers) for bugs, feature requests, or questions.
270+
Open an issue on the [GitHub repository](https://github.com/FACTSlab/quivers) for bugs, feature requests, or questions.

README.md

Lines changed: 108 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
# Quivers
22

3+
[![CI](https://github.com/FACTSlab/quivers/actions/workflows/ci.yml/badge.svg)](https://github.com/FACTSlab/quivers/actions/workflows/ci.yml)
4+
[![Docs](https://github.com/FACTSlab/quivers/actions/workflows/docs.yml/badge.svg)](https://FACTSlab.github.io/quivers)
5+
[![PyPI](https://img.shields.io/pypi/v/quivers)](https://pypi.org/project/quivers/)
6+
[![Python 3.13+](https://img.shields.io/badge/python-3.13%2B-blue)](https://www.python.org/downloads/)
7+
[![License: MIT](https://img.shields.io/badge/license-MIT-green)](LICENSE)
8+
39
Computational category theory as differentiable tensor programs.
410

5-
**Quivers** is a Python library for building categorical and probabilistic models as differentiable PyTorch programs. It represents morphisms between finite sets as tensors valued in a quantale (a lattice with a monoidal product), then extends this to stochastic morphisms (Markov kernels), continuous distribution families, monadic probabilistic programs, and variational inference. A built-in DSL compiles `.qvr` specifications into trainable `nn.Module` instances.
11+
**Quivers** is a Python library for building categorical and probabilistic models as differentiable PyTorch programs. It represents morphisms between finite sets as tensors valued in a quantale (a lattice with a monoidal product), then extends this to stochastic morphisms (Markov kernels), continuous distribution families, monadic probabilistic programs, and variational inference. A built-in functional DSL compiles `.qvr` specifications into trainable `nn.Module` instances.
612

713
## Features
814

9-
- **Core categorical algebra**: finite sets and product constructions as objects; quantales (Boolean, fuzzy, Łukasiewicz, Gödel, tropical); $\mathcal{V}$-enriched relations as parametrized tensors.
10-
- **Categorical structures**: functors, natural transformations, adjunctions, monoidal categories, traced monoidal categories.
11-
- **Monadic and enriched constructs**: monads, comonads, algebras, Kleisli categories, ends/coends, Kan extensions, profunctors, Yoneda, Day convolution, optics.
12-
- **Stochastic morphisms**: the FinStoch category of Markov kernels; discretized families (normal, beta, truncated normal); conditioning and mixing; the Giry monad.
13-
- **Continuous morphisms**: parameterized families of distributions (30+); boundaries (discretize/embed); normalizing flows; monadic programs for hybrid discrete-continuous computations.
14-
- **Monadic DSL**: a `.qvr` file format and compiler for writing categorical programs declaratively.
15-
- **Variational inference**: trace-based conditioning, variational guides, ELBO and SVI for posterior inference.
15+
- **Core categorical algebra**: finite sets, product/coproduct constructions, and free monoids as objects; quantales (Boolean, product fuzzy, Łukasiewicz, Gödel, tropical) as enrichment algebras; $\mathcal{V}$-enriched relations as parametrized tensors with composition via quantale operations.
16+
- **Categorical structures**: functors, natural transformations, adjunctions, monoidal categories, traced monoidal categories, base change between quantales.
17+
- **Enriched category theory**: ends, coends, Kan extensions, weighted limits/colimits, profunctors, Yoneda embedding, Day convolution, optics (lenses, prisms, adapters, grates).
18+
- **Monadic constructs**: monads, comonads, Kleisli/coKleisli categories, algebras, coalgebras, Eilenberg-Moore categories, distributive laws.
19+
- **Stochastic morphisms**: the FinStoch category of Markov kernels; discretized distribution families (normal, logit-normal, beta, truncated normal); conditioning, mixing, and normalization transforms; the Giry monad; query functions (prob, marginal_prob, expectation).
20+
- **Continuous morphisms**: 30+ parameterized conditional distribution families; continuous spaces (Euclidean, simplex, unit interval, positive reals); sampled composition; normalizing flows; discrete-continuous boundaries (discretize/embed).
21+
- **Monadic programs**: probabilistic programs with draw, observe, and return statements; ancestral sampling; log-joint computation; hybrid discrete-continuous random variables.
22+
- **QVR DSL**: a `.qvr` file format with lexer, recursive descent parser, AST, and compiler; supports object/morphism declarations, program blocks, let bindings, type expressions, and grammar-based parsers (PCFG, CCG, Lambek, multimodal type-logical).
23+
- **Variational inference**: execution traces, conditioning, automatic variational guides (normal, delta), ELBO computation, stochastic variational inference (SVI), posterior predictive sampling.
1624

1725
## Installation
1826

@@ -23,45 +31,123 @@ pip install quivers
2331
Or install from source:
2432

2533
```bash
26-
git clone https://github.com/aaronstevenwhite/quivers
34+
git clone https://github.com/FACTSlab/quivers
2735
cd quivers
2836
pip install -e .
2937
```
3038

39+
For development (includes pytest, ruff, pyright):
40+
41+
```bash
42+
pip install -e ".[dev]"
43+
```
44+
3145
## Quick Start
3246

47+
### Discrete morphisms and composition
48+
49+
Define finite sets, create learnable and observed morphisms, and compose them:
50+
3351
```python
34-
from quivers import FinSet, morphism, observed, identity, Program
52+
from quivers import FinSet, morphism, observed, Program
3553
import torch
3654

3755
X = FinSet("X", 3)
3856
Y = FinSet("Y", 4)
3957
Z = FinSet("Z", 2)
4058

41-
# Latent (learnable) morphism
42-
f = morphism(X, Y)
59+
f = morphism(X, Y) # learnable (sigmoid over raw params)
60+
g = observed(Y, Z, torch.rand(4, 2)) # fixed tensor
61+
62+
h = f >> g # V-enriched composition: X -> Z
63+
program = Program(h)
64+
output = program() # shape (3, 2), values in [0, 1]
65+
```
4366

44-
# Observed morphism with fixed tensor
45-
g_data = torch.rand(4, 2)
46-
g = observed(Y, Z, g_data)
67+
Composition uses the product fuzzy quantale by default: AND is multiplication, OR is noisy-OR ($1 - \prod(1 - x_i)$). The result is a differentiable tensor, trainable via `program.parameters()`.
4768

48-
# V-enriched composition: X -> Y -> Z
49-
h = f >> g
69+
### Stochastic morphisms
5070

51-
# Wrap as a trainable module
52-
program = Program(h)
53-
output = program() # shape (3, 2)
71+
Work with Markov kernels in the FinStoch category:
72+
73+
```python
74+
from quivers import FinSet, stochastic, condition, prob
75+
76+
S = FinSet("S", 3)
77+
O = FinSet("O", 5)
78+
79+
transition = stochastic(S, S) # learnable row-stochastic matrix
80+
emission = stochastic(S, O) # learnable row-stochastic matrix
81+
82+
# condition on an observation
83+
conditioned = condition(emission, obs_index=2)
84+
85+
# query probabilities
86+
p = prob(transition, domain_idx=0, codomain_idx=1)
87+
```
88+
89+
### The QVR DSL
90+
91+
Write probabilistic programs in `.qvr` syntax and compile to `nn.Module`:
92+
93+
```python
94+
from quivers.dsl import loads
95+
96+
source = """
97+
object Predictor : 1
98+
object Response : 1
99+
100+
program regression : Predictor -> Response
101+
sigma <- HalfCauchy(2.0)
102+
beta_0 <- Normal(0.0, 5.0)
103+
beta_1 <- Normal(0.0, 2.0)
104+
x <- Normal(0.0, 1.0)
105+
let mu = beta_0 + beta_1 * x
106+
observe y ~ Normal(mu, sigma)
107+
return y
108+
109+
output regression
110+
"""
111+
112+
model = loads(source)
113+
```
114+
115+
## Project Structure
116+
117+
```text
118+
src/quivers/
119+
├── core/ # objects, quantales, morphisms, tensor ops
120+
├── categorical/ # functors, natural transformations, adjunctions, monoidal, traced
121+
├── monadic/ # monads, comonads, algebras, distributive laws
122+
├── enriched/ # ends/coends, Kan extensions, profunctors, Yoneda, Day, optics
123+
├── stochastic/ # Markov kernels, Giry monad, grammar parsers, chart algorithms
124+
├── continuous/ # distribution families, spaces, flows, monadic programs
125+
├── dsl/ # lexer, parser, AST, compiler for .qvr files
126+
├── inference/ # traces, conditioning, guides, ELBO, SVI, predictive
127+
├── program.py # Program: wraps morphisms as nn.Module
128+
└── giry.py # GiryMonad, FinStoch
54129
```
55130

56131
## Documentation
57132

58-
Full documentation is available at [https://aaronstevenwhite.github.io/quivers](https://aaronstevenwhite.github.io/quivers).
133+
Full documentation: [https://FACTSlab.github.io/quivers](https://FACTSlab.github.io/quivers)
134+
135+
- [Installation](https://FACTSlab.github.io/quivers/getting-started/installation/)
136+
- [Quickstart](https://FACTSlab.github.io/quivers/getting-started/quickstart/)
137+
- [Conceptual Guides](https://FACTSlab.github.io/quivers/guides/)
138+
- [Tutorials](https://FACTSlab.github.io/quivers/tutorials/)
139+
- [Examples Gallery](https://FACTSlab.github.io/quivers/examples/)
140+
- [API Reference](https://FACTSlab.github.io/quivers/api/)
59141

60142
## Requirements
61143

62-
- Python 3.12+
144+
- Python 3.13+
63145
- PyTorch 2.0+
64146

147+
## Contributing
148+
149+
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, code style conventions, and the git workflow.
150+
65151
## License
66152

67153
MIT. See [LICENSE](LICENSE) for details.

docs/developer/contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This guide covers setting up a development environment, understanding the projec
1515
Clone the repository and install in development mode:
1616

1717
```bash
18-
git clone https://github.com/aaronstevenwhite/quivers
18+
git clone https://github.com/FACTSlab/quivers
1919
cd quivers
2020
pip install -e ".[dev]"
2121
```

docs/getting-started/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Quivers is not yet available on PyPI. Install directly from source:
1111

1212
```bash
1313
# Clone the repository
14-
git clone https://github.com/aaronstevenwhite/quivers
14+
git clone https://github.com/FACTSlab/quivers
1515
cd quivers
1616

1717
# Install in development mode

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Install from source:
2222

2323
```bash
2424
pip install torch
25-
git clone https://github.com/aaronstevenwhite/quivers
25+
git clone https://github.com/FACTSlab/quivers
2626
cd quivers
2727
pip install -e .
2828
```

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ docs = [
4747
]
4848

4949
[project.urls]
50-
Homepage = "https://github.com/aaronstevenwhite/quivers"
51-
Repository = "https://github.com/aaronstevenwhite/quivers"
52-
Documentation = "https://aaronstevenwhite.github.io/quivers"
53-
Changelog = "https://github.com/aaronstevenwhite/quivers/blob/main/CHANGELOG.md"
50+
Homepage = "https://github.com/FACTSlab/quivers"
51+
Repository = "https://github.com/FACTSlab/quivers"
52+
Documentation = "https://FACTSlab.github.io/quivers"
53+
Changelog = "https://github.com/FACTSlab/quivers/blob/main/CHANGELOG.md"
5454

5555
[project.entry-points."pygments.lexers"]
5656
qvr = "quivers.dsl.pygments_lexer:QvrLexer"

0 commit comments

Comments
 (0)