From 0e4b96c97e1959e7c78d0c35063ff021f2189f82 Mon Sep 17 00:00:00 2001 From: Adriane Boyd Date: Mon, 19 Jul 2021 10:25:54 +0200 Subject: [PATCH] Update lexeme ranks for loaded vectors (#8640) Update the ranks for any lexemes that have been added to the vocab before the vectors are added to the model. --- spacy/training/initialize.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spacy/training/initialize.py b/spacy/training/initialize.py index fa4e13197..6051eef29 100644 --- a/spacy/training/initialize.py +++ b/spacy/training/initialize.py @@ -156,6 +156,8 @@ def load_vectors_into_model( logger.warning(Warnings.W112.format(name=name)) nlp.vocab.vectors = vectors_nlp.vocab.vectors + for lex in nlp.vocab: + lex.rank = nlp.vocab.vectors.key2row.get(lex.orth, OOV_RANK) if add_strings: # I guess we should add the strings from the vectors_nlp model? # E.g. if someone does a similarity query, they might expect the strings.