In initialize only calculate current vectors hash if needed (#12607)

This commit is contained in:
Adriane Boyd 2023-05-08 16:51:58 +02:00
parent 42e5043816
commit 2cfbc1209d

View File

@ -133,10 +133,11 @@ def init_vocab(
logger.info("Added vectors: %s", vectors) logger.info("Added vectors: %s", vectors)
# warn if source model vectors are not identical # warn if source model vectors are not identical
sourced_vectors_hashes = nlp.meta.pop("_sourced_vectors_hashes", {}) sourced_vectors_hashes = nlp.meta.pop("_sourced_vectors_hashes", {})
vectors_hash = hash(nlp.vocab.vectors.to_bytes(exclude=["strings"])) if len(sourced_vectors_hashes) > 0:
for sourced_component, sourced_vectors_hash in sourced_vectors_hashes.items(): vectors_hash = hash(nlp.vocab.vectors.to_bytes(exclude=["strings"]))
if vectors_hash != sourced_vectors_hash: for sourced_component, sourced_vectors_hash in sourced_vectors_hashes.items():
warnings.warn(Warnings.W113.format(name=sourced_component)) if vectors_hash != sourced_vectors_hash:
warnings.warn(Warnings.W113.format(name=sourced_component))
logger.info("Finished initializing nlp object") logger.info("Finished initializing nlp object")