pimlico.datatypes.word2vec module

class Word2VecModel(base_dir, pipeline, **kwargs)[source]

Bases: pimlico.datatypes.base.PimlicoDatatype

Datatype for storing Gensim-trained word2vec embeddings.

See also

Datatype pimlico.datatypes.embeddings.Embeddings
Another, more generic way, to write the same data, which should generally be used in preference to this one. Embeddings does not depend on Gensim, but can be converted to Gensim’s data structure easily.
shell_commands = [<pimlico.datatypes.word2vec.NearestNeighboursCommand object>, <pimlico.datatypes.word2vec.VectorCommand object>, <pimlico.datatypes.word2vec.SimilarityCommand object>]
data_ready()[source]

Check whether the data corresponding to this datatype instance exists and is ready to be read.

Default implementation just checks whether the data dir exists. Subclasses might want to add their own checks, or even override this, if the data dir isn’t needed.

load_model()[source]
model
get_software_dependencies()[source]

Check that all software required to read this datatype is installed and locatable. This is separate to metadata config checks, so that you don’t need to satisfy the dependencies for all modules in order to be able to run one of them. You might, for example, want to run different modules on different machines. This is called when a module is about to be executed and each of the dependencies is checked.

Returns a list of instances of subclasses of :class:~pimlico.core.dependencies.base.SoftwareDependency, representing the libraries that this module depends on.

Take care when providing dependency classes that you don’t put any import statements at the top of the Python module that will make loading the dependency type itself dependent on runtime dependencies. You’ll want to run import checks by putting import statements within this method.

You should call the super method for checking superclass dependencies.

class Word2VecModelWriter(base_dir, verb_only=False, **kwargs)[source]

Bases: pimlico.datatypes.base.PimlicoDatatypeWriter

Note

Generally, it’s preferable to use pimlico.datatypes.embeddings.Embeddings, which is more generic, so easier to connect up with general vector/embedding-handling modules.

write_word2vec_model(model)[source]
write_keyed_vectors(vectors)[source]