Multilingual Parallel Translation Platform with Reflection-based Improvement using Local LLMs
TransCoder is a powerful translation platform that leverages local Large Language Models (LLMs) through Ollama, featuring innovative Reflection-based Translation methods that significantly improve translation quality through AI self-evaluation and iterative refinement.
- δΈηεΎθΊ«ζ¨‘εΌ (Three Reflections Mode): Translation β AI Reflection β Improvement cycle
- ει€ηΎηΌζ¨‘εΌ (Iterative Refinement Mode): Configurable 1-10 iteration optimization for maximum quality
- Multilingual Parallel Translation: Translate to multiple languages simultaneously
- 14 Language Variants: Including Chinese variants (Simplified, Traditional, Classical)
- Local LLM Support: Works with Ollama (Qwen, Llama, Mistral, etc.)
- Translation Memory: FAISS-based vector database for consistency
- Terminology Management: Professional term consistency across translations
- Quality Evaluation: BLEU, BERTScore, ROUGE metrics
pip install transcoder-llm
# With all features
pip install transcoder-llm[all]
# With specific features
pip install transcoder-llm[web] # Web interface
pip install transcoder-llm[vector-db] # Translation memory
pip install transcoder-llm[evaluation] # Quality metricsgit clone https://github.com/EasyCam/TransCoder.git
cd TransCoder
pip install -e .# Install Ollama (macOS/Linux)
curl -fsSL https://ollama.ai/install.sh | sh
# Download a model
ollama pull qwen3:0.6b# Web interface
transcoder web
# Or with production server
transcoder web --production
# CLI translation
transcoder cli -i input.txt -t en,ja,ko -o output.txtfrom transcoder import TransCoderAPI
api = TransCoderAPI(model="qwen3:0.6b")
# Simple translation
result = api.translate("Hello world", "en", ["zh-cn", "ja"])
print(result.data["translations"])
# Reflection mode (δΈηεΎθΊ«)
result = api.translate_with_reflection(
"Hello world", "en", "zh-cn"
)
# Iterative refinement (ει€ηΎηΌ)
result = api.translate_iterative(
"Hello world", "en", "zh-cn", iterations=3
)Fast one-pass translation for everyday use.
Initial Translation β AI Reflection Analysis β Improved Translation
The AI analyzes translation quality from four dimensions:
- Accuracy: Is the meaning fully preserved?
- Fluency: Is the expression natural?
- Style: Is the tone appropriate?
- Terminology: Are terms translated correctly?
Initial β Reflect β Improve β Reflect β Improve β ... β Final
Configure 1-10 iterations to balance quality vs. speed.
# Translation
POST /api/translate
{
"source_text": "Hello world",
"source_lang": "en",
"target_langs": ["zh-cn", "ja"]
}
# Reflection
POST /api/translate/reflect
{
"source_text": "Hello world",
"translation": "δ½ ε₯½δΈη",
"source_lang": "en",
"target_lang": "zh-cn"
}
# Improvement
POST /api/translate/improve
{
"source_text": "Hello world",
"current_translation": "δ½ ε₯½δΈη",
"reflection": "...",
"source_lang": "en",
"target_lang": "zh-cn"
}from transcoder import TransCoderAPI
api = TransCoderAPI()
# Translate
result = api.translate(text, source_lang, target_langs)
# With reflection
result = api.translate_with_reflection(text, source_lang, target_lang)
# Iterative
result = api.translate_iterative(text, source_lang, target_lang, iterations=3)
# Evaluate quality
result = api.evaluate_translation(source, translated, reference)| Code | Language |
|---|---|
| zh-cn | Chinese (Simplified) |
| zh-tw | Chinese (Traditional) |
| zh-classical-cn | Classical Chinese (Simplified) |
| zh-classical-tw | Classical Chinese (Traditional) |
| en | English |
| ja | Japanese |
| ko | Korean |
| es | Spanish |
| fr | French |
| de | German |
| ru | Russian |
| ar | Arabic |
| pt | Portuguese |
transcoder/
βββ __init__.py # Package exports
βββ cli.py # Command-line interface
βββ api.py # Unified Python API
βββ core.py # Core services
βββ app.py # Flask web application
βββ templates/ # HTML templates
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest tests/
# Run linter
ruff check transcoder/
# Build package
python -m build
# Upload to PyPI
./upload_pypi.shMIT License - See LICENSE for details.
If you use TransCoder in your research, please cite:
@software{transcoder2024,
title = {TransCoder: Multilingual Parallel Translation Platform with Reflection-based Improvement},
author = {TransCoder Team},
year = {2024},
url = {https://github.com/EasyCam/TransCoder}
}Contributions are welcome! Please read our contributing guidelines before submitting PRs.