PyramidSpanLayer<T>

Layers · AiDotNet.NeuralNetworks.Layers

The Pyramid nested-NER decoder (Wang et al. 2020, “Pyramid: A Layered Model for Nested Named Entity Recognition”, section 3): L decoding layers, each a layer norm and a bidirectional LSTM followed by a width-2 convolution that merges adjacent hidden states, so layer l’s position t represents tokens t to t + l - 1 (Equations 5 and 6); an inverse pyramid that reconstructs each lower layer from the concatenated normal and inverse hidden states with a zero-padded width-2 convolution (Equations 7 and 8, zeros for the top inverse layer); and a linear layer scoring each span from the two hidden states (Equation 9). The layer norms, LSTMs and convolutions are shared by all decoding layers, as the paper’s notation states.

Inheritance: LayerBase<T> → PyramidSpanLayer<T>

Implements: IShapeContract

How It Works

Shapes: input [B, S, D] (or [S, D]); output [B, S * S, C], the span grid at index start * S + end (the layout of BiaffineSpanScorerLayer), with zero scores for spans longer than L or with end before start. The paper’s remedy for mentions longer than L (B and I tags on the top layer) is not built; L defaults to the paper’s 16. The bidirectional LSTMs sum their directions.

Constructors

Constructor Summary
PyramidSpanLayer(int dim, int numLayers, int numClasses) Creates the decoder.

Properties

Property Summary
bool SupportsTraining { get; }

Methods

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