Skip to content

Productionize NLP models trained on Pytorch by AIResearch.in.th

License

Notifications You must be signed in to change notification settings

vistec-AI/ai2api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ai2api

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.

Getting Started with Machine Translation Models

We can serve the machine translation models in nmt_inference_examples.ipynb as REST API on your machine with the following steps:

  1. Clone this repository

  2. 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/"

  3. Decompress all downloaded files

  4. Run docker as following commands

docker build -t ai2api .

docker run -d --name myapi -p 80:80 ai2api
  1. Perform health check
curl --location --request GET 'http://localhost/'
  1. Translate EN to TH
curl --location --request POST 'http://localhost/translate' \
--data-raw '{
    "text": "Sweet!",
    "source": "en",
    "target": "th"
}'
  1. Translate TH to EN
curl --location --request POST 'http://localhost/translate' \
--data-raw '{
    "text": "น่ารักจัง",
    "source": "th",
    "target": "en"
}'

To-do

  • Industry-grade productionization tutorials

  • Cookie cutter templates for other models

About

Productionize NLP models trained on Pytorch by AIResearch.in.th

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published