Views
No views yet
| Parameter | Value |
|---|---|
| Parameters | 600 Million |
| Precision | Int8 |
| Vocabulary Size | 256,206 |
| Inference Engine | CTranslate2 (v4.0+) |
| Hardware Target | NVIDIA GPU (Tensor Core optimized) or modern CPU |
ctranslate2 and transformers libraries installed.pip install ctranslate2 transformers sentencepiece1import ctranslate2
2import transformers
3
4# Load the model and tokenizer
5model_path = "AlaminI/nllb-200-600M-ct2-int8"
6tokenizer = transformers.AutoTokenizer.from_pretrained(model_path)
7translator = ctranslate2.Translator(model_path, device="cpu") # or "cuda"
8
9def translate(text, src_lang="eng_Latn", tgt_lang="hau_Latn"):
10 # Prepare the input with NLLB language tags
11 tokenizer.src_lang = src_lang
12 source = tokenizer.convert_ids_to_tokens(tokenizer.encode(text))
13
14 # Execute translation via C++ backend
15 results = translator.translate_batch(
16 [source],
17 target_prefix=[[tgt_lang]],
18 beam_size=4,
19 max_decoding_length=128,
20 repetition_penalty=1.2
21 )
22
23 # Post-process output
24 output_tokens = results[0].hypotheses[0]
25 if tgt_lang in output_tokens:
26 output_tokens.remove(tgt_lang)
27
28 return tokenizer.decode(tokenizer.convert_tokens_to_ids(output_tokens))
29
30# Example execution
31result = translate("The scientific method is a systematic way of learning about the world.")
32print(f"Result: {result}")