Downloads · 30 days
3
8% of all-time downloads
hov172/nllb-200-coreml-256
nllb-200-coreml-256 is a translation model from hov172. Use it when you need text moved from one language to another. It is set up for coremltools. The card lists the license as cc-by-nc-4.0.
On-device neural machine translation for 200 languages using CoreML on Apple devices (iPhone, iPad, Mac).
Downloads · 30 days
3
8% of all-time downloads
All-time downloads
37
Public
Repo size
1.8 GB
Likes
0
Public
Click a slice to open those files.
.bin1.8 GB · 98%
From the Hugging Face model README
On-device neural machine translation for 200 languages using CoreML on Apple devices (iPhone, iPad, Mac).
This is a CoreML conversion of facebook/nllb-200-distilled-600M optimized for:
.
├── NLLB_Encoder_256.mlpackage # Encoder model (~1.5 GB)
├── NLLB_Decoder_256.mlpackage # Decoder model (~1.7 GB)
├── tokenizer/ # Tokenizer files
├── example.py # Ready-to-run example
└── language_codes.json # Language code reference
pip install coremltools transformers
# Clone this repo
git lfs install
git clone https://huggingface.co/cstr/nllb-200-coreml-256
cd nllb-200-coreml-256
from example import translate_text
# English to German
result = translate_text(
"Hello, how are you today?",
source_lang="eng_Latn",
target_lang="deu_Latn"
)
print(result) # "Hallo, wie geht es dir heute?"
from example import translate_text
# English → Spanish
translate_text("Good morning!", "eng_Latn", "spa_Latn")
# → "¡Buenos días!"
# French → English
translate_text("Bonjour le monde", "fra_Latn", "eng_Latn")
# → "Hello world"
# Japanese → English
translate_text("こんにちは", "jpn_Jpan", "eng_Latn")
# → "Hello"
# 256-token context handles longer paragraphs
long_text = """
Machine learning is a subset of artificial intelligence that
enables computers to learn and improve from experience without
being explicitly programmed. In recent years, it has transformed
technology and created new possibilities.
"""
result = translate_text(long_text, "eng_Latn", "deu_Latn")
import coremltools as ct
from transformers import AutoTokenizer
class Translator:
def __init__(self):
# Load once, reuse for all translations
self.encoder = ct.models.MLModel(
"NLLB_Encoder_256.mlpackage",
compute_units=ct.ComputeUnit.ALL # Use GPU
)
self.decoder = ct.models.MLModel(
"NLLB_Decoder_256.mlpackage",
compute_units=ct.ComputeUnit.ALL
)
self.tokenizer = AutoTokenizer.from_pretrained("./tokenizer")
def translate(self, text, src_lang, tgt_lang):
# Your translation logic here
pass
# Create once
translator = Translator()
# Reuse many times (fast!)
translator.translate("Hello", "eng_Latn", "deu_Latn")
translator.translate("Goodbye", "eng_Latn", "fra_Latn")
See language_codes.json for the full list of 200+ languages. Common examples:
| Language | Code |
|---|---|
| English | eng_Latn |
| German | deu_Latn |
| French | fra_Latn |
| Spanish | spa_Latn |
| Chinese (Simplified) | zho_Hans |
| Japanese | jpn_Jpan |
| Arabic | arb_Arab |
| Russian | rus_Cyrl |
Full list: NLLB Language Codes
encoder = ct.models.MLModel(
"NLLB_Encoder_256.mlpackage",
compute_units=ct.ComputeUnit.CPU_ONLY
)
texts = ["Hello", "Goodbye", "Thank you"]
translations = [translate_text(t, "eng_Latn", "deu_Latn") for t in texts]
| Feature | 128-Token | 256-Token (This) |
|---|---|---|
| Max Length | ~80-100 words | ~150-180 words |
| Model Size | ~3.2 GB | ~3.2 GB |
| Speed | Faster | Slightly slower |
| Use Case | Short texts, chat | Paragraphs, articles |
⚠️ Non-commercial use only per NLLB license