Report this

What is the reason for this report?

Translating bulk documents with ERNIE 4.5 1-Click GPU Droplets

Published on July 16, 2025
James Skelton

By James Skelton

Technical Evangelist // AI Arcanist

Translating bulk documents with ERNIE 4.5 1-Click GPU Droplets

Here at DigitalOcean, we are committed to bringing the best AI technologies to our users. From awesome serverless inference tools to powerful RAG pipelines, users can always look out for the best, Open-Source LLMs on GradientAI.

This week, we are excited to announce that we are expanding the GradientAI lineup further by adding the ERNIE 4.5 21B model to our 1-Click Deployment lineup, joining models like distilled R1 Qwen and Llama. ERNIE 4.5, developed by the researchers at Baidu, is the latest in their series of Deep Learning Large Language Models, and it offers powerful capabilities for its users.

In this tutorial, we show how to use an ERNIE 4.5 1-Click GPU Droplet to bulk translate files from English to Chinese. This methodology allows users to rapidly translate files for localization effort using the newest SOTA in bilingual language modeling, out performing models like Qwen3 at translation tasks.

Follow along for step by step instructions on running this process on a DigitalOcean 1-Click GPU Droplet.

Key Takeaways

  • ERNIE 4.5 21B is now available on GradientAI 1-Click GPU Droplets
  • It’s easy to set up and run ERNIE with the 1-Click GPU Droplet
  • ERNIE is a powerful translation tool, making it simple to translate documents at scale with a short python script

Setting up the 1-Click GPU Droplet

The steps for getting started with the 1-Click GPU Droplet are outlined in the ERNIE marketplace page and the Jupyter set up tutorial, but we will quickly outline them here.

image

First, login to your DigitalOcean account and navigate to the GPU Droplets tab in the sidebar.

image

Second, click the 1-Click option in the GPU Droplet creation window, and scroll down to select ERNIE from the options.

Finally, click an appropriately powerful GPU for the Droplet. We recommend using the NVIDIA H100 for this task.

There is one additional step here to remember: make sure that you have assigned an SSH key to the GPU Droplet. We will need this later, as we will use VS Code (or Cursor) to access Jupyter Labs on our local browser.

With everything done, we can name and launch our GPU Droplet.

Running ERNIE on the GPU Droplet

Once your GPU Droplet is spun up, we can get started setting up our environment to run the GPU Droplet. First, we will create a virtual environment for testing and install relevant packages in the environment. Once that is complete, we can launch our GPU Droplet’s Jupyter Lab in our local browser, and, finally, we will run Python code to do the translations.

Paste the following into the terminal window.

python3 -m venv venv
source venv/bin/activate
pip3 install openai jupyter 

This will install everything required for us to run the 1-Click model translation process! Just paste the following into the terminal, and then use the process described within this tutorial to access the Jupyter Lab window on your local browser.

jupyter lab --allow-root

Take the link output, and put it into the simple browser of your host connected VS Code/Cursor window. Then, click the button to the right of the URL bar to open the link in your default browser.

Translating bulk documents from English to Chinese

ERNIE shines across a variety of LLM tasks, but one of the most notable features of the model family is their bilingual capabilities: they can write English and Chinese fluently. This offers serious potential for localization efforts.

To facilitate this experiment, we have created the following Python script. In practice, this script takes the inputted text files from a specified directory, and outputs the translated versions of those text files to the output directory. Check out the code below.

import os
from openai import OpenAI  # or your specific OpenAI client import

# Instantiate your API client (replace with your specific client setup)
client = OpenAI(base_url="http://localhost:8000/v1/", api_key={YOUR-API-KEY})

def translate_files(input_dir, output_dir):
    # Ensure output directory exists
    os.makedirs(output_dir, exist_ok=True)

    # Iterate through all files in the given directory
    for filename in os.listdir(input_dir):
        input_filepath = os.path.join(input_dir, filename)

        # Check if it's a regular file (skip directories)
        if os.path.isfile(input_filepath):
            combined_text = ""  # Reset combined text for each file

            # Open and read the file content line-by-line
            with open(input_filepath, 'r', encoding='utf-8') as file:
                lines = file.readlines()
                for line in lines:
                    line = line.strip()
                    if line:  # Skip empty lines
                        chat_completion = client.chat.completions.create(
                            model="baidu/ERNIE-4.5-21B-A3B-Base-PT",
                            messages=[
                                {"role": "system", "content": "You are a helpful translator assistant."},
                                {"role": "user", "content": f"Translate the following to Chinese: {line}"}
                            ],
                            temperature=0.7,
                            top_p=0.95,
                            max_tokens=1024
                        )

                        translated_line = chat_completion.choices[0].message.content
                        combined_text += translated_line + "\n"
            
            # Save translated text to a new file in output directory
            output_filepath = os.path.join(output_dir, f"{os.path.splitext(filename)[0]}_translated.txt")
            with open(output_filepath, 'w', encoding='utf-8') as output_file:
                output_file.write(combined_text)

            print(f"File '{filename}' translated and saved as '{output_filepath}'")

# Example usage
input_directory = "YOUR INPUT DIRECTORY HERE"
output_directory = "YOUR OUTPUT DIRECTORY HERE"
translate_files(input_directory, output_directory)

In our experiments, using Google Translate as our bar for translation skill, we found that Baidu was incredibly capable at the translation tasks we assigned to it. It can accurately, line by line, translate the submitted documents in mere moments. The potential here for translation task automation cannot thus be understated. With simple adjustments, this same script could be applied to a wide variety of different file types, like markdown or doc files, as well.

Closing Thoughts

Translation is just one of the many things that ERNIE 1-Click Droplets can do. We are excited to experiment further with the model, using it to assist us with coding tasks, especially, and apply it to various situations where we use LLMs to assist us with research. We encourage everyone to experiment with the new 1-Click Droplet with ERNIE to see what the latest from Baidu can really do!

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the author

James Skelton
James Skelton
Author
Technical Evangelist // AI Arcanist
See author profile

Still looking for an answer?

Was this helpful?


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Creative CommonsThis work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License.
Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.