Views
No views yet
⚠️ Note: This model is experimental and for demonstration purposes only. It is not production-ready.
from transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer
import torch
# Load model
from transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer
import torch
# Load model
model_id = "michsethowusu/opani-translate_1b-merged-16bit"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16,
device_map="auto",
)
# Prepare message
messages = [
{
"role": "user",
"content": """Translate this text to Twi language:\nFormer French President Nicolas Sarkozy starts five-year prison sentence for campaign finance conspiracy.
"""
}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
)
# Generate response
streamer = TextStreamer(tokenizer, skip_prompt=True)
_ = model.generate(
**tokenizer(text, return_tensors="pt").to(model.device),
max_new_tokens=2048,
temperature=0.7,
top_p=0.9,
streamer=streamer,
)
@misc{opani-translate_1b_2024,
author = {michsethowusu},
title = {Opani Translate 1B: Fine-tuned Llama 3.2 1B for English-to-Twi Translation},
year = {2024},
publisher = {HuggingFace},
url = {[https://huggingface.co/michsethowusu/opani-translate_1b-merged-16bit](https://huggingface.co/michsethowusu/opani-translate_1b-merged-16bit)}
}