Run this model with HF Jobs
Run werent4/mt5TranslatorLT on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/werent4/mt5TranslatorLT. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/werent4/mt5TranslatorLT on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use werent4/mt5TranslatorLT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use werent4/mt5TranslatorLT with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("werent4/mt5TranslatorLT") model = AutoModelForSeq2SeqLM.from_pretrained("werent4/mt5TranslatorLT", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Model Card for Model ID
This model is a translator into Lithuanian and vice versa. It was trained on the following datasets:
Model Usage
import torch
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
from transformers import T5Tokenizer, MT5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained('werent4/mt5TranslatorLT')
model = MT5ForConditionalGeneration.from_pretrained("werent4/mt5TranslatorLT")
model.to(device)
def translate(text, model, tokenizer, device, translation_way = "en-lt"):
translations_ways = {
"en-lt": "<EN2LT>",
"lt-en": "<LT2EN>"
}
if translation_way not in translations_ways:
raise ValueError(f"Invalid translation way. Supported ways: {list(translations_ways.keys())}")
input_text = f"{translations_ways[translation_way]} {text}"
encoded_input = tokenizer(input_text, return_tensors="pt", padding=True, truncation=True, max_length=128).to(device)
with torch.no_grad():
output_tokens = model.generate(
**encoded_input,
max_length=128,
num_beams=5,
no_repeat_ngram_size=2,
early_stopping=True
)
translated_text = tokenizer.decode(output_tokens[0], skip_special_tokens=True)
return translated_text
text = "How are you?"
translate(text, model, tokenizer, device)
`Kaip esate?`
text = "I live in Kaunas"
translate(text, model, tokenizer, device)
`Aลก gyvenu Kaunas`
text = "Mano vardas yra Karolis"
translate(text, model, tokenizer, device, translation_way= "lt-en")
`My name is Karolis`
Model Card Authors
Model Card Contact
[More Information Needed]
- Downloads last month
- 18
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐ Ask for provider support