Instructions to use lm-spell/gemma3-270m-it-ft-ssc with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lm-spell/gemma3-270m-it-ft-ssc with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="lm-spell/gemma3-270m-it-ft-ssc") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("lm-spell/gemma3-270m-it-ft-ssc") model = AutoModelForCausalLM.from_pretrained("lm-spell/gemma3-270m-it-ft-ssc", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use lm-spell/gemma3-270m-it-ft-ssc with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "lm-spell/gemma3-270m-it-ft-ssc" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lm-spell/gemma3-270m-it-ft-ssc", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/lm-spell/gemma3-270m-it-ft-ssc
- SGLang
How to use lm-spell/gemma3-270m-it-ft-ssc 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 "lm-spell/gemma3-270m-it-ft-ssc" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lm-spell/gemma3-270m-it-ft-ssc", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "lm-spell/gemma3-270m-it-ft-ssc" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lm-spell/gemma3-270m-it-ft-ssc", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use lm-spell/gemma3-270m-it-ft-ssc with Docker Model Runner:
docker model run hf.co/lm-spell/gemma3-270m-it-ft-ssc
Gemma 3 270M IT Fine-tuned for Sinhala Spell Correction
A Gemma 3 270M IT model fine-tuned for Sinhala spell correction as part of the LMSpell project.
Model Details
- Base model:
unsloth/gemma-3-270m-it - Model type: Fine-tuned model
- Language: Sinhala (
si) - Task: Sinhala Spell Correction (SSC)
- Training method: Supervised Fine-Tuning (SFT)
- Dataset: Sinhala Spell Correction Dataset
- License: CC BY 4.0
- Project: LMSpell
Uses
Direct Use
The model can be used to correct spelling errors in Sinhala text.
Out-of-Scope Use
The model is not intended for languages other than Sinhala or for tasks unrelated to spell correction.
Limitations
- Performance may vary across different domains and text styles.
- The model may occasionally modify text that is already correctly spelled.
- Performance may be lower on informal, code-mixed, or domain-specific text.
How to Get Started
1. Model Loading
from transformers import AutoTokenizer, AutoModelForCausalLM
model_name = "lm-spell/gemma3-270m-it-ft-ssc"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
tokenizer.pad_token = tokenizer.eos_token
2. Inference
import re
def clean_text(text):
match = re.search(r'### Output:\n(.*)', text, re.DOTALL)
if match:
return match.group(1).replace("Text:\n", "").replace("Output:\n", "").replace("###", "").strip()
return text.strip()
alpaca_prompt = f"""You are an Expert Sinhala Spell Corrector. Below is a sentence in Sinhala Language. It may or may not have a spelling mistake. Give the corrected output in Sinhala.
### Text:
{{}}
### Output:
{{}}"""
text = "เถบเทเถฑเท เทเทเถเทเถฑเทเถฑเท เถดเทเถญเทเถฑเท เถ
เถฐเทโเถบเทเถดเถฑ เถเทโเถปเถธเถบเท เถดเทเถญเทเถฑ เถเทเท เถธเถงเทเถงเถธเถบ ."
inputs = tokenizer(
[alpaca_prompt.format(text, "")],
return_tensors="pt"
)
outputs = model.generate(**inputs)
pred_text = tokenizer.decode(
outputs[0],
skip_special_tokens=True
)
print(clean_text(pred_text))
Training Details
Training Data
The model was fine-tuned using the Sinhala Spell Correction Dataset.
Training Procedure
The model was fine-tuned using Supervised Fine-Tuning (SFT) with Unsloth.
Evaluation
The model was evaluated for Sinhala spell correction using the evaluation datasets and metrics described in the LMSpell paper.
For detailed training methodology, dataset preparation, evaluation results, and comparisons with other models, please refer to the paper.
Research
LMSpell: Spell Correction with Pre-Trained Language Models
A. Gunathilake, N. Karunarathna, T. Bandaranayake, S. Ranathunga, N. de Silva and N. Jayatilleke, "LMSpell: Spell Correction with Pre-Trained Language Models," 2026 Moratuwa Engineering Research Conference (MERCon), Moratuwa, Sri Lanka, 2026, pp. 503-508.
- Paper: https://doi.org/10.1109/MERCon71835.2026.11691371
- Extended Preprint: https://arxiv.org/html/2512.05414v3
Citation
@INPROCEEDINGS{11691371,
author={Gunathilake, Akesh and Karunarathna, Nadil and Bandaranayake, Tharusha and Ranathunga, Surangika and de Silva, Nisansa and Jayatilleke, Nevidu},
booktitle={2026 Moratuwa Engineering Research Conference (MERCon)},
title={LMSpell: Spell Correction with Pre-Trained Language Models},
year={2026},
pages={503-508},
doi={10.1109/MERCon71835.2026.11691371}
}
- Downloads last month
- -