Using Hugging Face transformers in spaCy
In this chapter, we are going to use spaCy’s transformer component from spacy-transformers in conjunction with the textcat component to increase the accuracy of the pipeline. This time, we will create the pipeline using spaCy’s config.cfg system, which is the recommended way to train the spaCy components.
Let’s first get to know the Transformer component.
The Transformer component
The Transformer component is provided by the spacy-transformers package. With the Transformer component, we can use transformer models to improve the accuracy of our tasks. The component supports all models that are available via the Hugging Face transformers library. In this chapter, we are going to use the RoBERTa model. We'll learn more about this model in the next sections of this chapter.
Transformer adds a Doc._.trf_data attribute to the Doc objects. These transformer tokens can be shared with the other pipeline components...