Offline neural machine translation with local-only, on-device inference. Supports multiple translation models:
- NLLB-200: Meta's No Language Left Behind model (200+ languages, ~2.5GB)
- TranslateGemma: Google's lightweight translation model based on Gemma 3 (55 languages, ~8GB) - Requires a HuggingFace token
- Multiple Models: Choose between NLLB-200 (200+ languages) or TranslateGemma (55 languages)
- Privacy-First: Local translation inference, no data sent to external servers
- Text-to-Speech: Listen to translations in supported languages in the browser
- Saved Translations: Save and revisit your favorite translations
- CLI & Web Interface: Use via terminal or web app
- Fast & Efficient: Optimized models for speed
- Backend: Python, FastAPI, HuggingFace Transformers
- Frontend: React, TypeScript, Tailwind CSS
- Models: Facebook NLLB-200-distilled-600M, Google TranslateGemma-4b-it
- Python 3.11+
- uv - Python package installer and resolver
- ~3GB disk space for NLLB-200, ~8GB for TranslateGemma
- For TranslateGemma: Hugging Face account and token (see below)
-
Install dependencies:
uv sync
-
Download a translation model:
NLLB-200 (default, ~2.5GB):
uv run bab download
TranslateGemma (~8GB):
uv run bab download --model translategemma
Note: TranslateGemma requires accepting the license on Hugging Face and setting the
HF_TOKENenvironment variable. Visit https://huggingface.co/google/translategemma-4b-it to accept the license. -
Verify the model files:
uv run bab verify # Or for a specific model: uv run bab verify --model translategemma -
Run the development server:
uv run fastapi dev server/main.py
-
Open http://localhost:8000 in your browser to see the API.
| Model | Languages | Size | Auth Required |
|---|---|---|---|
nllb |
200+ | ~2.5GB | No |
translategemma |
55 | ~8GB | Yes (HF token) |
List all models with their download status:
uv run bab modelsThe bab CLI provides commands for managing translation models:
uv run bab modelsuv run bab status
uv run bab status --model translategemmaShows whether the model is downloaded and loaded, along with storage location and size.
uv run bab download
uv run bab download --model translategemmaDownloads the model to the local cache. Use --force to re-download:
uv run bab download --forceuv run bab verify
uv run bab verify --model translategemmaChecks that all required model files are present.
uv run bab languages
uv run bab languages --model translategemmaShows all supported languages for the specified model.
uv run bab load-test
uv run bab load-test --model translategemmaLoads the model into memory to verify it works correctly.
uv run bab translate "Hello, world!" -s eng_Latn -t fra_Latn
uv run bab translate "Hello, world!" -s en -t fr --model translategemmaNote: Language codes differ between models. Use bab languages --model <id> to see available codes.
uv run bab delete
uv run bab delete --model translategemmaAll commands support a custom cache directory:
uv run bab --cache-dir /path/to/cache statusRun without arguments to enter interactive mode:
uv run babCommands in interactive mode:
/model- Select translation model/source- Set source language/target- Set target language/swap- Swap languages/status- Show status/languages- List languages/models- List models/help- Show help
Once the server is running, visit:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Models:
GET /model/list- List available modelsGET /model/list/status- Get status of all modelsGET /model/status?model_id=nllb- Get status of a specific modelPOST /model/download?model_id=nllb- Download a modelPOST /model/remove?model_id=nllb- Remove a model
Translation:
POST /translate- Translate text{ "text": "Hello", "source_language_code": "eng_Latn", "target_language_code": "fra_Latn", "model_id": "nllb" }
Languages:
GET /languages?model_id=nllb- Get supported languages
TranslateGemma requires authentication with Hugging Face:
-
Create a Hugging Face account at https://huggingface.co
-
Visit https://huggingface.co/google/translategemma-4b-it and accept the license
-
Create an access token at https://huggingface.co/settings/tokens
-
Set the
HF_TOKENenvironment variable:export HF_TOKEN=hf_your_token_here uv run bab download --model translategemma
babelo/
├── cli/
│ ├── cli.py # CLI commands
│ └── interactive/ # Interactive mode
├── core/
│ ├── model.py # Model registry and backends
│ ├── languages.py # Language code mappings
│ ├── database.py # Saved translations storage
│ └── preferences.py # User preferences
├── frontend/
│ └── src/
│ ├── components/
│ │ ├── ModelSelector.tsx
│ │ └── ...
│ ├── hooks/
│ └── utils/
├── server/
│ └── routes/
│ ├── model.py # Model management endpoints
│ ├── translate.py # Translation endpoint
│ ├── languages.py # Languages endpoint
│ └── ...
├── tests/
├── README.md
└── pyproject.toml
uv run pytestWith verbose output:
uv run pytest -vuv add <package-name>uv add --dev <package-name>NLLB-200-Distilled-600M from Meta AI.
- Model size: ~2.5GB
- Supported languages: 200+ languages
- Architecture: Encoder-Decoder Transformer
- Language codes: BCP-47 style (e.g.,
eng_Latn,fra_Latn)
TranslateGemma-4b-it from Google.
- Model size: ~8GB
- Supported languages: 55 languages
- Architecture: Gemma 3 based multimodal model
- Language codes: ISO 639-1 (e.g.,
en,fr,de-DE) - License: Requires accepting Gemma license on Hugging Face