Instructions to use flax-community/Sinhala-gpt2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use flax-community/Sinhala-gpt2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="flax-community/Sinhala-gpt2")# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("flax-community/Sinhala-gpt2") model = AutoModel.from_pretrained("flax-community/Sinhala-gpt2") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use flax-community/Sinhala-gpt2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "flax-community/Sinhala-gpt2" # 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/Sinhala-gpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/flax-community/Sinhala-gpt2
- SGLang
How to use flax-community/Sinhala-gpt2 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 "flax-community/Sinhala-gpt2" \ --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/Sinhala-gpt2", "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 "flax-community/Sinhala-gpt2" \ --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/Sinhala-gpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use flax-community/Sinhala-gpt2 with Docker Model Runner:
docker model run hf.co/flax-community/Sinhala-gpt2
Sinhala GPT2 trained on MC4 (manually cleaned)
Overview
This is a smaller GPT2 model trained on MC4 Sinhala dataset. As Sinhala is one of those low resource languages, there are only a handful of models been trained. So, this would be a great place to start training for more downstream tasks.
This model uses a manually cleaned version of MC4 dataset which can be found here. Although the dataset is relatively small ~3GB. The finetuned model on news articles generates good and acceptable results.
Model Specification
The model chosen for training is GPT2 with the following specifications:
- vocab_size=50257
- n_embd=768
- n_head=12
- n_layer=12
- n_positions=1024
How to Use
You can use this model directly with a pipeline for causal language modeling:
from transformers import pipeline
generator = pipeline('text-generation', model='flax-community/Sinhala-gpt2')
generator("เถธเถธ", max_length=50, num_return_sequences=5)
- Downloads last month
- 11