Instructions to use rasyosef/gpt2-small-amharic with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use rasyosef/gpt2-small-amharic with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="rasyosef/gpt2-small-amharic")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("rasyosef/gpt2-small-amharic") model = AutoModelForCausalLM.from_pretrained("rasyosef/gpt2-small-amharic") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use rasyosef/gpt2-small-amharic with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "rasyosef/gpt2-small-amharic" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rasyosef/gpt2-small-amharic", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/rasyosef/gpt2-small-amharic
- SGLang
How to use rasyosef/gpt2-small-amharic with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "rasyosef/gpt2-small-amharic" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rasyosef/gpt2-small-amharic", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "rasyosef/gpt2-small-amharic" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rasyosef/gpt2-small-amharic", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use rasyosef/gpt2-small-amharic with Docker Model Runner:
docker model run hf.co/rasyosef/gpt2-small-amharic
gpt2-small-amharic
This is a smaller version of the gpt2 decoder transformer model pretrained from scratch for 2 days on 290 million tokens of Amharic text.
- It has 33.7 Million parameters
- The context size of this model is 128 tokens.
- It has the same tokenizer as gpt2, trained from scratch using the same Amharic dataset as the model with a vocabulary size of 16384.
- This is a base model and hasn't undergone any supervised finetuing yet.
It achieves the following results on the evaluation set:
Loss: 3.96Perplexity: 52.55
How to use
You can use this model directly with a pipeline for text generation:
from transformers import pipeline
gpt2_am = pipeline(
"text-generation",
model="rasyosef/gpt2-small-amharic"
)
prompt = "በ ኢንግሊዝ ፕሪምየር ሊግ"
gpt2_am(
prompt,
max_new_tokens=64,
temperature=0.8,
do_sample=True,
top_k=8,
top_p=0.8,
repetition_penalty=1.25
)
Output:
[{'generated_text': 'በ ኢንግሊዝ ፕሪምየር ሊግ የዋንጫ ባለቤት የሆነው ማንቸስተር ሲቲ በ9 ነጥብ ተበልጦ አራተኛ ደረጃ ላይ ይገኛል ።\nከትናንት በስቲያ ምሽት በእንግሊዝ ፕሬሚየር ሊግ አርሰናልን 3 ለ1 በማሸነፍ ነጥቡን ወደ 7 ከፍ በማድረግ በደረጃ ሠንጠረዡ ግርጌ ላይ የሚገኘው ሊቨርፑል ትናንት ማታ ከበርንሌይ ጋር አንድ እኩል ተለያይቷል'}]
Hallucination
Due to the model's small size, hallucinations occur often in the generated text. Here's an example
[{'generated_text': 'በ ኢንግሊዝ ፕሪምየር ሊግ የ5ኛ ሳምንት መርሃግብር ዛሬ ምሽት 4 :00 ሰአት ላይ በዋልያዎቹ 2-0 አሸናፊነት ተጠናቋል፡፡\nከጨዋታው መጠናቀቅ በኋላ የኢትዮጵያ እግር ኳስ ፌደሬሽን ስራ አስፈፃሚ ኮሚቴ ሰብሳቢ አቶ ኢሳያስ ጂራ እና ምክትል ፕሬዝዳንቱ አቶ ሰለሞን ገ/እግዚያብሔር ለሶከር ኢትዮጵያ እንደገለፁት የሁለቱ ቡድኖች ጨዋታ ነገ ጠዋት 3:30'}]
Demo
You can use the following demo to generate text using gpt2-small-amharic. Please enter a prompt and click the Generate button to generate completions for the prompt.
- Downloads last month
- 236