Text Generation
Transformers
Safetensors
Kazakh
deepseek_v3
kazakh
grammar-correction
gec
chatml
conversational
text-generation-inference
Instructions to use TilQazyna/Til-2B-GEC with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use TilQazyna/Til-2B-GEC with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="TilQazyna/Til-2B-GEC") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("TilQazyna/Til-2B-GEC") model = AutoModelForCausalLM.from_pretrained("TilQazyna/Til-2B-GEC") 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use TilQazyna/Til-2B-GEC with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "TilQazyna/Til-2B-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": "TilQazyna/Til-2B-GEC", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/TilQazyna/Til-2B-GEC
- SGLang
How to use TilQazyna/Til-2B-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 "TilQazyna/Til-2B-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": "TilQazyna/Til-2B-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 "TilQazyna/Til-2B-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": "TilQazyna/Til-2B-GEC", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use TilQazyna/Til-2B-GEC with Docker Model Runner:
docker model run hf.co/TilQazyna/Til-2B-GEC
Til-2B-GEC
Til-2B-GEC — қазақ мәтініндегі грамматикалық, орфографиялық және пунктуациялық қателерді түзететін модель. Til-2B base-моделінің fine-tune нұсқасы.
Til-2B-GEC is a Kazakh grammatical-error-correction model — a fine-tune of the Til-2B base model. Given a Kazakh sentence with spelling, grammar or punctuation errors, it returns a corrected version.
What it fixes
Trained on Kazakh error pairs spanning 10 grammar categories:
- Септік жалғау (case endings) · Жіктік жалғау (personal/predicative endings)
- Тәуелдік жалғау (possessive) · Көптік жалғау (plural)
- Шылау (postpositions/particles) · Шақ (tense) · Болымсыздық (negation)
- Сөз тәртібі (word order) · Құрмалас сөйлем (compound sentences) · Үндестік заңы (vowel/consonant harmony)
- Kazakh-letter confusions (
жанбыр→жаңбыр,бул→бұл,окыдым→оқыдым), capitalization, missing punctuation.
Model details
| Base | TilQazyna/Til-2B (1977M, dense + MLA) |
| Format | ChatML, assistant-only loss |
| Data | ~316K Kazakh GEC pairs: human-annotated grammar errors (10 categories) + synthetic typed-error injection over clean sentences |
| Epochs / LR | 3 / 1e-5 (cosine), bf16 |
| Context | 4096 |
The training instruction (fixed, Kazakh):
Мәтіндегі грамматикалық, орфографиялық және пунктуациялық қателерді түзет. Тек түзетілген мәтінді қайтар.
Usage
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "TilQazyna/Til-2B-GEC"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, dtype=torch.bfloat16, device_map="auto")
INSTR = ("Мәтіндегі грамматикалық, орфографиялық және пунктуациялық қателерді түзет. "
"Тек түзетілген мәтінді қайтар.")
def correct(text: str) -> str:
msgs = [{"role": "user", "content": f"{INSTR}\n\nМәтін: {text}"}]
prompt = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True)
ids = tok(prompt, return_tensors="pt", add_special_tokens=False).input_ids.to(model.device)
out = model.generate(ids, max_new_tokens=128, do_sample=False, pad_token_id=0,
eos_token_id=tok.convert_tokens_to_ids("<|im_end|>"))
text_out = tok.decode(out[0][ids.shape[1]:], skip_special_tokens=True)
return text_out.strip().split("\n")[0].strip()
print(correct("Алматыда ауа райы жақсы болды кеше жанбыр жауды"))
Intended use & limitations
- Intended: correcting single sentences or short paragraphs of Kazakh text.
- Best on single sentences; correct long inputs sentence-by-sentence.
- May occasionally rephrase rather than minimally correct.
- Kazakh only; not a style checker or translator.
- No safety alignment has been applied.
License
Apache 2.0. Access is gated (manual approval) for usage tracking.
- Downloads last month
- -
Model tree for TilQazyna/Til-2B-GEC
Base model
TilQazyna/Til-2B