Amharic GPT2
Collection
GPT2 transformer decoder models pretrained on 290 million tokens of Amharic text • 6 items • Updated
How to use rasyosef/gpt2-medium-amharic-28k-512 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="rasyosef/gpt2-medium-amharic-28k-512") # Load model directly
from transformers import AutoTokenizer, AutoModelForMultimodalLM
tokenizer = AutoTokenizer.from_pretrained("rasyosef/gpt2-medium-amharic-28k-512")
model = AutoModelForMultimodalLM.from_pretrained("rasyosef/gpt2-medium-amharic-28k-512")How to use rasyosef/gpt2-medium-amharic-28k-512 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "rasyosef/gpt2-medium-amharic-28k-512"
# 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-medium-amharic-28k-512",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/rasyosef/gpt2-medium-amharic-28k-512
How to use rasyosef/gpt2-medium-amharic-28k-512 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "rasyosef/gpt2-medium-amharic-28k-512" \
--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-medium-amharic-28k-512",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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-medium-amharic-28k-512" \
--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-medium-amharic-28k-512",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use rasyosef/gpt2-medium-amharic-28k-512 with Docker Model Runner:
docker model run hf.co/rasyosef/gpt2-medium-amharic-28k-512
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 achieves the following results on the evaluation set:
Loss: 4.24Perplexity: 69.4You can use this model directly with a pipeline for text generation:
from transformers import pipeline
gpt2_am = pipeline(
"text-generation",
model="rasyosef/gpt2-medium-amharic-28k-512"
)
prompt = "በ ኢንግሊዝ ፕሪምየር ሊግ"
gpt2_am(
prompt,
max_new_tokens=256,
temperature=0.4,
do_sample=True,
top_k=8,
top_p=0.8,
repetition_penalty=1.4
)
Output:
[{'generated_text': 'በ ኢንግሊዝ ፕሪምየር ሊግ የ3ኛ ሳምንት ጨዋታዎች ዛሬ እና ነገ ይካሄዳሉ ።\nየፕሪምየር ሊጉ ከፍተኛ ግብ አስቆጣሪ የሆነው ኤቨርተን ከኒውካስል ዩናይትድ የሚያደርጉትን ጨዋታ በቀጥታ ስርጭት ይመልከቱ።\nከሊቨርፑል ጋር ባደረገው ግጥሚያም አርሰናል በፕሬሚየር ሊጉ ላይ ጎል በማስቆጠር ቀዳሚ ሆኖ አጠናቋል።\nአርሰናል በፕሬሚየር ሊጉ የደረጃ ሰንጠረዡን እየመራ ይገኛል። ሊቨርፑል በፕሬሚየር ሊጉ ሁለተኛ ደረጃ ላይ ከሚገኘው ማንቸስተር ሲቲ ጋር እኩል ነው፤ እንዲሁም ማንቸስተር ሲቲ በፕሬሚየር ሊጉ አራተኛ ደረጃ ላይ የሚገኘው ቸልሲ በፕሬሚየር ሊጉ ሦስተኛ ደረጃ ላይ ይገኛል።\nበእንግሊዝ ፕሬሚየር ሊግ የእግር ኳስ ፍልሚያ ትናንት ማታ ስቶክሆልም ከተማ ውስጥ ዌስትሐምን 3 ለ0 አሸንፏል። ከትናንት በስቲያ ምሽት ኒውካስትል ዩናይትድን 2 ለባዶ ያሸነፈው ማንቸስተር ሲቲ ቅዳሜ ዕለት ዌስትሐም ሆትስፐር ከማንቸስተር ሲቲ ጋር አንድ እኩል ተለያይቷል።\nትናንት ማታ ስቶክሆልን 4 ለ1 በሆነ ሰፊ ውጤት በማሸነፍ በደረጃ ሠንጠረዡ አናት ላይፕትሲሽንን በኹለተኛነት ይከተላል። ማንቸስተር ሲቲ በፕሬሚየር ሊጉ አምስተኛ ደረጃን ይዞ ሲያጠናቅቅ፣ ማንቸስተር ሲቲ በፕሬሚየር ሊጉ ሦስተኛ ደረጃ ይዟል።\nበጀርመን ቡንደስ ሊጋ ባየር ሙይንሽን ሐኖቨርን 5 ለ2 ድል አድርጓል። ቦሩስያ ዶርትሙንድ በፕሬሚየር ሊጉ ሦስተኛ ኾኖ ያጠናቀቀው ሽቱትጋርት በፕሬሚየር ሊጉ ሦስተኛ ደረጃ ላይ ይገኛል'}]