Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

How to Load Any HuggingFace Model in spaCy

import spacy
nlp = spacy.blank("en") # empty English pipeline
# create the config with the name of your model
# values omitted will get default values
config = {
    "model": {
        "@architectures": "spacy-transformers.TransformerModel.v3",
        "name": "roberta-base" # XXX customize this bit
    }
}
nlp.add_pipe("transformer", config=config)
nlp.initialize() # XXX don't forget this step!
doc = nlp("Robots in disguise")
print(doc._.trf_data) # all the Transformer output is stored here
Source by github.com #
 
PREVIOUS NEXT
Tagged: #How #Load #Any #HuggingFace #Model #spaCy
ADD COMMENT
Topic
Name
7+7 =