Update developer docs

This commit is contained in:
shadeMe 2023-07-04 14:16:53 +02:00
parent 6711143f5b
commit 2aeca38a07
No known key found for this signature in database
GPG Key ID: 6FCA9FC635B2A402

View File

@ -1,14 +1,18 @@
# Listeners # Listeners
1. [Overview](#1-overview) - [Listeners](#listeners)
2. [Initialization](#2-initialization) - [1. Overview](#1-overview)
- [A. Linking listeners to the embedding component](#2a-linking-listeners-to-the-embedding-component) - [2. Initialization](#2-initialization)
- [B. Shape inference](#2b-shape-inference) - [2A. Linking listeners to the embedding component](#2a-linking-listeners-to-the-embedding-component)
3. [Internal communication](#3-internal-communication) - [2B. Shape inference](#2b-shape-inference)
- [A. During prediction](#3a-during-prediction) - [3. Internal communication](#3-internal-communication)
- [B. During training](#3b-during-training) - [3A. During prediction](#3a-during-prediction)
- [C. Frozen components](#3c-frozen-components) - [3B. During training](#3b-during-training)
4. [Replacing listener with standalone](#4-replacing-listener-with-standalone) - [Training with multiple listeners](#training-with-multiple-listeners)
- [3C. Frozen components](#3c-frozen-components)
- [The Tok2Vec or Transformer is frozen](#the-tok2vec-or-transformer-is-frozen)
- [The upstream component is frozen](#the-upstream-component-is-frozen)
- [4. Replacing listener with standalone](#4-replacing-listener-with-standalone)
## 1. Overview ## 1. Overview
@ -218,3 +222,10 @@ new_model = tok2vec_model.attrs["replace_listener"](new_model)
The new config and model are then properly stored on the `nlp` object. The new config and model are then properly stored on the `nlp` object.
Note that this functionality (running the replacement for a transformer listener) was broken prior to Note that this functionality (running the replacement for a transformer listener) was broken prior to
`spacy-transformers` 1.0.5. `spacy-transformers` 1.0.5.
As of spaCy 3.7, the `replace_listener` callback accepts three arguments instead of just one: the new (copied) model,
the listener to be replaced, the `tok2vec`/`transformer` pipe from which the new model was copied.
```
new_model = tok2vec_model.attrs["replace_listener"](new_model, replaced_listener, tok2vec)
```