TriaffineSpanLayer<T>

Layers · AiDotNet.NeuralNetworks.Layers

The Triaffine nested-NER classifier (Yuan et al. 2022, “Fusing Heterogeneous Factors with Triaffine Mechanism for Nested Named Entity Recognition”, section 3). The deep triaffine transformation TriAff(u, v, w, W) = W x1 u’ x2 w’ x3 v’ with u’ = [MLP(u); 1], v’ = [MLP(v); 1] and w’ = MLP(w) (Equations 1 to 3) scores, for every span (i, j) and label r, each inside token k against the span’s boundaries; a softmax over the inside tokens gives label-wise span representations (Equations 5 to 7) and the auxiliary scores p_ijr (triaffine scoring, section 3.5). The top-m spans by their best non-None auxiliary score then attend over each other with triaffine attention, and their final scores come from the decomposed triaffine scoring (Equations 8 to 13).

Inheritance: LayerBase<T> → TriaffineSpanLayer<T>

Implements: IShapeContract

How It Works

Shapes: input [B, S, D] (or [S, D]); output [B, S * S, R], the span grid at index start * S + end, R labels with None first. The top-m spans carry their final scores p^c. In training the other spans carry their auxiliary scores, so the cross-entropy over the grid trains both predictions (the paper applies the auxiliary loss to every span and the main loss to the top-m); in inference they are assigned None (section 3.6). Spans with end before start score None.

Constructors

Constructor Summary
TriaffineSpanLayer(int inputDim, int dim, int numLabels, int topM) Creates the classifier.

Properties

Property Summary
bool SupportsTraining { get; }

Methods

Method Summary
IReadOnlyList<ILayer<T>> GetSubLayers()
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank)
void ResetState()