Add parser example to docs

This commit is contained in:
ines 2017-10-26 16:12:34 +02:00
parent 2d6ec99884
commit 0575e9cf20
2 changed files with 60 additions and 1 deletions

View File

@ -1,6 +1,56 @@
//- 💫 DOCS > USAGE > TRAINING > TAGGER & PARSER
+under-construction
+h(3, "example-train-parser") Updating the parser
p
| This example shows how to train spaCy's dependency parser, starting off
| with an existing model or a blank model. You'll need a set of
| #[strong training examples] and the respective #[strong heads] and
| #[strong dependency label] for each token of the example texts.
+github("spacy", "examples/training/train_parser.py")
+h(4) Step by step guide
+list("numbers")
+item
| #[strong Load the model] you want to start with, or create an
| #[strong empty model] using
| #[+api("spacy#blank") #[code spacy.blank]] with the ID of your
| language. If you're using a blank model, don't forget to add the
| parser to the pipeline. If you're using an existing model,
| make sure to disable all other pipeline components during training
| using #[+api("language#disable_pipes") #[code nlp.disable_pipes]].
| This way, you'll only be training the parser.
+item
| #[strong Add the dependency labels] to the parser using the
| #[+api("dependencyparser#add_label") #[code add_label]] method. If
| you're starting off with a pre-trained spaCy model, this is usually
| not necessary but it doesn't hurt either, just to be safe.
+item
| #[strong Shuffle and loop over] the examples and create a
| #[code Doc] and #[code GoldParse] object for each example. Make sure
| to pass in the #[code heads] and #[code deps] when you create the
| #[code GoldParse].
+item
| For each example, #[strong update the model]
| by calling #[+api("language#update") #[code nlp.update]], which steps
| through the words of the input. At each word, it makes a
| #[strong prediction]. It then consults the annotations provided on the
| #[code GoldParse] instance, to see whether it was
| right. If it was wrong, it adjusts its weights so that the correct
| action will score higher next time.
+item
| #[strong Save] the trained model using
| #[+api("language#to_disk") #[code nlp.to_disk]].
+item
| #[strong Test] the model to make sure the parser works as expected.
+h(3, "training-json") JSON format for training

View File

@ -80,6 +80,15 @@ include ../_includes/_mixins
+github("spacy", "examples/training/train_new_entity_type.py")
+h(3, "parser") Training spaCy's parser
p
| This example shows how to update spaCy's dependency parser,
| starting off with an existing, pre-trained model, or from scratch
| using a blank #[code Language] class.
+github("spacy", "examples/training/train_parser.py")
+h(3, "textcat") Training spaCy's text classifier
+tag-new(2)