From 6357d62ca2256cb7b3d3c9d74903990c0572c912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danie=CC=88l=20de=20Kok?= Date: Wed, 1 Feb 2023 20:15:07 +0100 Subject: [PATCH] Language.update: call pipe finish_update after all pipe updates This does correct and fast updates if multiple components update the same parameters. --- spacy/language.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/spacy/language.py b/spacy/language.py index 4c0cd10bd..2364e0893 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -1155,7 +1155,7 @@ class Language: and isinstance(proc, ty.TrainableComponent) and proc.is_trainable ): - proc.update(examples, sgd=sgd, losses=losses, **component_cfg[name]) + proc.update(examples, sgd=None, losses=losses, **component_cfg[name]) if name in annotates: for doc, eg in zip( _pipe( @@ -1168,6 +1168,14 @@ class Language: examples, ): eg.predicted = doc + for name, proc in self.pipeline: + if ( + name not in exclude + and isinstance(proc, ty.TrainableComponent) + and proc.is_trainable + ): + proc.finish_update(sgd) + return losses def rehearse(