Skip to content

Commit 393b766

Browse files
polmsvlandeg
authored andcommitted
Add note on batch contract for listeners (explosion#9691)
* Add note on batch contract Using listeners requires batches to be consistent. This is obvious if you understand how the listener works, but it wasn't clearly stated in the Docs, and was subtle enough that the EntityLinker missed it. There is probably a clearer way to explain what the actual requirement is, but I figure this is a good start. * Rewrite to clarify role of caching
1 parent 86f4986 commit 393b766

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

website/docs/api/architectures.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ Instead of defining its own `Tok2Vec` instance, a model architecture like
124124
[Tagger](/api/architectures#tagger) can define a listener as its `tok2vec`
125125
argument that connects to the shared `tok2vec` component in the pipeline.
126126
127+
Listeners work by caching the `Tok2Vec` output for a given batch of `Doc`s. This
128+
means that in order for a component to work with the listener, the batch of
129+
`Doc`s passed to the listener must be the same as the batch of `Doc`s passed to
130+
the `Tok2Vec`. As a result, any manipulation of the `Doc`s which would affect
131+
`Tok2Vec` output, such as to create special contexts or remove `Doc`s for which
132+
no prediction can be made, must happen inside the model, **after** the call to
133+
the `Tok2Vec` component.
134+
127135
| Name | Description |
128136
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
129137
| `width` | The width of the vectors produced by the "upstream" [`Tok2Vec`](/api/tok2vec) component. ~~int~~ |

0 commit comments

Comments
 (0)