Point-Estimate Fitting¶
adam_fit_deduction maximises the corpus log-marginal
\(\sum_n \log Z(s_n; \mathbf{w})\) under an optional isotropic
Normal prior on the deduction's learnable log-weights. Each
\(\log Z\) is computed exactly by the chart's LogProb-semiring
fixed point; autograd through the agenda's semiring operations
gives the exact gradient
\(\nabla_\mathbf{w} \log Z(s; \mathbf{w})
= \mathbb{E}_{d \mid s}[\phi(d)]\) (the standard inside-outside
identity).
fit
¶
Point-estimate fitting of a weighted deduction system.
adam_fit_deduction runs gradient descent on the
deduction's learnable log-weights to maximise the corpus
log-marginal :math:\sum_n \log Z(s_n; \mathbf{w}), optionally
under an isotropic Normal prior (MAP). Each :math:\log Z(s;
\mathbf{w}) is computed exactly by the chart's LogProb-semiring
fixed point; autograd through the agenda's semiring operations
yields the exact gradient
:math:\nabla_{\mathbf{w}} \log Z(s; \mathbf{w})
= \mathbb{E}_{d \mid s}[\phi(d)] (the standard inside-outside
identity).
adam_fit_deduction
¶
adam_fit_deduction(ded: DeductionSystem, corpus: Sequence[Sequence[str]], *, steps: int = 300, lr: float = 0.05, prior_scale: float | None = None) -> list[float]
Maximise the corpus log-marginal under an optional Normal prior on the parameters.
| PARAMETER | DESCRIPTION |
|---|---|
ded
|
Deduction whose
TYPE:
|
corpus
|
Each sentence is a sequence of token strings the deduction's axiom injector accepts.
TYPE:
|
steps
|
Adam steps.
TYPE:
|
lr
|
Adam learning rate.
TYPE:
|
prior_scale
|
If supplied, adds a Gaussian regulariser
:math:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[float]
|
The loss trajectory; length == |
Source code in src/quivers/stochastic/deduction/fit.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |