Point-Estimate Fitting¶
adam_fit_deduction fits a deduction's learnable log weights \(\mathbf{w}\) by maximizing the
corpus objective \(\sum_n \log Z(s_n; \mathbf{w})\)
(charts as differentiable values),
optionally with an isotropic Normal prior on \(\mathbf{w}\). Each \(\log Z\) is the
exact fixed point of the chart under the log semiring, and automatic differentiation through it
gives the exact gradient \(\nabla_\mathbf{w} \log Z(s; \mathbf{w}) = \mathbb{E}_{d \mid s}[\phi(d)]\),
the expected feature counts of the inside-outside algorithm (Goodman, 1999). The objective
is a corpus log likelihood only when the grammar is normalized.
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
Cited sources¶
Joshua Goodman. Semiring Parsing. Computational Linguistics, 25(4):573–606, 1999. URL: https://aclanthology.org/J99-4004/.