Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent tok2vec to broadcast to listeners when predicting #11385

Merged
merged 7 commits into from
Sep 12, 2022

Conversation

svlandeg
Copy link
Member

@svlandeg svlandeg commented Aug 26, 2022

Description

Addressing the same problem as laid out in explosion/spacy-transformers#342, i.e. the fact that tok2vec.predict broadcasts the outputs to the listeners, breaks the usual contract in which the training mechanism should rely on that broadcasting, but in prediction we should use doc.tensor.

Because we still want to be able to have a frozen (but annotating!) embedding layer, have a fallback in the listener's forward function that will access the doc.tensor even when training, if there is otherwise no valid data available.

Types of change

bug fix

Checklist

  • I confirm that I have the right to submit this contribution under the project's MIT license.
  • I ran the tests, and all new and existing tests passed.
  • My changes don't require a change to the documentation, or if they do, I've added all required information.

@svlandeg svlandeg added bug Bugs and behaviour differing from documentation ⚠️ wip Work in progress feat / pipeline Feature: Processing pipeline and components feat / tok2vec Feature: Token-to-vector layer and pretraining labels Aug 26, 2022
@svlandeg
Copy link
Member Author

We might want to move this to develop, but I wanted to open this PR first to instigate some internal discussion.

@svlandeg svlandeg marked this pull request as ready for review September 7, 2022 15:47
@svlandeg svlandeg removed the ⚠️ wip Work in progress label Sep 7, 2022
@danieldk danieldk merged commit cc10a27 into explosion:develop Sep 12, 2022
@svlandeg svlandeg deleted the bugfix/listener_predict branch September 12, 2022 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs and behaviour differing from documentation feat / pipeline Feature: Processing pipeline and components feat / tok2vec Feature: Token-to-vector layer and pretraining
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants