Semirings#

Semiring#

class supar.structs.semiring.Semiring[source]#

Base semiring class Goodman (1999).

A semiring is defined by a tuple \(<K, \oplus, \otimes, \mathbf{0}, \mathbf{1}>\). \(K\) is a set of values; \(\oplus\) is commutative, associative and has an identity element 0; \(\otimes\) is associative, has an identity element 1 and distributes over +.

LogSemiring#

class supar.structs.semiring.LogSemiring[source]#

Log-space semiring \(<\mathrm{logsumexp}, +, -\infty, 0>\).

MaxSemiring#

class supar.structs.semiring.MaxSemiring[source]#

Max semiring \(<\mathrm{max}, +, -\infty, 0>\).

KMaxSemiring#

class supar.structs.semiring.KMaxSemiring(k)[source]#

k-max semiring \(<\mathrm{kmax}, +, [-\infty, -\infty, \dots], [0, -\infty, \dots]>\).

ExpectationSemiring#

class supar.structs.semiring.ExpectationSemiring[source]#

Expectation semiring \(<\oplus, +, [0, 0], [1, 0]>\) Li & Eisner (2009).

Practical Applications: \(H(p) = \log Z - \frac{1}{Z}\sum_{d \in D} p(d) r(d)\).

EntropySemiring#

class supar.structs.semiring.EntropySemiring[source]#

Entropy expectation semiring \(<\oplus, +, [-\infty, 0], [0, 0]>\), where \(\oplus\) computes the log-values and the running distributional entropy \(H[p]\) Li & Eisner 2009,Hwa 2000,Kim et al. (2019).

CrossEntropySemiring#

class supar.structs.semiring.CrossEntropySemiring[source]#

Cross Entropy expectation semiring \(<\oplus, +, [-\infty, -\infty, 0], [0, 0, 0]>\), where \(\oplus\) computes the log-values and the running distributional cross entropy \(H[p,q]\) of the two distributions Li & Eisner (2009).

KLDivergenceSemiring#

class supar.structs.semiring.KLDivergenceSemiring[source]#

KL divergence expectation semiring \(<\oplus, +, [-\infty, -\infty, 0], [0, 0, 0]>\), where \(\oplus\) computes the log-values and the running distributional KL divergence \(KL[p \parallel q]\) of the two distributions Li & Eisner (2009).

SampledSemiring#

class supar.structs.semiring.SampledSemiring[source]#

Sampling semiring \(<\mathrm{logsumexp}, +, -\infty, 0>\), which is an exact forward-filtering, backward-sampling approach.

SparsemaxSemiring#

class supar.structs.semiring.SparsemaxSemiring[source]#

Sparsemax semiring \(<\mathrm{sparsemax}, +, -\infty, 0>\) Martins & Astudillo 2016,Mensch & Blondel 2018,Correia et al. (2020).