Google T5 Translation as a Service with Just 7 lines of Codes

What is T5? Text-To-Text Transfer Transformer (T5) from Google gives the power of translation.

In the article, we will deploy Google T5 model as a REST API service. Difficult? What about I’ll tell you: you just need to write 7 lines of codes?

**H…

What is T5? Text-To-Text Transfer Transformer (T5) from Google gives the power of translation.

translation

In the article, we will deploy Google T5 model as a REST API service. Difficult? What about I’ll tell you: you just need to write 7 lines of codes?

translation

**HuggingFace** makes it easy to use the pretrained model with just several lines.

**Pinferencia** makes it super easy to serve any model with just three extra lines.

translation

Install Dependencies

HuggingFace

pip install “transformers[pytorch]”

If it doesn’t work, please visit Installation (huggingface.co) and check their official documentations.

Pinferencia

pip install “pinferencia[uvicorn]”

If it doesn’t work, please visit Install — Pinferencia (underneathall.app) and check their official documentations.

Define the Service

First let’s create the app.py to define the service:

Start the Service

uvicorn app:service --reload

Wait for the model get downloaded. When it’s finished, you’ll see:

finished

Call the Service

You can use curl or the interactive api page from Pinferencia.

Curl

curl

The result:

result

Interactive API Page

api page

Result:

result

If you like Pinferencia don’t forget to go to GitHub and save to your favorites.


Print Share Comment Cite Upload Translate
APA
wjiuhe | Sciencx (2024-03-29T07:05:58+00:00) » Google T5 Translation as a Service with Just 7 lines of Codes. Retrieved from https://www.scien.cx/2022/04/21/google-t5-translation-as-a-service-with-just-7-lines-of-codes/.
MLA
" » Google T5 Translation as a Service with Just 7 lines of Codes." wjiuhe | Sciencx - Thursday April 21, 2022, https://www.scien.cx/2022/04/21/google-t5-translation-as-a-service-with-just-7-lines-of-codes/
HARVARD
wjiuhe | Sciencx Thursday April 21, 2022 » Google T5 Translation as a Service with Just 7 lines of Codes., viewed 2024-03-29T07:05:58+00:00,<https://www.scien.cx/2022/04/21/google-t5-translation-as-a-service-with-just-7-lines-of-codes/>
VANCOUVER
wjiuhe | Sciencx - » Google T5 Translation as a Service with Just 7 lines of Codes. [Internet]. [Accessed 2024-03-29T07:05:58+00:00]. Available from: https://www.scien.cx/2022/04/21/google-t5-translation-as-a-service-with-just-7-lines-of-codes/
CHICAGO
" » Google T5 Translation as a Service with Just 7 lines of Codes." wjiuhe | Sciencx - Accessed 2024-03-29T07:05:58+00:00. https://www.scien.cx/2022/04/21/google-t5-translation-as-a-service-with-just-7-lines-of-codes/
IEEE
" » Google T5 Translation as a Service with Just 7 lines of Codes." wjiuhe | Sciencx [Online]. Available: https://www.scien.cx/2022/04/21/google-t5-translation-as-a-service-with-just-7-lines-of-codes/. [Accessed: 2024-03-29T07:05:58+00:00]
rf:citation
» Google T5 Translation as a Service with Just 7 lines of Codes | wjiuhe | Sciencx | https://www.scien.cx/2022/04/21/google-t5-translation-as-a-service-with-just-7-lines-of-codes/ | 2024-03-29T07:05:58+00:00
https://github.com/addpipe/simple-recorderjs-demo