google/smol
Viewer • Updated • 842k • 3.66k • 110
How to use NM-development/madlad400-3b-mt-ce-v0 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="NM-development/madlad400-3b-mt-ce-v0") # Load model directly
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("NM-development/madlad400-3b-mt-ce-v0")
model = AutoModelForSeq2SeqLM.from_pretrained("NM-development/madlad400-3b-mt-ce-v0")This model is fine-tuned version of google/madlad400-3b-mt, trained on nmd-ce-ru-171k-v0 Chechen-Russian parallel corpora combined with smoldoc.
BLEU and chrF++ calculated on BOUQuET 💐 for this model compared to nllb-ce-rus-v0.
| Direction | madlad400-3b-mt-ce-v0 | nllb-ce-rus-v0 |
|---|---|---|
| ce2ru | BLEU: 18.48 chrF2++: 41.38 |
BLEU: 9.59 chrF2++: 33.71 |
| ru2ce | BLEU: 7.53 chrF2++: 32.93 |
BLEU: 4.12 chrF2++: 26.48 |
| ce2en | BLEU: 12.37 chrF2++: 33.26 |
BLEU: 1.36 chrF2++: 9.29 |
| en2ce | BLEU: 5.30 chrF2++: 27.71 |
BLEU: 2.99 chrF2++: 22.91 |
You may run the model in Jupyter Notebook with this code:
from transformers import T5ForConditionalGeneration, T5Tokenizer
import torch
def translate(text, model, tokenizer, tgt_lang):
model.eval()
inputs = tokenizer(f"<2{tgt_lang}> {text}", return_tensors="pt").to(device)
outputs = model.generate(
**inputs,
max_length=256,
num_beams=5,
early_stopping=True
)
return tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model_id = 'NM-development/madlad400-3b-mt-ce-v0'
model = T5ForConditionalGeneration.from_pretrained(
model_id,
dtype=torch.bfloat16,
device_map=None,
).to(device)
tokenizer = T5Tokenizer.from_pretrained(model_id)
text = "После захода солнца батраки сложили сено у сарая и ушли из хутора."
translate(text, model, tokenizer, 'ce')
# Малх бухаделлачул тӀаьхьа, цӀийнан керта ялта а диллина, кӀотар чуьра дӀабахара бацараш.
Base model
google/madlad400-3b-mt