Abdeljalil-Ounaceur/English-Tamazight-Dictionnary-2007
Viewer โข Updated โข 9.07k โข 45 โข 1
How to use Abdeljalil-Ounaceur/nllb-tamazight-souss with Transformers:
# Use a pipeline as a high-level helper
# Warning: Pipeline type "translation" is no longer supported in transformers v5.
# You must load the model directly (see below) or downgrade to v4.x with:
# pip install "transformers<5.0.0"
from transformers import pipeline
pipe = pipeline("translation", model="Abdeljalil-Ounaceur/nllb-tamazight-souss") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("Abdeljalil-Ounaceur/nllb-tamazight-souss")
model = AutoModelForSeq2SeqLM.from_pretrained("Abdeljalil-Ounaceur/nllb-tamazight-souss", device_map="auto")A fine-tuned version of NLLB-200-distilled-600M for English โ Tamazight (Kabyle Latin script) translation, trained on a comprehensive dictionary dataset.
This model is a fine-tuned version of facebook/nllb-200-distilled-600M specifically adapted for English-Tamazight translation. It was trained on ~9,000 translation pairs from a curated dictionary dataset containing vocabulary, verb conjugations, country names, and cultural phrases.
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
# Load the model
tokenizer = AutoTokenizer.from_pretrained("Abdeljalil-Ounaceur/nllb-tamazight-souss")
model = AutoModelForSeq2SeqLM.from_pretrained("Abdeljalil-Ounaceur/nllb-tamazight-souss")
# Translate English to Tamazight
def translate(text, src_lang="eng_Latn", tgt_lang="kab_Latn"):
inputs = tokenizer(text, return_tensors="pt")
# Get target language token
forced_bos_token_id = tokenizer.convert_tokens_to_ids(tgt_lang)
generated_tokens = model.generate(
**inputs,
forced_bos_token_id=forced_bos_token_id,
max_length=50,
num_beams=4,
early_stopping=True
)
return tokenizer.decode(generated_tokens[0], skip_special_tokens=True)
# Example usage
print(translate("house")) # Expected: tamdint
print(translate("water")) # Expected: aman
Base model
facebook/nllb-200-distilled-600M