arikda/smart-hebrew-translator
0
Smart Multilingual Translator
An intelligent translation application powered by Facebook's mBART-50 model, translating Hebrew text to three languages: English, Spanish, and French.
Key Features
- Automatic Language Detection: Automatic detection of input language using langdetect
- Multilingual Translation: Simultaneous translation to three target languages
- User-Friendly Interface: Intuitive user interface built with Gradio
- RTL Support: Full support for right-to-left writing direction for Hebrew
- Built-in Examples: Sample texts for demonstration
Models Used
mBART-50 (facebook/mbart-large-50-many-to-many-mmt)
Advantages:
- Supports 50 different languages
- Direct translation between language pairs without intermediate language
- High translation quality for multilingual model
- Specifically designed for many-to-many translation
Comparison with Other Models
MarianMT (Helsinki-NLP)
- Advantages: Fast, easy to use
- Disadvantages: Separate model for each language pair, limited to paired translation
Google Translate API
- Advantages: Excellent quality, wide support
- Disadvantages: Requires paid API key, dependent on internet connection
NLLB (No Language Left Behind)
- Advantages: Support for 200+ languages
- Disadvantages: Requires more computational resources
Local Installation and Running
System Requirements
Python 3.8+
CUDA (optional, for better performance)Installing Dependencies
pip install -r requirements.txtRunning the Application
python app.pyThe application will open at: http://localhost:7860
Project Structure
smart-translator/
├── app.py # Main Gradio application
├── requirements.txt # Python dependencies
├── map_model_lang.json # Language and model mapping
├── README.md # This documentation
└── assets/
└── screenshot.png # Application screenshotTechnical Configuration
Language Codes in mBART Model
- Hebrew: he_IL
- English: en_XX
- Spanish: es_XX
- French: fr_XX
Translation Parameters
- Max Length: 512 tokens
- Num Beams: 5 (beam search)
- Early Stopping: True
Usage
- Enter Hebrew text in the text box
- Click "Translate"
- View results in three languages
- Check status to ensure translation succeeded
Usage Examples
- "שלום, איך אתה מרגיש היום?" (Hello, how are you feeling today?)
- "הטכנולוגיה משנה את העולם בצורה מהירה" (Technology is changing the world rapidly)
- "אני אוהב לקרוא ספרים ולצפות בסרטים" (I love reading books and watching movies)
Performance
- Translation Time: 3-8 seconds (depending on text length)
- Memory Required: approximately 2GB RAM
- GPU Support: Yes (accelerates translation)
Troubleshooting Common Issues
"Model not loaded" Error Message
# Ensure all dependencies are installed
pip install -r requirements.txt
# Try downloading the model in advance
python -c "from transformers import pipeline; pipeline('translation', model='facebook/mbart-large-50-many-to-many-mmt')"Slow Translation
- Ensure GPU is available
- Reduce max_length parameter
- Use torch.float16 instead of torch.float32
Contributing to the Project
- Fork the project
- Create a new branch (git checkout -b feature/amazing-feature)
- Commit changes (git commit -m 'Add amazing feature')
- Push to branch (git push origin feature/amazing-feature)
- Open Pull Request
License
This project is distributed under the MIT License. See LICENSE for more details.
Acknowledgments
- Hugging Face for the Transformers library and models
- Facebook AI for the mBART-50 model
- Gradio for the excellent user interface
Smart Multilingual Translator | Built with mBART-50
