Add vectors registry

This commit is contained in:
Adriane Boyd 2023-07-31 18:04:30 +02:00
parent 808cc947fa
commit ffbc4af216
4 changed files with 4 additions and 3 deletions

View File

@ -27,7 +27,7 @@ batch_size = 1000
@tokenizers = "spacy.Tokenizer.v1"
[nlp.vectors]
@misc = "spacy.Vectors.v1"
@vectors = "spacy.Vectors.v1"
# The pipeline components and their models
[components]

View File

@ -1774,7 +1774,7 @@ class Language:
# fill in [nlp.vectors] if not present (as a narrower alternative to
# auto-filling [nlp] from the default config)
if "vectors" not in config["nlp"]:
config["nlp"]["vectors"] = {"@misc": "spacy.Vectors.v1"}
config["nlp"]["vectors"] = {"@vectors": "spacy.Vectors.v1"}
config_lang = config["nlp"].get("lang")
if config_lang is not None and config_lang != cls.lang:
raise ValueError(

View File

@ -118,6 +118,7 @@ class registry(thinc.registry):
augmenters = catalogue.create("spacy", "augmenters", entry_points=True)
loggers = catalogue.create("spacy", "loggers", entry_points=True)
scorers = catalogue.create("spacy", "scorers", entry_points=True)
vectors = catalogue.create("spacy", "vectors", entry_points=True)
# These are factories registered via third-party packages and the
# spacy_factories entry point. This registry only exists so we can easily
# load them via the entry points. The "true" factories are added via the

View File

@ -98,7 +98,7 @@ cdef class BaseVectors:
return self
@util.registry.misc("spacy.Vectors.v1")
@util.registry.vectors("spacy.Vectors.v1")
def create_mode_vectors() -> Callable[["Vocab"], BaseVectors]:
def vectors_factory(vocab: "Vocab") -> BaseVectors:
return Vectors(strings=vocab.strings)