import torch, logging
from transformers import AutoModelForCausalLM, AutoTokenizer

tig_model_path = "BeitTigreAI/tigre-llm-Llama3.2-1B"

# Set the device for computation
device = "cuda" if torch.cuda.is_available() else "cpu"

# Load the tokenizer and model from the specified path
tokenizer = AutoTokenizer.from_pretrained(tig_model_path)
model = AutoModelForCausalLM.from_pretrained(tig_model_path, device_map="auto")
model = model.to(device)

# Suppress some of the logging for a cleaner output
logging.getLogger("transformers").setLevel(logging.ERROR)

# Example 1: Generate text in Tigre (written in Ethiopic script)
prompt = "[tig_Ethi]แˆ˜แˆญแˆแ‰  แ‰ฅแŠฉแˆ"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=50)
print("Tigre Output:")
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))

# Example 2: Generate text in Arabic
prompt = "ู…ุง ุงู„ุฐูŠ ูŠู…ูŠุฒ ู„ุบุฉ ุงู„ุชุบุฑูŠุŸ"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=40)
print("\nArabic Output:")
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))

# Example 3: Generate text in English
prompt = "[eng_Latn] What is interesting about the Tigre language?"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=40)
print("\nEnglish Output:")
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))
Downloads last month
38
Safetensors
Model size
1.27B params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for BeitTigreAI/tigre-llm-Llama3.2-1B

Finetuned
(689)
this model