This is a very simple python api implementation for fastText https://github.com/facebookresearch/fastText.git
It is intended as an small proof of concept of a flask API exposing trained models.
git clone https://github.com/TheCodingLand/fastTextApi
cd fastTextApi
docker build . -t fasttext
docker run -p 5000:5000 -v fasttext:/data fasttext
open a browser and go to yourdockerhost:5000
I included an example model, named language, with version 0, supervised, quantized :
load the model :
{
"name": "language",
"version": 0,
"supervised": true,
"quantized": true
}
try the predict post method :
{
"name": "language",
"version": 0,
"text": "reanu keeves is an handsome man",
"nbofresults": 2
}
returns :
{
"status": "success",
"results": [
{
"category": "en",
"confidence": 0.9863510129824254
},
{
"category": "fr",
"confidence": 0.005755515951242966
}
]
}
you can add your models files into
/var/lib/docker/volumes/fasttext/_data/models/{modelname}/{modelversion}/model.ftz or model.bin
and query them like :
{
"name": "modelname",
"version": version,
"text": "my text to test",
"nbofresults": x number of results I want
}
This is the minimal working version.