Instructions to use mengsay/Gemma-3-Tonsai-1B-v0.1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mengsay/Gemma-3-Tonsai-1B-v0.1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mengsay/Gemma-3-Tonsai-1B-v0.1")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("mengsay/Gemma-3-Tonsai-1B-v0.1") model = AutoModelForCausalLM.from_pretrained("mengsay/Gemma-3-Tonsai-1B-v0.1") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use mengsay/Gemma-3-Tonsai-1B-v0.1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mengsay/Gemma-3-Tonsai-1B-v0.1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mengsay/Gemma-3-Tonsai-1B-v0.1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/mengsay/Gemma-3-Tonsai-1B-v0.1
- SGLang
How to use mengsay/Gemma-3-Tonsai-1B-v0.1 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 "mengsay/Gemma-3-Tonsai-1B-v0.1" \ --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": "mengsay/Gemma-3-Tonsai-1B-v0.1", "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 "mengsay/Gemma-3-Tonsai-1B-v0.1" \ --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": "mengsay/Gemma-3-Tonsai-1B-v0.1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use mengsay/Gemma-3-Tonsai-1B-v0.1 with Docker Model Runner:
docker model run hf.co/mengsay/Gemma-3-Tonsai-1B-v0.1
Gemma-3-Tonsai-1B-v0.1
Preview Release: This is an early preview (v0.1) for validation purposes. Not intended for production use. Evaluation and model quality may improve in future versions.
Gemma-3-Tonsai-1B is a Khmer-enhanced language model built through Continued Pre-Training (CPT) of Google's Gemma 3 1B on a mixture of Khmer, English, and parallel data.
"Tonsai" (ទន្សាយ) means "rabbit" in Khmer.
Note: This is a base model trained via Continued Pre-Training. It is designed as a foundation for downstream task-specific fine-tuning (e.g., translation, summarization, question answering). For best results, we recommend fine-tuning on your target task using Supervised Fine-Tuning (SFT) before deployment.
Model Details
| Base Model | google/gemma-3-1b-pt |
| Training Method | Continued Pre-Training (CPT), full parameter update |
| Languages | Khmer (km), English (en) |
| Parameters | ~1B |
| Context Length | 4096 tokens |
| Precision | bfloat16 |
| License | Gemma Terms of Use |
Model Lineage
google/gemma-3-1b-pt
└── mengsay/Gemma-3-Tonsai-1B-v0.1 (CPT on Khmer data)
Training
Data Mix
| Dataset | Type | Weight | Role |
|---|---|---|---|
| CulturaX (km) | Monolingual | 55% | Khmer web text |
| Wikipedia (km) | Monolingual | 5% | High-quality Khmer |
| CulturaX (en) | Monolingual | 10% | English retention |
| OPUS-100 (en-km) | Parallel | 15% | Cross-lingual alignment |
| OpenHermes 2.5 | Instruction | 10% | Instruction following |
| Khmer Dictionary 44K | Dictionary | 5% | Vocabulary knowledge |
Hyperparameters
| Parameter | Value |
|---|---|
| Effective batch size | 64 (32 per device x 2 grad accum) |
| Max sequence length | 4096 |
| Learning rate | 5e-5 (embedding: 1e-5) |
| LR scheduler | Cosine with warmup |
| Warmup steps | 200 |
| Weight decay | 0.01 |
| Optimizer | AdamW 8-bit |
| Gradient checkpointing | Unsloth |
| Hardware | NVIDIA RTX PRO 6000 Blackwell (95GB VRAM) |
Evaluation
Evaluation on OPUS-100 (en-km) translation and Khmer perplexity tasks.
Perplexity (lower is better)
| Dataset | Gemma-3-1B-PT (base) | Tonsai-1B v0.1 |
|---|---|---|
| Wikipedia (km) | 9.06 | 2.14 |
| CulturaX (km) | 7.09 | 7.90 |
Khmer Wikipedia perplexity drops dramatically (9.06 → 2.14), showing significant improvement in Khmer text prediction. CulturaX perplexity is comparable, as the model is still mid-training.
Translation (OPUS-100, 500 samples)
| Task | Setting | Metric | Gemma-3-1B-PT (base) | Tonsai-1B v0.1 |
|---|---|---|---|---|
| en→km | zero-shot | BLEU | 1.62 | 18.04 |
| en→km | 5-shot | BLEU | 3.71 | 19.34 |
| en→km | zero-shot | chrF | 4.45 | 36.25 |
| en→km | 5-shot | chrF | 16.60 | 37.14 |
| km→en | zero-shot | BLEU | 9.38 | 19.66 |
| km→en | 5-shot | BLEU | 13.12 | 19.00 |
| km→en | zero-shot | chrF | 31.21 | 44.57 |
| km→en | 5-shot | chrF | 35.70 | 42.09 |
Translation performance improves substantially in both directions, especially en→km zero-shot (BLEU 1.62 → 18.04).
Usage
Text Generation
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_name = "mengsay/Gemma-3-Tonsai-1B-v0.1"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.bfloat16,
device_map="auto",
)
prompt = "ជីវិតរស់នៅក្នុងទីក្រុងសព្វថ្ងៃពិតជា"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=200)
print(tokenizer.decode(output[0], skip_special_tokens=True))
Translation Example
prompt = "English: Cambodia is a country in Southeast Asia.\nKhmer:"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=256, do_sample=False)
print(tokenizer.decode(output[0], skip_special_tokens=True))
With vLLM Serving
# Start vLLM server
python -m vllm.entrypoints.openai.api_server \
--model mengsay/Gemma-3-Tonsai-1B-v0.1 --port 8000
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
response = client.completions.create(
model="mengsay/Gemma-3-Tonsai-1B-v0.1",
prompt="Cambodia is",
max_tokens=200,
)
print(response.choices[0].text)
Intended Use
This model is a continual pre-trained base model — it has been trained to improve Khmer language understanding and generation but has not been fine-tuned for any specific task or instruction following.
Recommended workflow:
- Use this model as a starting point for Supervised Fine-Tuning (SFT) on your target task
- Example downstream tasks: translation (en↔km), summarization, question answering, text classification
- Fine-tuning with even a few thousand task-specific examples can significantly improve performance
Not recommended for:
- Direct use as a chatbot or instruction-following assistant (use an instruction-tuned variant instead)
- Production deployment without task-specific fine-tuning and evaluation
Limitations
- This is a preview release (v0.1) intended for validation and research
- This is a CPT base model — fine-tuning on a specific task is recommended before use
- Not optimized for instruction following or conversational use
- May generate incorrect, biased, or harmful content
- Khmer language quality is preliminary; comprehensive benchmarks will follow in future versions
- Training data may contain biases present in web-crawled corpora
Citation
@misc{tonsai-lm-2026,
title = {Tonsai LM: Continued Pre-Training for Khmer Language Models},
author = {Mengsay Loem},
year = {2026},
url = {https://huggingface.co/mengsay/Gemma-3-Tonsai-1B-v0.1}
}
Acknowledgements
- Google Gemma team for the base model
- Unsloth for training optimization
- HuggingFace dataset contributors for open Khmer language resources
- Tonsai LM project
- Downloads last month
- 5
Model tree for mengsay/Gemma-3-Tonsai-1B-v0.1
Base model
google/gemma-3-1b-pt