Stop using Google Translate, build your own artificial intelligence application, learn how to use Hugging Face LLM and Python to translate long documents into your language without any restrictions

In today's globalized world, communicating with people from different countries and cultures is becoming more and more important. However, language barriers often hinder effective communication. While Google Translate has become a popular tool for bridging this gap, it has its limitations, especially when it comes to accurately translating longer texts.

I get really annoyed with copy/pasting small chunks of text into google translate, waiting for the results, copying it into my file...copy, paste, repeat...so why not use our face hugging swiss army to solve this Woolen cloth?

There are also concerns about the privacy and security of using third-party services to translate sensitive information. In this article, we'll explore an alternative solution to building your own AI translation application using Hugging Face. By building your own translation application, you can ensure the privacy and security of your data, while still achieving fairly accurate translations for longer texts.

To summarize the steps we will take:

安装依赖项
创建文件夹结构并下载语言模型
测试模型
创建 Streamlit 界面

The result will be something like this

insert image description here

install dependencies

There aren't many packages we need: we want to access the Hugging Face model, create long text blocks and graphical interfaces.

But first, as a good practice, let's create a virtual environment for new python projects. Create a brand new directory (mine is AI_translator) and run the venv create command:

mkdir AI_translator
cd AI_translator
python3.10 -m venv venv  #version 3.10 is reccomended

Activate the virtual environment:

so

Guess you like

Origin blog.csdn.net/iCloudEnd/article/details/132037278