Text Generation
Transformers
Safetensors
Kazakh
llama
kazakh
causal-lm
language-model
pretrained
Eval Results (legacy)
text-generation-inference

You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

SozKZ Llama 150M — Kazakh Language Model

A 152.75M parameter Llama-architecture language model pretrained from scratch on 3.11 billion tokens of Kazakh text. This is the first dense Kazakh-only model in the SozKZ family, trained with a custom 200K-vocab Kazakh tokenizer for high-quality Kazakh text generation.

Key Highlights

  • Trained from scratch — no English pretraining, no multilingual base. Pure Kazakh.
  • 200K vocabulary — a custom ByteLevel BPE tokenizer (stukenov/sozkz-core-gpt2-200k-kk-base-v1) optimized for Kazakh morphology, achieving ~1.2 tokens/word (vs. ~3-4 for multilingual tokenizers).
  • 3.11B tokens of clean Kazakh text from two curated datasets.
  • Eval perplexity: 32.7 after 1 epoch of training. Loss curve shows no plateau — further training would improve quality.

Model Architecture

Parameter Value
Architecture LlamaForCausalLM
Parameters 152.75M (unique)
Vocabulary size 200,019
Hidden size 512
Intermediate size (SwiGLU) 2,048
Attention heads 8 (MHA, head_dim=64)
KV heads 8
Layers 12
Max sequence length 2,048
Positional encoding RoPE (θ=10000)
Activation SiLU (SwiGLU)
Tied embeddings Yes
Embedding params ~102M
Transformer params ~50M

Training Details

Data

Dataset Train Samples Val Samples
stukenov/sozkz-corpus-tokenized-kk-200k-v1 ~920K ~48K
stukenov/sozkz-corpus-tokenized-kk-multidomain-200k-v1 ~600K ~32K
Total 1,520,133 80,008

Each sample is a pre-tokenized chunk of 2,048 tokens. Total training corpus: 3.11 billion tokens.

Hyperparameters

Parameter Value
Epochs 1
Total steps 11,877
Batch size per GPU 2
Gradient accumulation 32
GPUs 2× NVIDIA A10 (22GB)
Effective batch size 128 (= 2 × 32 × 2 GPUs)
Tokens per batch 262,144 (128 × 2048)
Learning rate 6e-4
LR scheduler Cosine decay
Warmup steps 500
Weight decay 0.1
Max gradient norm 1.0
Precision bf16
Gradient checkpointing Yes
Distributed strategy DDP (PyTorch)
Training time ~35 hours

Loss Curve

Training loss decreased steadily throughout the run with no signs of plateau:

Step Train Loss Eval Loss Perplexity
1,000 4.04 4.662 105.8
2,000 3.83 4.121 61.6
3,000 3.80 3.926 50.9
4,000 3.77 3.814 45.3
5,000 3.72 3.732 41.8
6,000 3.68 3.668 39.2
7,000 3.63 3.611 37.0
8,000 3.564 35.3
9,000 3.526 34.0
10,000 3.500 33.1
11,000 3.487 32.7
11,877 (final) 3.45

Note: The loss curve shows consistent improvement without plateau. Multi-epoch training is expected to further reduce perplexity.

Tokenizer

This model uses a custom 200K-vocabulary ByteLevel BPE tokenizer: stukenov/sozkz-core-gpt2-200k-kk-base-v1.

Key properties:

  • Vocabulary: 200,019 tokens
  • Type: ByteLevel BPE (GPT-2 style)
  • Kazakh efficiency: ~1.2 tokens per Kazakh word (vs. ~3-4 for LLaMA/GPT tokenizers)
  • Special tokens: BOS=2, EOS=0, PAD=1

Usage

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "stukenov/sozkz-llama-150m-200k-kk-base-v1"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16)
model.eval()

prompt = "Қазақстан —"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(
    **inputs,
    max_new_tokens=100,
    temperature=0.8,
    top_p=0.9,
    top_k=50,
    repetition_penalty=1.1,
    do_sample=True,
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

Generation Examples (Final Checkpoint)

Prompt: "Қазақстан —"

Қазақстан — Атырау облысы Құрманғазы ауданындағы ауыл, ауылдық округ орталығы. Су реестрінің мәліметтері бойынша Жоғарғы Еділ су алабы өңіріне жатады...

Prompt: "Білім алу өте"

Білім алу өте пайдалы. Оны пайдалану үшін менің және ата-анамның көмегі керек. Ал, қазіргі таңда балаларымның болашағы зор деп ойлаймын. Өйткені оларға да жақсы білім беріп, жан-жақты болуға тырысудамын...

Prompt: "Менің атым"

Менің атым — Қожа. Ол — менің досым. Менің атам — Қожа Ахмет Йассауи (12 ғасыр шамасында өлген). Өзі ақын, аты әлемге әйгілі болған кісі. Оның шығармалары әлем әдебиетіне қосылған ірі еңбек болып табылады...

Prompt: "Қазақ тілі —"

Қазақ тілі — мемлекеттік тіл. Тіл туралы заң бойынша, Қазақстан Республикасында тұратын барлық халықтар өздерінің ана тілінде сөйлесе алады. Қазақ тілінде еркін сөйлеп қана қоймай, шетел тілдерін меңгеру үшін жағдай бар...

Prompt: "Бүгінгі күні"

Бүгінгі күні қала халқының саны жыл санап артып келеді. Осы тұста Елбасы Нұрсұлтан Назарбаев еліміздің жаңа елордасы – Астананы салудың маңыздылығын ерекше атап өтті...

Quality Progression Across Checkpoints

The model shows clear quality improvement during training:

  • Checkpoint 3,000 (25%): Grammatically correct but frequent topic jumping between sentences.
  • Checkpoint 4,000 (34%): Structured lists appear, real citations, some code-switching to Russian.
  • Checkpoint 6,000 (51%): More coherent multi-sentence passages, real politicians' names, less topic drift.
  • Checkpoint 7,000 (59%): ISBN numbers, lesson plans, connected family narratives. Occasional repetition loops.
  • Final model (100%): Coherent paragraphs with factual references, institutional names, legal citations. Minimal repetition.

Limitations

  • Base model only — not instruction-tuned or RLHF-aligned. Generates continuation text, not answers.
  • Single epoch — the loss curve shows no plateau; additional training epochs would likely improve quality.
  • Small scale — at 150M parameters, the model has limited world knowledge and reasoning capacity.
  • Hallucinations — the model generates plausible-sounding but factually incorrect information (e.g., fake ISBN numbers, incorrect attributions).
  • Repetition — occasional repetition loops, especially on longer generations (>150 tokens).
  • No safety filtering — the model may generate harmful, biased, or offensive content.

Intended Use

  • Research on Kazakh language modeling
  • Baseline for Kazakh NLP benchmarks
  • Foundation for fine-tuning on downstream Kazakh tasks (summarization, classification, QA)
  • Studying tokenizer efficiency for agglutinative languages

Infrastructure

  • Hardware: 2× NVIDIA A10 (22GB VRAM each)
  • Software: PyTorch 2.10, Transformers 5.1, CUDA 12.8
  • Training: DDP (DistributedDataParallel), bf16 mixed precision
  • Training time: ~35 hours

Citation

@misc{sozkz-llama-150m-2026,
  title={SozKZ Llama 150M: A Kazakh Language Model},
  author={Saken Tukenov},
  year={2026},
  url={https://huggingface.co/stukenov/sozkz-llama-150m-200k-kk-base-v1}
}

License

Apache 2.0

Downloads last month
-
Safetensors
Model size
0.2B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collection including stukenov/sozkz-llama-150m-200k-kk-base-v1

Evaluation results