Skip to content

A determinantal model of vowel inventories

Overview

A finite determinantal point process (DPP) assigns probability to subsets of a fixed vowel inventory. Give each vowel \(i\) an embedding \(x_i\) and let \(X\) have these embeddings as rows. The kernel \(L=XX^\top\) is positive semidefinite because \(v^\top Lv=\lVert X^\top v\rVert^2\). For a subset \(S\), the principal minor \(\det L_{S,S}\) is its unnormalized mass. For two vowels this is \(\lVert x_i\rVert^2\lVert x_j\rVert^2\sin^2\theta\). Thus the lengths control the individual masses, and similar directions reduce the mass of their co-occurrence. Cotterell and Eisner (2017), §3.3.

QVR source

object Vowel : FinSet 4
object Prototype : FinSet 3
object Result : Real 1

program vowel_inventory(formants : Real[Fin Vowel, Fin 2], centers : Real[Fin Prototype, Fin 2], membership : Bool[Fin Vowel]) : Vowel -> Result
    let log_scale <- sample Normal(loc=0.0, scale=0.5)
    let features = map(formants, x -> map(centers, center -> exp(log_scale - 0.5 * sum((x - center) * (x - center)))))
    score inventory_mass = dpp_log_prob(features, membership)
    return inventory_mass

export vowel_inventory

Understanding the model

This example uses four vowels, [i, e, a, u], and three prototypes. formants holds two acoustic coordinates for each vowel, and centers holds the fixed prototype coordinates in that same space. QVR constructs each entry of \(X\) as \(\exp(\lambda-\lVert f_i-c_j\rVert^2/2)\), where \(\lambda\) is a shared log scale with a Normal prior. This specializes the Gaussian prototype responses to equal prototype weights and a fixed width. The coordinates below are synthetic. Cotterell and Eisner (2017), §5.2.

Walkthrough

The program reads one inventory, in ground-set order, as Boolean membership. dpp_log_prob(features, membership) computes a scalar log probability. The score statement adds it to the joint density at the current draw of log_scale. The trace and variational fit expose that same likelihood.

Try it

from pathlib import Path

import torch

from quivers.modeling import Model, VariationalMethod

source = Path("docs/examples/qiec/vowel-inventory.qvr").read_text()
data = {
    "formants": torch.tensor([[0.0, 0.0], [0.5, 0.7], [1.0, -0.5], [0.7, 0.25]]),
    "centers": torch.tensor([[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]]),
    "membership": torch.tensor([True, False, True, False]),
}
model = Model(source)
trace = model.bind(data).trace({"log_scale": torch.tensor(0.2)})
assert torch.isfinite(trace.log_joint).all()
fit = model.fit(data, method=VariationalMethod(num_steps=5, seed=81))
assert len(fit.losses) == 5

The observed subset contributes an explicit score and remains active in prior-only fitting. The builtin scores subsets and has no random-draw interface. QVR's general target transpilers report a capability diagnostic for programs that reach it.

Normalization and support

The score is

\[ \log p(S)=\log\det L_{S,S}-\log\det(I+L). \]

By multilinearity in the columns of \(I+L\), choose a column from \(L\) for each \(i\in S\) and an identity column for every other index. Expanding in the identity columns fixes those indices of a determinant permutation, so the term left over is \(\det L_{S,S}\) with its principal-minor sign. Summing over the choices gives \(\det(I+L)=\sum_S\det L_{S,S}\). This includes the empty set with determinant one and normalizes over all inventory sizes.

The selected submatrix \(X_S\) has nonzero Gram determinant exactly when it has full row rank. More than \(r\) selected vowels is impossible for \(r\) features. The evaluator also checks rank on the represented binary rationals, even when a floating-point factor could report a tiny positive volume for a dependent selection. Clearing powers of two in each row preserves rank. Full rank modulo a prime witnesses an integer minor whose nonzero residue certifies that the original minor is nonzero. Without that witness, integer row elimination determines the rank. Impossible subsets score \(-\infty\) with zero adjoint by convention. The log density has no ordinary derivative at a rank-loss boundary.

For positive mass, write \(E_S X=X_S\) for row selection. Differentiating the two log determinants along a feature perturbation gives

\[ \nabla_X\log p(S) =2E_S^\top (X_SX_S^\top)^{-1}X_S - 2(I+XX^\top)^{-1}X. \]

The empty selection contributes zero in the first term. A reduced QR factorization of \(X_S^\top\) gives the log numerator as twice the sum of the log absolute diagonal entries. The singular values of \(X\) give the log normalizer via \(\sum_j\log(1+\sigma_j^2)\), computed with log1p. The live normalizer derivative uses the QR of the taller of \(X\) and \(X^\top\) stacked below an identity, which has the same Gram determinant. The identity keeps the derivative on a full-column-rank factor even when \(X\) has repeated or zero singular values. Finite input, working range, and a floating condition test delimit the numerical implementation. The test rejects a computed singular value ratio at or below four times the working epsilon times the larger matrix extent. This is a numerical check on positive mass. The integer rank test decides exact zero mass.

For \(n\) vowels, \(r\) features, and \(k\) selected vowels, let \(m=\min(n,r)\) and \(M=\max(n,r)\). The dense factor work per inventory is \(O(Mm^2+rk^2)\), with \(O(nr+rk)\) retained tensor elements for the first reverse pass. Input validation and selecting rows take \(O(nr+n)\) work. The separate exact rank check copies \(kr\) selected entries to the host and takes \(O(k^2r)\) field or integer operations. In the integer fallback, reducing each active row by its greatest common divisor keeps a primitive integer representative of a row of Schur complement minors. If the initial cleared entries have at most \(B\) bits, these integers have \(O(k(B+\log k))\) bits by Hadamard's inequality. This bound counts integer positions and bit widths separately from tensor storage. The runtime does no subset enumeration. The tests enumerate all subsets of small independent fixtures and compare the probabilities and gradients through successive refits.