AI Personal Learning
and practical guidance
Ali-painted frog

MTranServer: CPU-ready offline translation service

General Introduction

MTranServer is an open source server project focused on offline translation, hosted on GitHub and created by developer xxnuo. Its biggest highlight is its ultra-low resource requirements, requiring only a CPU and 1GB of RAM to run, without GPU support, it can achieve an average response speed of 50ms for a single request. The project supports translations in major languages around the world, and the translation quality is close to that of Google Translate, which is suitable for users who need to deploy translation services locally. MTranServer can be deployed quickly via Docker, which makes it convenient for developers or enterprises to use it in network-less environments, and it is a light-weight and efficient translation solution.

MTranServer: Offline Translation Service Runs on Local CPU-1


 

Function List

  • Offline Translation Support: Multi-language translation tasks can be accomplished without the need for an Internet connection, guaranteeing data privacy and stability.
  • ultra-low resource footprint: Runs on CPU and 1GB of RAM only, suitable for deployment on low-profile devices.
  • rapid response: The average response time for a single translation request is 50ms, which is extremely efficient.
  • multilingual translation: Coverage of the world's major languages, with translation results comparable to Google Translate.
  • Docker Deployment: Docker containerization support is provided for quick installation and operation.
  • Open source and free: The code is completely open source and users are free to download, use and modify it.

 

Using Help

Installation process

The installation of MTranServer is mainly realized by Docker, which is suitable for users with basic command line operation ability. The following are the detailed installation steps:

1. Preparing the environment

  • system requirements: Make sure your device is running a Docker-enabled operating system (e.g. Linux, Windows 10/11, or macOS).
  • hardware requirement: At least 1GB of available RAM and a basic CPU, no GPU required.
  • Tool Installation::
    • Check to see if Docker is installed; if not, download and install it from the Docker website.
    • Verify the installation: Open a terminal and type docker --versionIf you see the version number, it means the installation was successful.

2. Download MTranServer

  • Open your browser and visit https://github.com/xxnuo/MTranServer.
  • Click on the green color in the upper right corner of the page Code button, select Download ZIP Download the source code, or clone it using Git:
    git clone https://github.com/xxnuo/MTranServer.git
  • Once the download is complete, unzip the file to a local directory (e.g. ~/MTranServer), or go directly to the cloned folder.

3. Build a Docker image

  • Open a terminal and go to the MTranServer project directory:
    cd ~/MTranServer
    
  • Execute the Docker build command to generate the image:
    docker build -t mtranserver .
    
    • -t mtranserver Naming the mirror.. Indicates that the Dockerfile for the current directory is used.
    • The build process may take a few minutes, depending on network and device performance. When finished, enter docker images Check if the image was generated successfully.

4. Running MTranServer

  • Use the following command to start the container:
    docker run -d -p 5000:5000 mtranserver
    
    • -d indicates that it is running in the background.-p 5000:5000 Maps port 5000 in the container to port 5000 on the host.
  • Verify operation status: Enter docker psIf you see the mtranserver container running, the startup was successful.

5. Testing services

  • Open a browser or use a tool (e.g. Postman, curl) to send a translation request:
    • Example Request:
      curl -X POST http://localhost:5000/translate -H "Content-Type: application/json" -d '{"text": "Hello, world!", "source_lang": "en", "target_ lang": "en", "target_lang": "zh"}'
      
    • Returns a sample result:{"translated_text": "Hello, world!" }
  • If the correct translation result is returned, the service is running normally.

Functional operation flow

1. Offline translation function

  • procedure::
    1. Ensure that the MTranServer is up and running locally (e.g., the http://localhost:5000).
    2. Send the text to be translated via an HTTP POST request in JSON format, containing the following fields:
      • text: The content of the text to be translated (e.g. "Hello, world!").
      • source_lang: Source language code (e.g. "en" for English).
      • target_lang: Target language code (e.g. "zh" for Chinese).
    3. After sending the request, the server returns the translation result, usually within 50ms.
  • caveat: The language code needs to be compliant with international standards (e.g. ISO 639-1), a list of supported languages can be found in the project documentation or in the default configuration.

2. Multilingual support

  • How to use::
    • Adjustments in requests source_lang cap (a poem) target_lang parameter, you can realize the translation between different languages. Example:
      • English to French:{"text": "Good morning", "source_lang": "en", "target_lang": "fr"}
      • Return:{"translated_text": "Bon matin"}
    • Supported languages cover the world's major languages, such as English, Chinese, Spanish, Russian, and so on.
  • Featured Description: No Internet connection is required, and all translation models are built into the server, guaranteeing privacy and speed.

3. Docker container management

  • Start and stop::
    • Stop the service: find the container ID (via docker ps View) and then run:
      docker stop
      
    • Restart the service:
      docker restart
      
  • Log View: If you encounter problems, you can check the container logs to troubleshoot:
    docker logs
    
  • Port Adjustment: If port 5000 is occupied, you can change the mapped port, for example -p 8080:5000and then visit http://localhost:8080The

4. Customized modifications

  • Operating Methods::
    1. Open the project folder and locate the configuration file or translation model directory (refer to the README for the exact path).
    2. Modify code or add language models as needed.
    3. Once the changes are complete, rebuild the image and run it:
      docker build -t mtranserver .
      docker run -d -p 5000:5000 mtranserver
      
  • Applicable Scenarios: Developers can extend the functionality according to actual needs, such as adding small language support or optimizing translation algorithms.

caveat

  • network environment: The first build image may require internet access to download dependencies, subsequent runs are completely offline.
  • performance optimization: If the performance of the device is low, stability can be improved by limiting the number of concurrent requests (configuration file modification required).
  • documentation reference: The Project README is the most authoritative user guide and is recommended to be read carefully for the most up-to-date information.

With the above steps, users can easily deploy and use MTranServer to enjoy efficient offline translation services.

CDN1
May not be reproduced without permission:Chief AI Sharing Circle " MTranServer: CPU-ready offline translation service

Chief AI Sharing Circle

Chief AI Sharing Circle specializes in AI learning, providing comprehensive AI learning content, AI tools and hands-on guidance. Our goal is to help users master AI technology and explore the unlimited potential of AI together through high-quality content and practical experience sharing. Whether you are an AI beginner or a senior expert, this is the ideal place for you to gain knowledge, improve your skills and realize innovation.

Contact Us
en_USEnglish