Views
No views yet
pip install -U transformerspipeline API1import torch
2from transformers import pipeline
3
4pipe = pipeline(
5 "text-generation",
6 model="etamin/Letz-MT-gemma2-2b-en-lb",
7 model_kwargs={"torch_dtype": torch.bfloat16},
8 device="cuda", # replace with "mps" to run on a Mac device
9)
10
11messages = [
12 {"role": "user", "content": """
13 <|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are a helpful AI assistant for translation.<|eot_id|>
14 <|start_header_id|>user<|end_header_id|>\n\nTranslate the English input text into Luxembourgish.
15 Do not include any additional information or unrelated content.\n\n
16 "I have not met you yet."
17 """},
18]
19
20outputs = pipe(messages, max_new_tokens=256)
21assistant_response = outputs[0]["generated_text"][-1]["content"].strip()
22print(assistant_response)
23# ech sinn em d'éinescht nach begéint1from transformers import AutoTokenizer, AutoModelForCausalLM
2import transformers
3import torch
4
5model_id = "etamin/Letz-MT-gemma2-2b-en-lb"
6dtype = torch.bfloat16
7
8tokenizer = AutoTokenizer.from_pretrained(model_id)
9model = AutoModelForCausalLM.from_pretrained(
10 model_id,
11 device_map="cuda",
12 torch_dtype=dtype,)
13
14chat = [
15 { "role": "user", "content": """
16 <|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are a helpful AI assistant for translation.<|eot_id|>
17 <|start_header_id|>user<|end_header_id|>\n\nTranslate the English input text into Luxembourgish.
18 Do not include any additional information or unrelated content.\n\n
19 "I have not met you yet."
20 """ },
21]
22prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)1inputs = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
2outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=150)
3print(tokenizer.decode(outputs[0]))1@misc{song2025llmsilverbulletlowresource,
2 title={Is LLM the Silver Bullet to Low-Resource Languages Machine Translation?},
3 author={Yewei Song and Lujun Li and Cedric Lothritz and Saad Ezzini and Lama Sleem and Niccolo Gentile and Radu State and Tegawendé F. Bissyandé and Jacques Klein},
4 year={2025},
5 eprint={2503.24102},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={https://arxiv.org/abs/2503.24102},
9}