CNNBiLSTMCRFOptions
Options & Configuration · AiDotNet.NER.Options
Configuration options for the CNN-BiLSTM-CRF Named Entity Recognition model.
Inheritance: ModelOptions → NeuralNetworkOptions → CNNBiLSTMCRFOptions
For Beginners
CNN-BiLSTM-CRF is like BiLSTM-CRF but with an extra component that looks at the letters within each word. A CNN (Convolutional Neural Network) slides a small window across the characters of each word to detect patterns like capitalization (“John” vs “john”), suffixes (“-tion”, “-ing”), and word shapes. These character features are combined with word embeddings before being fed into the BiLSTM.
Compared to BiLSTM-CRF with character BiLSTM:
- CNN is faster to compute (parallel vs sequential processing)
- CNN is better at capturing local character n-grams (suffixes, prefixes)
- BiLSTM is better at capturing long-range character dependencies (rare)
- In practice, both achieve similar NER accuracy (~91% F1 on CoNLL-2003)
How It Works
CNN-BiLSTM-CRF (Ma and Hovy, ACL 2016 - “End-to-end Sequence Labeling via Bi-directional LSTM-CNNs-CRF”) extends the BiLSTM-CRF architecture with character-level Convolutional Neural Network (CNN) embeddings. The architecture has three main components:
- Character-level CNN: A 1D CNN processes each word’s character sequence to capture
morphological features (capitalization, prefixes, suffixes, word shape). Unlike the character BiLSTM in Lample et al. (2016), a CNN is faster and better at capturing local n-gram patterns. The CNN output is max-pooled to produce a fixed-size vector per word.
- BiLSTM encoder: Processes the concatenation of word embeddings and character CNN
features in both forward and backward directions. Each token gets a representation that captures its full sentence context plus its morphological features.
- CRF decoder: Models label transition dependencies to produce globally optimal
label sequences, enforcing valid BIO constraints via the Viterbi algorithm.
Default values follow the original Ma and Hovy (2016) paper:
- 100-dimensional GloVe word embeddings
- Character CNN with 30-dimensional embeddings, 30 filters of width 3
- Single BiLSTM layer with 200 hidden units per direction
- 50% dropout rate
- 9 CoNLL-2003 BIO labels
Constructors
| Constructor | Summary |
|---|---|
CNNBiLSTMCRFOptions() |
Initializes a new instance with default values matching the original Ma and Hovy (2016) paper. |
CNNBiLSTMCRFOptions(CNNBiLSTMCRFOptions other) |
Initializes a new instance by deep-copying all settings from another instance. |
Properties
| Property | Summary |
|---|---|
NERModelVariant Variant { get; set; } |
Gets or sets the model size variant, which controls the overall capacity of the model. |
OnnxModelOptions OnnxOptions { get; set; } |
Gets or sets the ONNX Runtime configuration options. |
bool UseCRF { get; set; } |
Gets or sets whether to use CRF (Conditional Random Field) decoding. |
double DropoutRate { get; set; } |
Gets or sets the dropout rate for regularization during training. |
double LearningRate { get; set; } |
Gets or sets the learning rate for the optimizer during training. |
int CharCNNFilters { get; set; } |
Gets or sets the number of CNN filters for character-level feature extraction. |
int CharCNNKernelSize { get; set; } |
Gets or sets the kernel (window) size for the character CNN. |
int CharEmbeddingDimension { get; set; } |
Gets or sets the character embedding vector dimension. |
int EmbeddingDimension { get; set; } |
Gets or sets the input token embedding dimension. |
int HiddenDimension { get; set; } |
Gets or sets the LSTM hidden state dimension per direction. |
int MaxSequenceLength { get; set; } |
Gets or sets the maximum input sequence length in tokens. |
int NumLSTMLayers { get; set; } |
Gets or sets the number of stacked BiLSTM layers. |
int NumLabels { get; set; } |
Gets or sets the number of entity label classes in the BIO tagging scheme. |
string ModelPath { get; set; } |
Gets or sets the path to a pre-trained ONNX model file for inference mode. |
string[] LabelNames { get; set; } |
Gets or sets the BIO label names for the tagging scheme. |