Run this model with HF Jobs
Run puettmann/SmolMaestra-1.7b-Translation 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/puettmann/SmolMaestra-1.7b-Translation. 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/puettmann/SmolMaestra-1.7b-Translation 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 puettmann/SmolMaestra-1.7b-Translation with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use puettmann/SmolMaestra-1.7b-Translation 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="puettmann/SmolMaestra-1.7b-Translation")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("puettmann/SmolMaestra-1.7b-Translation") model = AutoModelForCausalLM.from_pretrained("puettmann/SmolMaestra-1.7b-Translation", device_map="auto") - Notebooks
- Google Colab
- Kaggle
SmolMaestra - A tiny model tuned for text translation
_____ _ __ __ _
/ ____| | | \/ | | |
| (___ _ __ ___ ___ | | \ / | __ _ ___ ___| |_ _ __ __ _
\___ \| '_ ` _ \ / _ \| | |\/| |/ _` |/ _ \/ __| __| '__/ _` |
____) | | | | | | (_) | | | | | (_| | __/\__ \ |_| | | (_| |
|_____/|_| |_| |_|\___/|_|_| |_|\__,_|\___||___/\__|_| \__,_|
For EN-IT translation, check out the lightweight Quadrifoglio models as well.
Model Card
This model was finetuned with roughly 300.000 examples of translations from English to Italian and Italian to English. The model was finetuned in a way to more directly provide a translation without much explanation.
Finetuning took about 10 hours on an A10G Nvidia GPU.
Due to its size, the model runs very well on CPUs.
Usage
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "LeonardPuettmann/SmolMaestra-1.7b-Instruct-v0.1"
model = AutoModelForCausalLM.from_pretrained(
model_id,
device_map="auto",
trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained(model_id, add_bos_token=True, trust_remote_code=True)
row_json = [
{"role": "system", "content": "Your job is to return translations for sentences or words from either Italian to English or English to Italian."},
{"role": "user", "content": "Do you sell tickets for the bus?"},
]
prompt = tokenizer.apply_chat_template(row_json, tokenize=False)
model_input = tokenizer(prompt, return_tensors="pt").to("cuda")
with torch.no_grad():
print(tokenizer.decode(model.generate(**model_input, max_new_tokens=1024)[0]))
Data used
The source for the data were sentence pairs from tatoeba.com. The data can be downloaded from here: https://tatoeba.org/downloads
Credits
Base model: HuggingFaceTB/SmolLM2-1.7B-Instruct
Finetuned by: Leonard Püttmann https://www.linkedin.com/in/leonard-p%C3%BCttmann-4648231a9/
- Downloads last month
- 1,849