document individual component API pages

This commit is contained in:
svlandeg 2020-09-09 16:18:38 +02:00
parent a8aa9a8068
commit c89e07927e
5 changed files with 79 additions and 5 deletions

View File

@ -307,6 +307,32 @@ Add a new label to the pipe.
| `label` | The label to add. ~~str~~ | | `label` | The label to add. ~~str~~ |
| **RETURNS** | `0` if the label is already present, otherwise `1`. ~~int~~ | | **RETURNS** | `0` if the label is already present, otherwise `1`. ~~int~~ |
Note that you don't have to call `pipe.add_label` if you provide a
representative data sample to the [`begin_training`](#begin_training) method. In
this case, all labels found in the sample will be automatically added to the
model, and the output dimension will be
[inferred](/usage/layers-architectures#shape-inference) automatically.
## DependencyParser.set_output {#set_output tag="method"}
Change the output dimension of the component's model by calling the model's
attribute `resize_output`. This is a function that takes the original model and
the new output dimension `nO`, and changes the model in place.
> #### Example
>
> ```python
> parser = nlp.add_pipe("parser")
> parser.set_output(512)
> ```
| Name | Description |
| ---- | --------------------------------- |
| `nO` | The new output dimension. ~~int~~ |
When resizing an already trained model, care should be taken to avoid the
"catastrophic forgetting" problem.
## DependencyParser.to_disk {#to_disk tag="method"} ## DependencyParser.to_disk {#to_disk tag="method"}
Serialize the pipe to disk. Serialize the pipe to disk.

View File

@ -295,6 +295,32 @@ Add a new label to the pipe.
| `label` | The label to add. ~~str~~ | | `label` | The label to add. ~~str~~ |
| **RETURNS** | `0` if the label is already present, otherwise `1`. ~~int~~ | | **RETURNS** | `0` if the label is already present, otherwise `1`. ~~int~~ |
Note that you don't have to call `pipe.add_label` if you provide a
representative data sample to the [`begin_training`](#begin_training) method. In
this case, all labels found in the sample will be automatically added to the
model, and the output dimension will be
[inferred](/usage/layers-architectures#shape-inference) automatically.
## EntityRecognizer.set_output {#set_output tag="method"}
Change the output dimension of the component's model by calling the model's
attribute `resize_output`. This is a function that takes the original model and
the new output dimension `nO`, and changes the model in place.
> #### Example
>
> ```python
> ner = nlp.add_pipe("ner")
> ner.set_output(512)
> ```
| Name | Description |
| ---- | --------------------------------- |
| `nO` | The new output dimension. ~~int~~ |
When resizing an already trained model, care should be taken to avoid the
"catastrophic forgetting" problem.
## EntityRecognizer.to_disk {#to_disk tag="method"} ## EntityRecognizer.to_disk {#to_disk tag="method"}
Serialize the pipe to disk. Serialize the pipe to disk.

View File

@ -258,6 +258,8 @@ context, the original parameters are restored.
Add a new label to the pipe. If the `Morphologizer` should set annotations for Add a new label to the pipe. If the `Morphologizer` should set annotations for
both `pos` and `morph`, the label should include the UPOS as the feature `POS`. both `pos` and `morph`, the label should include the UPOS as the feature `POS`.
Raises an error if the output dimension is already set, or if the model has
already been fully [initialized](#begin_training).
> #### Example > #### Example
> >
@ -271,6 +273,12 @@ both `pos` and `morph`, the label should include the UPOS as the feature `POS`.
| `label` | The label to add. ~~str~~ | | `label` | The label to add. ~~str~~ |
| **RETURNS** | `0` if the label is already present, otherwise `1`. ~~int~~ | | **RETURNS** | `0` if the label is already present, otherwise `1`. ~~int~~ |
Note that you don't have to call `pipe.add_label` if you provide a
representative data sample to the [`begin_training`](#begin_training) method. In
this case, all labels found in the sample will be automatically added to the
model, and the output dimension will be
[inferred](/usage/layers-architectures#shape-inference) automatically.
## Morphologizer.to_disk {#to_disk tag="method"} ## Morphologizer.to_disk {#to_disk tag="method"}
Serialize the pipe to disk. Serialize the pipe to disk.

View File

@ -249,9 +249,9 @@ Score a batch of examples.
> scores = tagger.score(examples) > scores = tagger.score(examples)
> ``` > ```
| Name | Description | | Name | Description |
| ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | | ----------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `examples` | The examples to score. ~~Iterable[Example]~~ | | `examples` | The examples to score. ~~Iterable[Example]~~ |
| **RETURNS** | The scores, produced by [`Scorer.score_token_attr`](/api/scorer#score_token_attr) for the attribute `"tag"`. ~~Dict[str, float]~~ | | **RETURNS** | The scores, produced by [`Scorer.score_token_attr`](/api/scorer#score_token_attr) for the attribute `"tag"`. ~~Dict[str, float]~~ |
## Tagger.create_optimizer {#create_optimizer tag="method"} ## Tagger.create_optimizer {#create_optimizer tag="method"}
@ -288,7 +288,8 @@ context, the original parameters are restored.
## Tagger.add_label {#add_label tag="method"} ## Tagger.add_label {#add_label tag="method"}
Add a new label to the pipe. Add a new label to the pipe. Raises an error if the output dimension is already
set, or if the model has already been fully [initialized](#begin_training).
> #### Example > #### Example
> >
@ -302,6 +303,12 @@ Add a new label to the pipe.
| `label` | The label to add. ~~str~~ | | `label` | The label to add. ~~str~~ |
| **RETURNS** | `0` if the label is already present, otherwise `1`. ~~int~~ | | **RETURNS** | `0` if the label is already present, otherwise `1`. ~~int~~ |
Note that you don't have to call `pipe.add_label` if you provide a
representative data sample to the [`begin_training`](#begin_training) method. In
this case, all labels found in the sample will be automatically added to the
model, and the output dimension will be
[inferred](/usage/layers-architectures#shape-inference) automatically.
## Tagger.to_disk {#to_disk tag="method"} ## Tagger.to_disk {#to_disk tag="method"}
Serialize the pipe to disk. Serialize the pipe to disk.

View File

@ -297,7 +297,8 @@ Modify the pipe's model, to use the given parameter values.
## TextCategorizer.add_label {#add_label tag="method"} ## TextCategorizer.add_label {#add_label tag="method"}
Add a new label to the pipe. Add a new label to the pipe. Raises an error if the output dimension is already
set, or if the model has already been fully [initialized](#begin_training).
> #### Example > #### Example
> >
@ -311,6 +312,12 @@ Add a new label to the pipe.
| `label` | The label to add. ~~str~~ | | `label` | The label to add. ~~str~~ |
| **RETURNS** | `0` if the label is already present, otherwise `1`. ~~int~~ | | **RETURNS** | `0` if the label is already present, otherwise `1`. ~~int~~ |
Note that you don't have to call `pipe.add_label` if you provide a
representative data sample to the [`begin_training`](#begin_training) method. In
this case, all labels found in the sample will be automatically added to the
model, and the output dimension will be
[inferred](/usage/layers-architectures#shape-inference) automatically.
## TextCategorizer.to_disk {#to_disk tag="method"} ## TextCategorizer.to_disk {#to_disk tag="method"}
Serialize the pipe to disk. Serialize the pipe to disk.