MTranServer

repository·main·Indexed 26 days ago

https://github.com/xxnuo/mtranserver

A high-speed, low-resource offline translation model server designed for cross-platform deployment. It provides millisecond-level response times for major world languages without requiring a GPU. The project includes a Node.js/Bun library via the MTran class, a CLI binary, and a Docker image. It features compatibility layers for Immersive Translate, DeepL, Google Translate, and other plugins, and supports single and batch translation via a REST API.

Tokens
14.9K
Snippets
30
Records
77
Agent score
85%

What's inside mtranserver

  1. Overview of MTranServer

    main

    MTranServer is an ultra-fast offline translation model server designed for minimal resource consumption. It does not require a GPU and achieves an average response time of 50ms per request. It supports major world languages and focuses on offline translation, response speed, multi-platform deployment, and local execution to provide unlimited free translation.

    Note: Due to model optimization for speed and size, translation quality may not match large-scale online translation models. For high-quality requirements, online LLM APIs are recommended.

  2. Compare MTranServer with alternative translation projects

    main

    If you are evaluating translation solutions, MTranServer is optimized for low memory usage, high concurrency, and extremely fast response times (averaging 50ms per request).

    Below is a comparison of MTranServer against other common projects based on CPU-based English-to-Chinese translation tests:

    ProjectMemory UsageConcurrencyTranslation QualitySpeedNotes
    本项目 (MTranServer)LowHighAverageExtremely FastAvg response 50ms
    NLLBVery HighPoorAverageSlowOptimized in RTranslator for Android
    LibreTranslateVery HighAverageAverageMediumMid-range CPU: 3 sentences/s; High-end: 15-20 sentences/s
    OPUS-MTHighAverageSlightly PoorFast
    Other LLMsUltra HighDynamicVery GoodVery SlowHigh hardware requirements; use vllm for high concurrency

    Note: These comparisons are based on simple CPU tests for English-to-Chinese translation and are for reference only.

  3. Compare MTranServer with similar translation projects

    main

    MTranServer is optimized for low memory usage, high concurrency, and ultra-fast performance (averaging 50ms response time per request) compared to other translation solutions. Use the following comparison as a reference for selecting the right tool based on your hardware and performance requirements:

    Project NameMemory UsageConcurrencyTranslation QualitySpeedAdditional Info
    MTranServerLowHighAverageUltra Fast50ms average response time per request.
    NLLBVery HighPoorAverageSlowAndroid port RTranslator has many optimizations but remains resource-heavy.
    LibreTranslateVery HighAverageAverageMediumMid-range CPU: 3 sentences/s; High-end CPU: 15-20 sentences/s.
    OPUS-MTHighAverageBelow AverageFastSee CTranslate2 benchmarks.
    Any LLMExtremely HighDynamicVery GoodVery SlowHigh hardware requirements; vllm recommended for high concurrency.

    Note: Data is based on CPU-based English-to-Chinese testing using non-quantized versions and is for reference only.

  4. Deploy MTranServer using Docker Compose

    main

    For containerized deployment, create a compose.yml file in an empty directory and use the following configuration. This setup maps the local ./models directory to the container to persist downloaded models and exposes port 8989.

    services:
      mtranserver:
        image: xxnuo/mtranserver:latest
        container_name: mtranserver
        restart: unless-stopped
        ports:
          - "8989:8989"
        environment:
          - MT_HOST=0.0.0.0
          - MT_PORT=8989
          - MT_OFFLINE=false
          # - MT_API_TOKEN=ihr_geheimer_token_hier
        volumes:
          - ./models:/app/models

    Then run:

    docker pull xxnuo/mtranserver:latest
    docker compose up -d
  5. Configure Immersive Translate with MTranServer

    main

    To use MTranServer with the Immersive Translate plugin:

    1. In Immersive Translate settings, enable Beta features in Developer Mode.
    2. Under Translation Services, find Custom API Settings.
    3. Set the API URL based on your security requirements:
      • Without password: http://localhost:8989/imme
      • With password: http://localhost:8989/imme?token=your_token (replace your_token with your MT_API_TOKEN).
    4. To maximize performance, increase Max requests per second (e.g., to 512) and set Max paragraphs per request to 1 in the Custom API settings.
  6. Configure compatible translation plugin interfaces

    main

    MTranServer provides compatibility interfaces for several popular translation plugins and APIs. You can configure these by setting the appropriate URL in your plugin's settings.

    Supported Interfaces

    InterfaceMethodDescription
    /immePOSTImmersive Translate plugin interface
    /kissPOSTKiss Translator plugin interface
    /deeplPOSTDeepL API v2 compatibility interface
    /deeplxPOSTDeepLX compatibility interface
    /hcfyPOSTSelection Translator (划词翻译) compatibility interface
    /google/language/translate/v2POSTGoogle Translate API v2 compatibility interface
    /google/translate_a/singleGETGoogle translate_a/single compatibility interface

    Plugin Configuration Mapping

    Use the following URLs to connect your plugins to the MTranServer instance (assuming default port 8989):

    Plugin NameURLConfiguration Note
    Immersive Translate (No Token)http://localhost:8989/immeSet in Custom API Settings -> API URL
    Immersive Translate (With Token)http://localhost:8989/imme?token=your_tokenReplace your_token with your MT_API_TOKEN
    Kiss Translator (No Token)http://localhost:8989/kissSet in Interface Settings -> Custom -> URL
    Kiss Translator (With Token)http://localhost:8989/kissSet KEY to your your_token
    DeepL Compatibilityhttp://localhost:8989/deeplUse DeepL-Auth-Key or Bearer authentication
    DeepLX Compatibilityhttp://localhost:8989/deeplxSupports token parameter or Bearer authentication
    Google Compatibilityhttp://localhost:8989/google/language/translate/v2Use key parameter or Bearer authentication
    Selection Translator (划词翻译)http://localhost:8989/hcfySupports token parameter or Bearer authentication
  7. Use MTranCode for IDE comment translation

    main

    MTranCode is a plugin for VS Code, Cursor, Augment, and other VS Code-based IDEs that translates code comments.

    1. Search for MTranCode in your IDE's plugin marketplace and install it.
    2. By default, it attempts to connect to the server at http://localhost:8989. You can change this address in the plugin settings if your server is hosted elsewhere.
  8. Use MTranCode IDE Plugin

    main

    MTranCode is a comment translation plugin that supports VS Code-based IDEs including VS Code, Cursor, and Augment.

    1. Search for MTranCode in your IDE's extension marketplace to install it.
    2. By default, the plugin calls the server at http://localhost:8989 to translate comments and code. You can change this address in the plugin settings.
  9. Configure Kiss Translator for high performance

    main

    To fully utilize MTranServer performance in the Kiss Translator plugin:

    1. Scroll down to the Custom interface in the Settings page.
    2. Set Maximum Concurrent Requests (e.g., 100).
    3. Set Request Interval Time (e.g., 1).
    4. Adjust these values based on your specific server hardware configuration.