This is a English -> Romanian translation model trained by Mihai Popa (with the help of Kimi K2.6 Thinking)! It's based on BART, and it's a lot smaller than other models.
Because it's for my own future LocalTranslate project! Unlike Google Translate, this uses models (LTR files in the future) that you download and put on your device! And yes, it translates locally!
Code is by Gemini 3 Flash/Kimi K2.6 Thinking (then some little modifications by myself):
1from transformers import BartForConditionalGeneration, AutoTokenizer
2import torch
3
4# 1. Load from your Hugging Face Repo
5model_id = "MihaiPopa-1/LocalTranslate_EN_RO"
6
7tokenizer = AutoTokenizer.from_pretrained(model_id)
8model = BartForConditionalGeneration.from_pretrained(
9 model_id,
10 torch_dtype=torch.float32, # Standard for CPU
11 device_map="cpu" # Forces CPU usage
12)
13
14# 2. Translate to Romanian
15inputs = tokenizer("At your current usage level, this runtime may last up to 1 hour.", return_tensors="pt")
16outputs = model.generate(
17 **inputs,
18 max_length=64,
19 num_beams=2,
20 early_stopping=True,
21 forced_eos_token_id=tokenizer.eos_token_id,
22)
23translation = tokenizer.decode(outputs[0], skip_special_tokens=True)
24
25print(translation)