Training custom sequence labeling models
In this section, we will be looking at the process, syntax, objects, and methods involved in training custom sequence labeling models in Flair. If you read the previous sections of this chapter and understood the contents, you're in luck. Once you understand the underlying concepts of neural networks, have a GPU-equipped rig running, and are familiar with the most common parameters, the actual training process is actually fairly straightforward.
The process can be broken down into the following steps:
- Loading a tagged corpus
- Loading the tag dictionary
- Building the embedding stack
- Initializing the
SequenceTagger
object - Training the model
Each of these steps requires only a few lines of code. To best understand the code, let's cover it as part of a practical example of training a PoS tagger. For example, let's pretend there are no pre-trained English taggers in Flair and attempt to train a PoS tagger...