Views
No views yet
.
├── NLLB_Encoder_128.mlpackage # Encoder model (~1.5 GB)
├── NLLB_Decoder_128.mlpackage # Decoder model (~1.7 GB)
├── tokenizer/ # Tokenizer files
├── example.py # Ready-to-run example
└── language_codes.json # Language code referencepip install coremltools transformers1# Clone this repo
2git lfs install
3git clone https://huggingface.co/cstr/nllb-200-coreml-128
4cd nllb-200-coreml-1281from example import translate_text
2
3# English to German
4result = translate_text(
5 "Hello, how are you today?",
6 source_lang="eng_Latn",
7 target_lang="deu_Latn"
8)
9print(result) # "Hallo, wie geht es dir heute?"1from example import translate_text
2
3# English → Spanish
4translate_text("Good morning!", "eng_Latn", "spa_Latn")
5# → "¡Buenos días!"
6
7# French → English
8translate_text("Bonjour le monde", "fra_Latn", "eng_Latn")
9# → "Hello world"
10
11# Japanese → English
12translate_text("こんにちは", "jpn_Jpan", "eng_Latn")
13# → "Hello"1import coremltools as ct
2from transformers import AutoTokenizer
3
4class Translator:
5 def __init__(self):
6 # Load once, reuse for all translations
7 self.encoder = ct.models.MLModel(
8 "NLLB_Encoder_128.mlpackage",
9 compute_units=ct.ComputeUnit.ALL # Use GPU
10 )
11 self.decoder = ct.models.MLModel(
12 "NLLB_Decoder_128.mlpackage",
13 compute_units=ct.ComputeUnit.ALL
14 )
15 self.tokenizer = AutoTokenizer.from_pretrained("./tokenizer")
16
17 def translate(self, text, src_lang, tgt_lang):
18 # Your translation logic here
19 pass
20
21# Create once
22translator = Translator()
23
24# Reuse many times (fast!)
25translator.translate("Hello", "eng_Latn", "deu_Latn")
26translator.translate("Goodbye", "eng_Latn", "fra_Latn")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 |
1encoder = ct.models.MLModel(
2 "NLLB_Encoder_128.mlpackage",
3 compute_units=ct.ComputeUnit.CPU_ONLY
4)1texts = ["Hello", "Goodbye", "Thank you"]
2translations = [translate_text(t, "eng_Latn", "deu_Latn") for t in texts]
## Provenance and EU AI Act Art. 53 note
- **Upstream model:** [facebook/nllb-200-distilled-600M](https://huggingface.co/facebook/nllb-200-distilled-600M) — published by `facebook`.
- **Upstream licence:** `cc-by-nc-4.0`. This repository redistributes under the same terms; it grants no rights the upstream licence does not.
- **What was done here:** format conversion and/or quantisation only (CoreML). No training, no fine-tuning, no merging, no distillation, no change to architecture, vocabulary or capability. Only the numeric representation of the upstream weights differs.
- **Training data:** documented — where it is documented at all — by the upstream provider; see the upstream model card. No training data was used, added or selected by this repository.
- **Provider status:** under Regulation (EU) 2024/1689 the upstream authors remain the provider of this model. Converting the serialisation format does not make this repository the provider of a new general-purpose AI model, and no such claim is made. Questions about training content, copyright policy or model capability belong upstream.