Add warning if initial vectors are empty (#7641)

See #7637, where this came up.
This commit is contained in:
Paul O'Leary McCann 2021-04-05 03:20:24 +09:00 committed by GitHub
parent f6ad4684bd
commit 7944761ba7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -157,6 +157,8 @@ class Warnings:
"`spacy.load()` to ensure that the model is loaded on the correct "
"device. More information: "
"http://spacy.io/usage/v3#jupyter-notebook-gpu")
W112 = ("The model specified to use for initial vectors ({name}) has no "
"vectors. This is almost certainly a mistake.")
@add_codes

View File

@ -133,6 +133,10 @@ def load_vectors_into_model(
)
err = ConfigValidationError.from_error(e, title=title, desc=desc)
raise err from None
if len(vectors_nlp.vocab.vectors.keys()) == 0:
logger.warning(Warnings.W112.format(name=name))
nlp.vocab.vectors = vectors_nlp.vocab.vectors
if add_strings:
# I guess we should add the strings from the vectors_nlp model?