napoler / gensim-fasttext-service

A simple web service wrapped up by Gensim's FastText model. Demo only

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FastText Web Service for AG

A web service wrapping up Gensim's FastText model and similarity query based on lee_background corpus.

Install

Install all dependencies by the given requirements.txt.

> python install -r requirements.txt

Using a virtual environment is highly recommended.

Before starting the web service, build the FastText model by running:

> python -m script.build_model

Start the web service

> gunicorn service.app:app -c ./gunicorn.py --worker-connections 100

Users can configure the way of how to start the service in gunicorn.py. Currently, the default setup is:

bind = "0.0.0.0:8080"
workers = 1
timeout = 30
worker_class = "gevent"

For more details of deplyoing Gunicorn, please visit here.

APIs

/most-similar

A POST method that exposes Gensim's similarity query functionality.

> curl -X POST -F "word=toys" -F "topn=5"  localhost:8080/most-similar
["and","spinner","sand","initial","negelected"]

The topn is set to be 10 by default:

> curl -X POST -F "word=toys" "localhost:8080/most-similar"
["and","spinner","hijacked","initial","sand","negelected","land","hand","december","hijackings"]

/health-check

A helper API to check service's availability.

> curl -X GET "http://localhost:8080/health-check"
YES

About

A simple web service wrapped up by Gensim's FastText model. Demo only


Languages

Language:Python 79.2%Language:Shell 15.1%Language:Dockerfile 5.8%