Instructions to use SupratimRK/SmolLM2-360M-GEC with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use SupratimRK/SmolLM2-360M-GEC with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="SupratimRK/SmolLM2-360M-GEC") 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("SupratimRK/SmolLM2-360M-GEC") model = AutoModelForCausalLM.from_pretrained("SupratimRK/SmolLM2-360M-GEC", 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]:])) - PEFT
How to use SupratimRK/SmolLM2-360M-GEC with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use SupratimRK/SmolLM2-360M-GEC with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf SupratimRK/SmolLM2-360M-GEC # Run inference directly in the terminal: llama cli -hf SupratimRK/SmolLM2-360M-GEC
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf SupratimRK/SmolLM2-360M-GEC # Run inference directly in the terminal: llama cli -hf SupratimRK/SmolLM2-360M-GEC
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf SupratimRK/SmolLM2-360M-GEC # Run inference directly in the terminal: ./llama-cli -hf SupratimRK/SmolLM2-360M-GEC
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf SupratimRK/SmolLM2-360M-GEC # Run inference directly in the terminal: ./build/bin/llama-cli -hf SupratimRK/SmolLM2-360M-GEC
Use Docker
docker model run hf.co/SupratimRK/SmolLM2-360M-GEC
- LM Studio
- Jan
- vLLM
How to use SupratimRK/SmolLM2-360M-GEC with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "SupratimRK/SmolLM2-360M-GEC" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "SupratimRK/SmolLM2-360M-GEC", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/SupratimRK/SmolLM2-360M-GEC
- SGLang
How to use SupratimRK/SmolLM2-360M-GEC 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 "SupratimRK/SmolLM2-360M-GEC" \ --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": "SupratimRK/SmolLM2-360M-GEC", "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 "SupratimRK/SmolLM2-360M-GEC" \ --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": "SupratimRK/SmolLM2-360M-GEC", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use SupratimRK/SmolLM2-360M-GEC with Ollama:
ollama run hf.co/SupratimRK/SmolLM2-360M-GEC
- Unsloth Desktop
- Docker Model Runner
How to use SupratimRK/SmolLM2-360M-GEC with Docker Model Runner:
docker model run hf.co/SupratimRK/SmolLM2-360M-GEC
- Lemonade
How to use SupratimRK/SmolLM2-360M-GEC with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull SupratimRK/SmolLM2-360M-GEC
Run and chat with the model
lemonade run user.SmolLM2-360M-GEC-{{QUANT_TAG}}List all available models
lemonade list
- Atomic Chat
โ๏ธ SmolLM2-360M-GEC: High-Precision Grammar & Spelling Corrector
SmolLM2-360M-GEC is a lightweight, high-performance Grammatical Error Correction (GEC) and spelling correction model fine-tuned on top of HuggingFaceTB/SmolLM2-360M-Instruct.
Trained with completion-only loss masking on a curated multi-source corpus of ~290,000 real-world sentence pairs, it delivers state-of-the-art grammar, typo, syntax, and agreement corrections at a fraction of the computational footprint of industry models.
โก Key Highlights
- Ultra-Compact Footprint: At only 360M parameters (less than half the parameter count of
grammarly/coedit-large's 770M), it requires only ~550 MB VRAM when running the included Q8_0 GGUF (LM Studio / llama.cpp) and ~950 MB VRAM for native FP16 PyTorch inference. - Blazing Fast Throughput: Delivers 120 โ 180+ tokens/sec with 100% GPU offload on consumer GPUs (e.g., GTX 1650, RTX 3060, Apple Silicon) and runs in ~1 second per sentence on CPU.
- Zero Hallucination / Anti-Overcorrection: Trained with clean identity anchors (
source == target) ensuring 100% precision on already correct sentences without altering the user's intended meaning. - Dual Distribution: Packaged with standard Hugging Face
transformerssafetensors andllama.cppQ8_0 GGUF for instant deployment in LM Studio, Ollama, and local edge devices.
๐ฅ 3-Way Model Comparison
We rigorously evaluated SmolLM2-360M-GEC side-by-side against its Base Model (SmolLM2-360M-Instruct) and Grammarly's Industry Standard (grammarly/coedit-large, 770M Seq2Seq T5).
1. Architectural & Resource Profile
| Feature / Metric | Base Model (SmolLM2-360M-Instruct) |
Grammarly coedit-large |
Our SmolLM2-360M-GEC |
|---|---|---|---|
| Architecture | Causal LM (Decoder-Only) | FLAN-T5 (Encoder-Decoder) | Causal LM (Decoder-Only) |
| Parameter Count | 360 Million | 770 Million (2.1x larger) | 360 Million (Optimal) |
| Model Weights (FP16) | ~724 MB | ~1,540 MB (3,132 MB in FP32 release) | ~724 MB (model.safetensors) |
| Model Weights (Q8_0 GGUF) | ~386 MB (if quantized) | ~820 MB (if quantized) | ~368 MB (smollm2_gec_v1.5.gguf) |
| Active Peak VRAM (FP16 PyTorch) | ~950 MB (Weights + CUDA context) | ~2.0 โ 2.2 GB (Runs on 4GB GPUs) | ~950 MB (Weights + CUDA context) |
| Active Peak VRAM (Q8_0 GGUF) | ~550 MB (llama.cpp / LM Studio) | ~1.1 โ 1.3 GB (if quantized) | ~550 MB (llama.cpp / LM Studio) |
| GEC Behavior | Conversational chat; explains errors | Generates rewrite | Deterministic direct correction; zero fluff |
| Inference Latency (CPU) | ~1,800 ms | ~2,200 ms | ~1,200 โ 1,400 ms (Fastest) |
| Edge / Mobile Ready | Yes | Limited (Encoder-decoder is heavier on edge) | Yes (GGUF runs on phone/Pi/laptop) |
2. Empirical Benchmark Examples (Head-to-Head)
| Test Category | Input Sentence | Base Model (SmolLM2-Instruct) |
Grammarly coedit-large (770M) |
Our SmolLM2-360M-GEC |
|---|---|---|---|---|
| Missing Letter Typo | Please close the dor. |
Please close the door. โ
|
Please close the dor. โ (Missed typo) |
Please close the door. โ
(Fixed) |
| Double Misspelling | Please recieve my sincere appologies for the delay. |
I'm sorry for the delay. โ (Rewrites tone/wording) |
Please receive my sincere appologies for the delay. โ (Missed 2nd typo) |
Please receive my sincere apologies for the delay. โ
(Fixed both) |
| Past Subjunctive Conditional | If I would have known, I would have called you. |
If I had known, I would have called you. โ
|
If I would have known, I would have called you. โ (Missed error) |
If I had known, I would have called you. โ
(Fixed) |
| Subject-Verb Agreement | Neither of the students have submitted their assignment. |
Neither of the students have submitted their assignment. โ (Missed error) |
Neither of the students have submitted their assignments yet. โ (Hallucinated "yet") |
Neither of the students has submitted their assignment. โ
(Clean) |
| Collective Agreement | The number of applicants have increased, but a number of them is unqualified. |
The number of applicants has increased, but a number of them are unqualified. โ
|
The number of applicants has increased, but a number of them are unqualified. โ
|
The number of applicants has increased, but a number of them are unqualified. โ
|
| Redundant Conjunction | She asked me that whether I could lend her some money. |
She asked me if I could lend her some money. โ ๏ธ (Substituted "if" for "whether") |
She asked me whether I could lend her some money. โ
|
She asked me whether I could lend her some money. โ
|
| Clean Invariance (Zero-Hallucination) | The quick brown fox jumps over the lazy dog. |
The quick brown fox jumps over the lazy dog. โ
|
The quick brown fox jumps over the lazy dog. โ
|
The quick brown fox jumps over the lazy dog. โ
(Untouched) |
๐ Quickstart Guide
1. Using Hugging Face transformers
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "SupratimRK/SmolLM2-360M-GEC"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
device_map="auto" if torch.cuda.is_available() else None,
)
SYSTEM_PROMPT = (
"You are an expert grammar and spelling correction assistant. "
"Fix all grammatical, spelling, and punctuation errors. "
"Output only the corrected sentence without any explanation."
)
def correct_grammar(text: str) -> str:
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": text.strip()}
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=128,
do_sample=False, # Deterministic greedy decoding
pad_token_id=tokenizer.eos_token_id,
eos_token_id=[tokenizer.eos_token_id, tokenizer.convert_tokens_to_ids("<|im_end|>")]
)
decoded = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
return decoded.strip()
# Test
print(correct_grammar("she go to school yesterday and buyed apples"))
# Output: She went to school yesterday and bought apples.
print(correct_grammar("Their going to there house over they're."))
# Output: They are going to their house over there.
2. Running in LM Studio (GGUF)
- Download
smollm2_gec_v1.5.ggufdirectly from the Files and versions tab. - Place it into your LM Studio models directory:
~/.cache/lm-studio/models/SupratimRK/SmolLM2-360M-GEC/smollm2_gec_v1.5.gguf - Load the model and configure:
- GPU Offload: Set to MAX (32 layers) (uses ~550 MB VRAM).
- Chat Template: Select
ChatML(or paste the Jinja template below). - System Prompt:
You are an expert grammar and spelling correction assistant. Fix all grammatical, spelling, and punctuation errors. Output only the corrected sentence without any explanation. - Temperature:
0.0(Greedy decoding for deterministic grammar correction). - Stop Tokens:
<|im_end|>,<|endoftext|>.
3. LM Studio Jinja2 Chat Template
{% for message in messages %}
{% if loop.first and messages[0]['role'] != 'system' %}
{{ '<|im_start|>system\nYou are an expert grammar and spelling correction assistant. Fix all grammatical, spelling, and punctuation errors. Output only the corrected sentence without any explanation.<|im_end|>\n' }}
{% endif %}
{{ '<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>\n' }}
{% endfor %}
{% if add_generation_prompt %}
{{ '<|im_start|>assistant\n' }}
{% endif %}
๐ฌ Training Methodology
- Base Model:
HuggingFaceTB/SmolLM2-360M-Instruct - Fine-Tuning Paradigm: LoRA (Low-Rank Adaptation)
- Rank ($r$): 16 | Alpha ($\alpha$): 32 | Dropout: 0.05
- Target Modules: All linear projections (
q_proj,k_proj,v_proj,o_proj,gate_proj,up_proj,down_proj)
- Loss Masking Strategy: Completion-Only Loss Masking. Loss is computed strictly over the corrected target tokens; all system instructions and user input prompt tokens are assigned a loss label of
-100. - Training Corpus: ~290,000 multi-domain gold sentence pairs:
grammarly/coedit(GEC Task)- Cambridge W&I-LOCNESS Detokenized ESL Corpus
agentlans/grammar-correctionSyntactic CorpusProCreations/Mistake-To-MeaningKeyboard & OCR Typosguychuk/typos-misspellings-homophonesConfusable Words- Clean Identity Invariance Anchors (
source == target)
๐ License & Attribution
This model is licensed under the Apache 2.0 License, inherited from the foundational SmolLM2 architecture. You are free to use, modify, and integrate this model into commercial and personal applications.
- Downloads last month
- 44
Model tree for SupratimRK/SmolLM2-360M-GEC
Base model
HuggingFaceTB/SmolLM2-360M