# TraductAL with Romansh Support 🇨🇭 Complete guide for German/English/French to Romansh (Sursilvan) translation using your TraductAL engine with Apertus-8B integration. --- ## 📋 Table of Contents 1. [Quick Start](#quick-start) 2. [System Overview](#system-overview) 3. [Usage Examples](#usage-examples) 4. [Available Models](#available-models) 5. [Romansh Variants](#romansh-variants) 6. [Dataset Information](#dataset-information) 7. [THIRD-PARTY-NOTICES.md](../THIRD-PARTY-NOTICES.md) 8. [Troubleshooting](#troubleshooting) --- ## 🚀 Quick Start ### Translate German to Romansh Sursilvan ```bash cd TraductAL-v1.1.0 python3 unified_translator.py de rm-sursilv "Guten Tag, wie geht es Ihnen?" ``` **Output:** ``` 🔤 Original (de (German)): Guten Tag, wie geht es Ihnen? 🌍 Translation (rm-sursilv (Romansh Sursilvan)): Bun di, co va cun vos? 🤖 Engine: Apertus-8B ⏱️ Time: 12.30s ``` ### List All Supported Languages ```bash python3 unified_translator.py --list-languages ``` ### List Available Models ```bash python3 unified_translator.py --list-models ``` --- ## 🎯 System Overview TraductAL is powered by a single translation engine: ### **Apertus-8B** (Swiss AI) - **Languages**: 1,811 (including all Romansh variants) - **Type**: Causal LLM (decoder-only) - **Speed**: ⚡ 2-5s per sentence on GPU, 10-25s on CPU - **Best for**: Romansh and low-resource languages, and mainstream pairs alike - **Quality**: Very high for Swiss languages - **License**: Apache-2.0 — commercial use permitted ### 🤖 Engine Selection Apertus-8B handles every language pair. It is a Romansh specialist, so Swiss-language pairs are its strongest cases: | Scenario | Engine Used | Reason | |----------|-------------|---------| | German → Romansh | Apertus-8B | Romansh specialist | | English → German | Apertus-8B | Single engine | | French → Romansh | Apertus-8B | Romansh specialist | | Romansh → German | Apertus-8B | Romansh specialist | --- ## 💡 Usage Examples ### Example 1: Basic Translation ```bash python3 unified_translator.py de rm-sursilv "Willkommen in der Schweiz" ``` ### Example 2: French to Romansh ```bash python3 unified_translator.py fr rm-sursilv "Bonjour, comment allez-vous?" ``` ### Example 3: Force Specific Engine ```bash # Apertus-8B is the only engine python3 unified_translator.py en de "Hello" ``` ### Example 4: Clean Output (No Formatting) ```bash python3 unified_translator.py de rm-sursilv "Guten Tag" --clean # Output: Bun di ``` ### Example 5: Using Python API Directly ```python from unified_translator import UnifiedTranslator translator = UnifiedTranslator() # Translate with auto engine selection result = translator.translate( "Guten Tag", src_lang="de", tgt_lang="rm-sursilv" ) print(result["translation"]) # Output: Bun di ``` ### Example 6: Compare Engines (Benchmark) ```bash python3 unified_translator.py --benchmark ``` --- ## 🤖 Available Models ### Apertus-8B Model Downloaded on first run; cached at `~/.cache/huggingface/hub/models--swiss-ai--Apertus-8B-2509` | Model | Size | Languages | Speed | Quality | |-------|------|-----------|-------|---------| | Apertus-8B | ~16GB | 1,811 | Slower | Very High | --- ## 🇨🇭 Romansh Variants Supported The system supports **all 6 Romansh variants**: | Code | Variant | Speakers | Status | |------|---------|----------|--------| | `rm-sursilv` | Sursilvan | 55% | ✅ Primary | | `rm-vallader` | Vallader | 20% | ✅ Supported | | `rm-puter` | Puter | 12% | ✅ Supported | | `rm-surmiran` | Surmiran | 10% | ✅ Supported | | `rm-sutsilv` | Sutsilvan | 3% | ✅ Supported | | `rm-rumgr` | Rumantsch Grischun | Standard | ✅ Supported | ### Usage with Different Variants ```bash # Sursilvan (most common) python3 unified_translator.py de rm-sursilv "Guten Tag" # Vallader python3 unified_translator.py de rm-vallader "Guten Tag" # Rumantsch Grischun (official standard) python3 unified_translator.py de rm-rumgr "Guten Tag" ``` --- ## 📊 Dataset Information ### Downloaded Dataset **Location**: `datasets/romansh/` (created on demand; not redistributed — see the licence note below) | Dataset | Language Pair | Size | Source | |---------|--------------|------|--------| | swiss-ai/apertus-posttrain-romansh | German ↔ Romansh | 46,092 pairs | HuggingFace | ### Dataset Structure ```python from datasets import load_from_disk dataset = load_from_disk("./datasets/romansh") print(len(dataset['train'])) # 46,092 examples # Sample entry sample = dataset['train'][0] # Contains: German text → Romansh translation ``` ### Dataset Contents - **Dictionary translations**: Single words and phrases - **Sentence-level translations**: Complete sentences - **Idiom identification**: Romansh idioms and expressions - **Instruction data**: Small set of human-translated instructions --- ## 🔧 Fine-tuning Guide (Optional) If you want to **improve** translation quality for specific domains: ### When to Fine-tune - ✅ You have domain-specific terminology (medical, legal, technical) - ✅ You want better accuracy for specific Romansh variants - ✅ You have additional parallel data - ❌ Current quality is already good for general use ### Fine-tuning Apertus-8B **Note**: Apertus-8B is already pre-trained on Romansh data, so fine-tuning is optional. ```bash # Using your existing training infrastructure cd TraductAL-v1.1.0 # Fine-tune the causal LM on the Romansh dataset # (training scripts for Apertus-8B are not included in this release) ``` **Requirements**: - GPU with sufficient VRAM for 8B-parameter fine-tuning - 2-6 hours training time --- ## 🐛 Troubleshooting ### Issue: "Model not found" **Solution**: check the HuggingFace cache and pre-download if needed: ```bash python3 startup_check.py # or force a download: python3 -c "from huggingface_hub import snapshot_download; snapshot_download('swiss-ai/Apertus-8B-2509')" ``` ### Issue: "Translation is slow" **Cause**: Apertus-8B runs on CPU (8B parameters) **Solutions**: 1. **Use GPU** (if available): - Automatically detected if CUDA available - ~5x speedup 2. **Reduce input length**: translate paragraph by paragraph rather than whole documents ### Issue: "Virtual environment not found" **Solution**: Activate manually: ```bash cd TraductAL-v1.1.0 source .venv/bin/activate python unified_translator.py de rm-sursilv "Test" ``` ### Issue: "datasets library not found" **Solution**: Already installed! If issues persist: ```bash source .venv/bin/activate pip install datasets ``` ### Issue: "Translation quality is poor" **Solutions**: 1. **Try different Romansh variants**: - Each variant has different training data - Sursilvan (`rm-sursilv`) is most common 2. **Use more context**: - Provide full sentences instead of single words - Include punctuation 3. **Consider fine-tuning**: - Add domain-specific data - See Fine-tuning Guide above --- ## 📝 Python API Reference ### UnifiedTranslator Class ```python from unified_translator import UnifiedTranslator translator = UnifiedTranslator() # Translate with auto engine selection result = translator.translate( text="Guten Tag", src_lang="de", tgt_lang="rm-sursilv" ) # Force specific engine result = translator.translate( text="Hello", src_lang="en", tgt_lang="de" ) # Result structure { "translation": "Bun di", "model": "Apertus-8B", "engine": "Apertus-8B", "time": "12.30s", "src_lang": "de (German)", "tgt_lang": "rm-sursilv (Romansh Sursilvan)", "device": "cpu" } ``` ### ApertusTranslator Class (Direct) ```python from apertus_translator import ApertusTranslator translator = ApertusTranslator() result = translator.translate( text="Guten Tag", src_lang="de", tgt_lang="rm-sursilv", max_tokens=512 ) # List supported languages translator.list_languages() ``` ### Apertus Translator Class (Direct) ```python from apertus_translator import ApertusTranslator translator = ApertusTranslator() result = translator.translate( text="Hello", src_lang="en", tgt_lang="de" ) ``` --- ## 🎓 Language Code Reference ### Common Source Languages | Code | Language | Example | |------|----------|---------| | `de` | German | Guten Tag | | `en` | English | Hello | | `fr` | French | Bonjour | | `it` | Italian | Buongiorno | ### Romansh Target Languages | Code | Variant | Example Translation | |------|---------|-------------------| | `rm-sursilv` | Sursilvan | Bun di | | `rm-vallader` | Vallader | Bun dí | | `rm-puter` | Puter | Bun dì | | `rm-rumgr` | Rumantsch Grischun | Bun di | --- ## 📞 Support & Resources ### File Locations ``` TraductAL/ ├── unified_translator.py # Main CLI / UnifiedTranslator class ├── apertus_translator.py # Apertus-8B wrapper ├── translate_enhanced.sh # Shell wrapper ├── scripts/ │ └── download_romansh_dataset.py └── datasets/ └── romansh/ # Downloaded dataset (not redistributed) Apertus-8B weights are cached under ~/.cache/huggingface/hub (models--swiss-ai--Apertus-8B-2509) and are not shipped with the source. ``` ### Documentation - **TraductAL**: `README.md` - **Romansh**: `ROMANSH_GUIDE.md` (this file) ### External Resources - **Apertus-8B**: https://huggingface.co/swiss-ai/Apertus-8B-2509 - **Romansh Dataset**: https://huggingface.co/datasets/swiss-ai/apertus-posttrain-romansh --- ## ✅ Summary You now have a **complete Romansh translation system** that: ✅ Translates German/English/French → Romansh (all variants) ✅ Automatically selects the best engine ✅ Supports 1,811 languages total ✅ Includes 46,092 German-Romansh training examples ✅ Works 100% offline ✅ Respects privacy (no data sent to external servers) **Main command**: ```bash cd TraductAL-v1.1.0 python3 unified_translator.py de rm-sursilv "Guten Tag" ``` **Enjoy translating!** 🇨🇭