spaCy/spacy/tests/parser
Daniël de Kok 5e297aa20e
Add TrainablePipe.{distill,get_teacher_student_loss} (#12016)
* Add `TrainablePipe.{distill,get_teacher_student_loss}`

This change adds two methods:

- `TrainablePipe::distill` which performs a training step of a
   student pipe on a teacher pipe, giving a batch of `Doc`s.
- `TrainablePipe::get_teacher_student_loss` computes the loss
  of a student relative to the teacher.

The `distill` or `get_teacher_student_loss` methods are also implemented
in the tagger, edit tree lemmatizer, and parser pipes, to enable
distillation in those pipes and as an example for other pipes.

* Fix stray `Beam` import

* Fix incorrect import

* Apply suggestions from code review

Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>

* TrainablePipe.distill: use `Iterable[Example]`

* Add Pipe.is_distillable method

* Add `validate_distillation_examples`

This first calls `validate_examples` and then checks that the
student/teacher tokens are the same.

* Update distill documentation

* Add distill documentation for all pipes that support distillation

* Fix incorrect identifier

* Apply suggestions from code review

Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>

* Add comment to explain `is_distillable`

Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
2023-01-16 10:25:53 +01:00
..
__init__.py Revert #4334 2019-09-29 17:32:12 +02:00
_search.pyx Fix v4 branch to build against Thinc v9 (#11921) 2022-12-17 14:32:19 +01:00
test_add_label.py Support negative examples in partial NER annotations (#8106) 2021-06-17 17:33:00 +10:00
test_arc_eager_oracle.py Migrate regression tests into the main test suite (#9655) 2021-12-04 20:34:48 +01:00
test_ner.py Add TrainablePipe.{distill,get_teacher_student_loss} (#12016) 2023-01-16 10:25:53 +01:00
test_neural_parser.py Update config resolution to use new Thinc 2020-09-27 22:21:31 +02:00
test_nn_beam.py Tidy up and auto-format 2021-01-05 13:41:53 +11:00
test_nonproj.py Auto-format code with black (#10945) 2022-06-10 13:21:33 +02:00
test_parse_navigate.py Raise error if deps not provided with heads (#8335) 2021-06-15 13:23:32 +02:00
test_parse.py Add TrainablePipe.{distill,get_teacher_student_loss} (#12016) 2023-01-16 10:25:53 +01:00
test_preset_sbd.py Support negative examples in partial NER annotations (#8106) 2021-06-17 17:33:00 +10:00
test_search.py Fix v4 branch to build against Thinc v9 (#11921) 2022-12-17 14:32:19 +01:00
test_space_attachment.py Tidy up tests and docs 2020-09-21 20:43:54 +02:00
test_state.py Tidy up and auto-format 2021-01-05 13:41:53 +11:00