Skip to content

About

Free and Open Source Machine Translation API with LLM capabilities. Self-hosted, offline capable and easy to setup.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

LibreTranslate

Try it online! | API Docs | Community Forum | Bluesky

Python versions Run tests Build and Publish Docker Image Publish package Awesome Humane Tech

Free and Open Source Machine Translation API, entirely self-hosted. Unlike other APIs, it doesn't rely on proprietary software such as Google or Azure to perform translations. Instead, its translation engine is powered by the open source Argos Translate library.

This fork adds optional Ollama integration, allowing you to use LLM-based translation models such as Translategemma as an alternative translation backend.

Translation

Getting Started

Ollama LLM Translation

Prerequisites

  • A running Ollama instance
  • The Translategemma model pulled into Ollama:
    ollama pull translategemma

Configuration

Enable the feature via CLI arguments or environment variables:

CLI Argument Environment Variable Default Description
--ollama LT_OLLAMA_ENABLED=true false Enable the Ollama translation backend
--ollama-host LT_OLLAMA_HOST http://localhost:11434 Ollama API URL
--ollama-model LT_OLLAMA_MODEL translategemma Model to use for translation
--ollama-system-prompt LT_OLLAMA_SYSTEM_PROMPT (see below) System prompt to constrain model output

The default system prompt is:

You are a translation engine. Output only the translated text without any explanation, notes, or additional content.

You can override it to fine-tune the model behaviour, e.g.:

libretranslate --ollama --ollama-system-prompt "Translate the following text. Return only the translation, nothing else."

Example:

libretranslate --ollama --ollama-host http://localhost:11434 --ollama-model translategemma

Or with environment variables:

LT_OLLAMA_ENABLED=true LT_OLLAMA_HOST=http://localhost:11434 libretranslate

Usage

When Ollama is enabled, a toggle switch labeled "LLM Translation (Ollama)" appears in the web UI between the language selectors and the text fields. Users can switch between the standard Argos Translate engine and the Ollama-backed LLM translation at any time. The preference is stored in the browser and persists across page reloads.

The feature can also be used via the API by adding use_ollama=true to the /translate request:

curl -X POST http://localhost:5000/translate \
  -d "q=Hello world&source=en&target=de&use_ollama=true"

Credits

This work is largely possible thanks to Argos Translate, which powers the translation engine.

License

GNU Affero General Public License v3

Trademark

See Trademark Guidelines

About

Free and Open Source Machine Translation API with LLM capabilities. Self-hosted, offline capable and easy to setup.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages