Skip to content
This repository has been archived by the owner on Dec 11, 2022. It is now read-only.
/ word2vec-pyro4 Public archive

Word Vectors Served via Pyro4.

License

Notifications You must be signed in to change notification settings

nlpub/word2vec-pyro4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Word Vectors Served via Pyro4

This is a simple network service that serves the Gensim's KeyedVectors via Pyro4.

Docker Hub

Running

$ ./server.py
usage: server.py [--id ID] [--no-sims] [-h HOST] [-p PORT] w2v

The only mandatory parameter, w2v, specifies the path to the word vectors in the word2vec format. By default, the server listens to any network interface on the port 9090.

For instance, the following pre-trained vectors are available:

The image is designed under the assumption that the vectors are mounted as /usr/src/app/w2v.bin.

Accessing

import Pyro4

Pyro4.config.SERIALIZER = 'pickle' # see the Disclaimer

w2v = Pyro4.Proxy('PYRO:w2v@localhost:9090')

w2v.word_vec('cat') # => array([…], dtype=float32)

Disclaimer

Note that this service should be running in a trusted environment since it uses the pickle serializer to handle the NumPy arrays. This makes the system extremely vulnerable and even allows arbitrary code execution, which is not recommended by the Pyro4 developers.

Copyright

Copyright (c) 2017–2021 Dmitry Ustalov. See LICENSE for details.