flax-community/swahili-safi
Updated โข 23 โข 3
How to use flax-community/gpt2-swahili with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="flax-community/gpt2-swahili") # Load model directly
from transformers import AutoTokenizer, AutoModelForMultimodalLM
tokenizer = AutoTokenizer.from_pretrained("flax-community/gpt2-swahili")
model = AutoModelForMultimodalLM.from_pretrained("flax-community/gpt2-swahili")How to use flax-community/gpt2-swahili with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "flax-community/gpt2-swahili"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "flax-community/gpt2-swahili",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/flax-community/gpt2-swahili
How to use flax-community/gpt2-swahili with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "flax-community/gpt2-swahili" \
--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": "flax-community/gpt2-swahili",
"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 "flax-community/gpt2-swahili" \
--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": "flax-community/gpt2-swahili",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use flax-community/gpt2-swahili with Docker Model Runner:
docker model run hf.co/flax-community/gpt2-swahili
This model was trained using HuggingFace's Flax framework and is part of the JAX/Flax Community Week organized by HuggingFace. All training was done on a TPUv3-8 VM sponsored by the Google Cloud team.
from transformers import AutoTokenizer, AutoModelWithLMHead
tokenizer = AutoTokenizer.from_pretrained("flax-community/gpt2-swahili")
model = AutoModelWithLMHead.from_pretrained("flax-community/gpt2-swahili")
print(round((model.num_parameters())/(1000*1000)),"Million Parameters")
124 Million Parameters
This model was trained on Swahili Safi
For more details and Demo please check HF Swahili Space