Text Generation
Transformers
PyTorch
TensorFlow
JAX
TensorBoard
Sinhala
gpt2
feature-extraction
Sinhala
text-generation-inference
Instructions to use keshan/sinhala-gpt2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use keshan/sinhala-gpt2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="keshan/sinhala-gpt2")# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("keshan/sinhala-gpt2") model = AutoModel.from_pretrained("keshan/sinhala-gpt2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use keshan/sinhala-gpt2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "keshan/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": "keshan/sinhala-gpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/keshan/sinhala-gpt2
- SGLang
How to use keshan/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 "keshan/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": "keshan/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 "keshan/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": "keshan/sinhala-gpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use keshan/sinhala-gpt2 with Docker Model Runner:
docker model run hf.co/keshan/sinhala-gpt2
Saving weights and logs of step 10
Browse files- sinhala-gpt2/config.json → config.json +0 -0
- config.py +1 -1
- sinhala-gpt2/events.out.tfevents.1625744111.t1v-n-0b4afe6c-w-0.150137.3.v2 → events.out.tfevents.1625851395.t1v-n-0b4afe6c-w-0.251724.3.v2 +2 -2
- flax_model.msgpack +3 -0
- run_clm_flax.py +0 -1
- si_tokenizer.py +1 -1
- sinhala-gpt2/flax_model.msgpack +0 -0
- sinhala-gpt2/tokenizer.json → tokenizer.json +0 -0
sinhala-gpt2/config.json → config.json
RENAMED
|
File without changes
|
config.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
from transformers import GPT2Config
|
| 2 |
|
| 3 |
-
model_dir = "
|
| 4 |
|
| 5 |
config = GPT2Config.from_pretrained("gpt2", resid_pdrop=0.0, embd_pdrop=0.0, attn_pdrop=0.0)
|
| 6 |
config.save_pretrained(model_dir)
|
|
|
|
| 1 |
from transformers import GPT2Config
|
| 2 |
|
| 3 |
+
model_dir = "./sihala-gpt2"
|
| 4 |
|
| 5 |
config = GPT2Config.from_pretrained("gpt2", resid_pdrop=0.0, embd_pdrop=0.0, attn_pdrop=0.0)
|
| 6 |
config.save_pretrained(model_dir)
|
sinhala-gpt2/events.out.tfevents.1625744111.t1v-n-0b4afe6c-w-0.150137.3.v2 → events.out.tfevents.1625851395.t1v-n-0b4afe6c-w-0.251724.3.v2
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e497ce08418104de7651e94eb9dffb54daac6d986bc927df823d3b9d8a78ae45
|
| 3 |
+
size 40
|
flax_model.msgpack
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:694fdb364154b16f66f557226c6f0006187a1fe305f6696be427aa8e7f634748
|
| 3 |
+
size 497764120
|
run_clm_flax.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
/home/Keshan/transformers/examples/flax/language-modeling/run_clm_flax.py
|
|
|
|
|
|
si_tokenizer.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
from datasets import load_dataset
|
| 2 |
from tokenizers import trainers, Tokenizer, normalizers, ByteLevelBPETokenizer
|
| 3 |
|
| 4 |
-
model_dir = "
|
| 5 |
|
| 6 |
# load dataset
|
| 7 |
dataset = load_dataset("mc4", "si", split="train")
|
|
|
|
| 1 |
from datasets import load_dataset
|
| 2 |
from tokenizers import trainers, Tokenizer, normalizers, ByteLevelBPETokenizer
|
| 3 |
|
| 4 |
+
model_dir = "sinhala-gpt2" # ${MODEL_DIR}
|
| 5 |
|
| 6 |
# load dataset
|
| 7 |
dataset = load_dataset("mc4", "si", split="train")
|
sinhala-gpt2/flax_model.msgpack
DELETED
|
File without changes
|
sinhala-gpt2/tokenizer.json → tokenizer.json
RENAMED
|
File without changes
|