Productionize NLP models trained on Pytorch by AIResearch.in.th
This repository contains examples converting trained pytorch models to REST APIs using fastapi and docker.
We can serve the machine translation models in nmt_inference_examples.ipynb
as REST API on your machine with the following steps:
-
Clone this repository
-
Download models
-
"SCB_1M-MT_OPUS+TBASE_th-en_spm-spm_32000-joined_v1.0"
-
"SCB_1M-MT_OPUS+TBASE_en-th_spm-spm_32000-joined_v1.0"
from https://airesearch.in.th/releases/machine-translation-models/ or https://github.com/vistec-AI/model-releases/releases/tag/SCB_1M%2BTBASE_v1.0
and put it under directory "/app/"
-
-
Decompress all downloaded files
-
Run docker as following commands
docker build -t ai2api .
docker run -d --name myapi -p 80:80 ai2api
- Perform health check
curl --location --request GET 'http://localhost/'
- Translate EN to TH
curl --location --request POST 'http://localhost/translate' \
--data-raw '{
"text": "Sweet!",
"source": "en",
"target": "th"
}'
- Translate TH to EN
curl --location --request POST 'http://localhost/translate' \
--data-raw '{
"text": "น่ารักจัง",
"source": "th",
"target": "en"
}'
-
Industry-grade productionization tutorials
-
Cookie cutter templates for other models