mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 17:36:30 +03:00
Add section on disabling pipeline components
This commit is contained in:
parent
9efa662345
commit
419d265ff0
|
@ -315,3 +315,43 @@ p
|
|||
| For more information and a detailed guide on how to package your model,
|
||||
| see the documentation on
|
||||
| #[+a("/docs/usage/saving-loading#models") saving and loading models].
|
||||
|
||||
+h(2, "disabling") Disabling pipeline components
|
||||
|
||||
p
|
||||
| If you don't need a particular component of the pipeline – for
|
||||
| example, the tagger or the parser, you can disable loading it. This can
|
||||
| sometimes make a big difference and improve loading speed. Disabled
|
||||
| component names can be provided to #[code spacy.load], #[code from_disk]
|
||||
| or the #[code nlp] object itself as a list:
|
||||
|
||||
+code.
|
||||
nlp = spacy.load('en', disable['parser', 'tagger'])
|
||||
nlp = English().from_disk('/model', disable=['vectorizer', 'ner'])
|
||||
doc = nlp(u"I don't want parsed", disable=['parser'])
|
||||
|
||||
p
|
||||
| Note that you can't write directly to #[code nlp.pipeline], as this list
|
||||
| holds the #[em actual components], not the IDs. However, if you know the
|
||||
| order of the components, you can still slice the list:
|
||||
|
||||
+code.
|
||||
nlp = spacy.load('en')
|
||||
nlp.pipeline = nlp.pipeline[:2] # only use the first two components
|
||||
|
||||
+infobox("Important note: disabling pipeline components")
|
||||
.o-block
|
||||
| Since spaCy v2.0 comes with better support for customising the
|
||||
| processing pipeline components, the #[code parser], #[code tagger]
|
||||
| and #[code entity] keyword arguments have been replaced with
|
||||
| #[code disable], which takes a list of
|
||||
| #[+a("/docs/usage/language-processing-pipeline") pipeline component names].
|
||||
| This lets you disable both default and custom components when loading
|
||||
| a model, or initialising a Language class via
|
||||
| #[+api("language-from_disk") #[code from_disk]].
|
||||
+code-new.
|
||||
nlp = spacy.load('en', disable=['parser'])
|
||||
doc = nlp(u"I don't want parsed", disable=['parser'])
|
||||
+code-old.
|
||||
nlp = spacy.load('en', parser=False)
|
||||
doc = nlp(u"I don't want parsed", parse=False)
|
||||
|
|
Loading…
Reference in New Issue
Block a user