CoolFace
Apppublic

arikda/smart-hebrew-translator

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes
App README

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.txt

Running the Application

python app.py

The 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 screenshot

Technical 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

  1. 1.Enter Hebrew text in the text box
  2. 2.Click "Translate"
  3. 3.View results in three languages
  4. 4.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

  1. 1.Fork the project
  2. 2.Create a new branch (git checkout -b feature/amazing-feature)
  3. 3.Commit changes (git commit -m 'Add amazing feature')
  4. 4.Push to branch (git push origin feature/amazing-feature)
  5. 5.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