diff --git a/website/docs/usage/training.md b/website/docs/usage/training.md index 2d7905230..6d56f5767 100644 --- a/website/docs/usage/training.md +++ b/website/docs/usage/training.md @@ -669,7 +669,7 @@ def custom_logger(log_path): #### Example: Custom batch size schedule {#custom-code-schedule} -For example, let's say you've implemented your own batch size schedule to use +You can also implement your own batch size schedule to use during training. The `@spacy.registry.schedules` decorator lets you register that function in the `schedules` [registry](/api/top-level#registry) and assign it a string name: @@ -806,7 +806,37 @@ def filter_batch(size: int) -> Callable[[Iterable[Example]], Iterator[List[Examp ### Defining custom architectures {#custom-architectures} - +Built-in pipeline components such as the tagger or named entity recognizer are +constructed with default neural network [models](/api/architectures). +You can change the model architecture +entirely by implementing your own custom models and providing those in the config +when creating the pipeline component. See the +documentation on +[layers and model architectures](/usage/layers-architectures) for more details. + + +```python +### functions.py +from typing import List +from thinc.types import Floats2d +from thinc.api import Model +import spacy +from spacy.tokens import Doc + +@spacy.registry.architectures("custom_neural_network.v1") +def MyModel(output_width: int) -> Model[List[Doc], List[Floats2d]]: + # ... +``` + +```ini +### config.cfg (excerpt) +[components.tagger] +factory = "tagger" + +[components.tagger.model] +@architectures = "custom_neural_network.v1" +output_width = 512 +``` ## Internal training API {#api}