All Projects → nielsen-oss → fasttext-serving

nielsen-oss / fasttext-serving

Licence: Apache-2.0 license
Serve your fastText models for text classification and word vectors

Programming Languages

python
139335 projects - #7 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to fasttext-serving

Text Classification Demos
Neural models for Text Classification in Tensorflow, such as cnn, dpcnn, fasttext, bert ...
Stars: ✭ 144 (+585.71%)
Mutual labels:  fasttext
Cw2vec
cw2vec: Learning Chinese Word Embeddings with Stroke n-gram Information
Stars: ✭ 224 (+966.67%)
Mutual labels:  fasttext
bodywork-ml-pipeline-project
Deployment template for a continuous training pipeline.
Stars: ✭ 22 (+4.76%)
Mutual labels:  serving
Fasttext4j
Implementing Facebook's FastText with java
Stars: ✭ 148 (+604.76%)
Mutual labels:  fasttext
Sentence Classification
Sentence Classifications with Neural Networks
Stars: ✭ 177 (+742.86%)
Mutual labels:  fasttext
Pytorch Sentiment Analysis
Tutorials on getting started with PyTorch and TorchText for sentiment analysis.
Stars: ✭ 3,209 (+15180.95%)
Mutual labels:  fasttext
Whatthelang
Lightning Fast Language Prediction 🚀
Stars: ✭ 130 (+519.05%)
Mutual labels:  fasttext
Boostcamp-AI-Tech-Product-Serving
[Machine Learning Engineer Basic Guide] 부스트캠프 AI Tech - Product Serving 자료
Stars: ✭ 280 (+1233.33%)
Mutual labels:  serving
Shallowlearn
An experiment about re-implementing supervised learning models based on shallow neural network approaches (e.g. fastText) with some additional exclusive features and nice API. Written in Python and fully compatible with Scikit-learn.
Stars: ✭ 196 (+833.33%)
Mutual labels:  fasttext
Simple-Sentence-Similarity
Exploring the simple sentence similarity measurements using word embeddings
Stars: ✭ 99 (+371.43%)
Mutual labels:  fasttext
Embedding As Service
One-Stop Solution to encode sentence to fixed length vectors from various embedding techniques
Stars: ✭ 151 (+619.05%)
Mutual labels:  fasttext
Wordvectors
Pre-trained word vectors of 30+ languages
Stars: ✭ 2,043 (+9628.57%)
Mutual labels:  fasttext
Ai law
all kinds of baseline models for long text classificaiton( text categorization)
Stars: ✭ 243 (+1057.14%)
Mutual labels:  fasttext
Wordembeddings Elmo Fasttext Word2vec
Using pre trained word embeddings (Fasttext, Word2Vec)
Stars: ✭ 146 (+595.24%)
Mutual labels:  fasttext
Text Classification TF
用tf实现各种文本分类模型,并且封装restful接口,可以直接工程化
Stars: ✭ 32 (+52.38%)
Mutual labels:  fasttext
Nlp research
NLP research:基于tensorflow的nlp深度学习项目,支持文本分类/句子匹配/序列标注/文本生成 四大任务
Stars: ✭ 141 (+571.43%)
Mutual labels:  fasttext
Pyfasttext
Yet another Python binding for fastText
Stars: ✭ 229 (+990.48%)
Mutual labels:  fasttext
actions-suggest-related-links
A GitHub Action to suggest related or similar issues, documents, and links. Based on the power of NLP and fastText.
Stars: ✭ 23 (+9.52%)
Mutual labels:  fasttext
fastchess
Predicts the best chess move with 27.5% accuracy by a single matrix multiplication
Stars: ✭ 75 (+257.14%)
Mutual labels:  fasttext
fasttextjs
JavaScript implementation of the FastText prediction algorithm
Stars: ✭ 31 (+47.62%)
Mutual labels:  fasttext

FastText Serving

FastText Serving is a simple and efficient serving system for fastText models. Inspired by TensorFlow Serving, it provides the missing piece in the microservice puzzle to connect your business logic with basic Natural Language Processing (NLP). The idea of this project is to provide an elegant and reusable implementation for managing several fastText models, allowing to run concurrent multi model predictions. The API of the service is based on gRPC to reduce network latency and deliver higher throughput. For instance, you can run millions of predictions in around one second using just a single CPU.

The service has been developed in Python, making use of Facebook's fastText library for running predictions over text pieces (words, sentences, paragraphs, etc.). The fastText API is used through the Python bindings provided in the official project. Clients of the service can boost their performance by sending multiple sentences grouped in batches within the same request as the fastText library is compiled as a binary.

Serving models are determined by reading the contents of a configuration file. These models are cached in memory depending on the amount of memory available and the size of the model. Every request is dispatched to the model specified in the body of that request. In addition, models are reloaded when a newer version is published or the file contents are changed in disk, thanks to the watchdog library.

Features

These are the most interesting features of this project:

  • Concurrent management and serving of different models
  • Model versioning, allowing A/B test with concurrent requests to different versions
  • Hot model serving, loading the new model as soon as a new version is detected in the storage
  • Both bag of words and skip-gram models are supported
  • gRPC API

Quick Start

# Clone the repository
git clone https://github.com/nielsen-oss/fasttext-serving
cd fasttext-serving

# Build the Docker image
IMAGE_NAME=fasttext-serving
docker image build -t IMAGE_NAME .

# Start serving some example models
docker run -p 50051:50051 \
  -v ${PWD}/sample/models:/models \
  -v ${PWD}/sample/config.yaml:/etc/fts/config.yaml \
  -e SERVICE_CONFIG_PATH=/etc/fts/config.yaml \
  IMAGE_NAME 

# You can download pretrained models from fasttext webpage
# https://fasttext.cc/docs/en/supervised-models.html
# Do not forget to include the model in the models section of the config
wget https://dl.fbaipublicfiles.com/fasttext/supervised-models/dbpedia.ftz -P sample/models/dbpedia/1/

# Install requirements
pip3 install -r requirements.txt

# Compile protocol buffers (required by the client)
pip3 install .

# Make predictions using the example client
python3 sample/client.py

API

The gRPC API exposes a set of methods for performing model management and predictions with fastText. More specifically, the service provides this functionalities:

  • Classify a sentence
  • Get the words vectors of a set of words
  • Get currently loaded models
  • Load a list of models
  • Reload the models in the configuration file
  • Get the status of a given model:
    • UNKNOWN: The model is not defined in the configuration file
    • LOADED: The model is cached in memory and ready to make predictions
    • AVAILABLE: The model is defined but not loaded, due to resource constraints
    • FAILED: The model is not loaded due to a different internal error

The complete specification can be found in the protocol buffer definition in the protos directory.

Troubleshooting

  • Newer versions of the model are not loaded.

    Check that the model has the extension .ftz or .bin and the path where the file has been uploaded. Also review your config file to check that the model is listed in the models section

  • Predictions are too slow.

    Send all the predictions to the same model in bigger batches. Increase the maximum number of concurrent workers in the service configuration.

Contact

You can open an issue in this project of just email your questions or comments to Francisco Delgado or Javier Tovar

Contribute

Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.

We recommend you to work in an isolated virtual environment:

git clone https://github.com/nielsen-oss/fasttext-serving
cd fasttext-serving
python3 -m venv venv
source venv/bin/activate
export SERVICE_CONFIG_PATH="sample/config.yaml"
python3 -m fts

And do not forget to pass the tests and add yours:

python3 test/test_suite.py

License

This project is released under the terms of the Apache 2.0 License.

Acknowledgements

Big thanks to these third-party projects used by fastText Serving:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].