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 Core Llama 150M Kazakh Instruct v2

A 152M-parameter instruction-following language model for Kazakh, fine-tuned from the base model using SFT on 368K ChatML multi-turn examples.

Key improvement over instruct-v1: 26x more training data (368K vs 49K), ChatML multi-turn format (vs Alpaca single-turn), final loss 1.5 (vs 2.918).

Model Details

Architecture LlamaForCausalLM
Parameters 152M
Layers 16
Hidden size 768
Attention heads 12
Vocab size 50,265 (50,261 + 4 ChatML tokens)
Max length 1024
Base model sozkz-core-llama-150m-kk-base-v1
Tokenizer sozkz-core-gpt2-50k-kk-base-v1 + ChatML tokens

Chat Template (ChatML)

<|user|>
What is the capital of Kazakhstan?
<|end|>
<|assistant|>
The capital of Kazakhstan is Astana.
<|end|>

Special tokens: <|system|>, <|user|>, <|assistant|>, <|end|>

Multi-turn conversations are supported by chaining message blocks.

Usage

from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

model_id = "stukenov/sozkz-core-llama-150m-kk-instruct-v2"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float32)

prompt = "<|user|>\nНаурыз мейрамы туралы айтып бер.\n<|end|>\n<|assistant|>\n"
inputs = tokenizer(prompt, return_tensors="pt")
with torch.no_grad():
    out = model.generate(
        **inputs,
        max_new_tokens=200,
        temperature=0.7,
        top_p=0.9,
        repetition_penalty=1.2,
    )
print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))

Example Outputs

Generation parameters: temperature=0.3, top_p=0.9, repetition_penalty=1.2

Q: Қазақстанның астанасы қандай?

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

Q: Абай Құнанбайұлы кім?

Ақын, ақын және ойшыл. 1. Абай - ұлы ақын және философ. 2. Ол адам мен табиғат арасындағы қарым-қатынасты зерттейді. 3. Оның шығармалары көбінесе философиялық мәселелерге бағытталған. 4. Оның өлеңдері адамның табиғатын түсінуге көмектеседі...

Q: Наурыз мейрамы туралы қысқаша айтып бер.

1-наурыз - бұл күн мен түннің теңелуі, көктемнің басталуы және табиғаттың оянуы. Бұл күні адамдар бір-біріне сыйлықтар беріп, жаңа жылды қарсы алу үшін жиналады...

Q: Бесбармақ қалай дайындалады?

Дәміне қарай, бір тілім нан немесе тоқаш. Тұздалған және пісірілген тағамдарға арналған рецептке сәйкес, ол жақсы қуырылған табада қуырылады...

The model generates coherent Kazakh text with partially correct factual information. Hallucinations are expected for a 152M parameter model.

Training

Dataset

Mixed from 3 sources, deduplicated by MD5(first user message):

Source Format Rows License
sozkz-instruct-chatml-kk-v1 ChatML 1,280,423 Apache 2.0
saillab/alpaca_kazakh_taco Alpaca to ChatML 62,308 MIT
AmanMussa/kazakh-instruction-v2 Alpaca to ChatML 52,201 MIT

After deduplication: 365,168 train / 3,689 validation (368,857 total).

The translated ChatML dataset was created by translating 9 English instruct sources (1.3M rows) from EN to KK using CTranslate2 with HPLT Marian (opus-mt-en-kk).

Hyperparameters

Parameter Value
Learning rate 2e-5
Scheduler Cosine with 3% warmup
Epochs 1
Effective batch size 512 (4 per device x 16 GPUs x 8 grad accum)
Max length 1024
Loss masking Train only on assistant tokens
Weight decay 0.01
Max grad norm 1.0

Training Loss

Step Loss
10 3.302
20 2.984
30 2.658
40 2.374
50 2.131
60 1.892

Final loss: approximately 1.5 (714 steps total)

Infrastructure

  • Hardware: 16x NVIDIA RTX 4090 (vast.ai)
  • Training time: approximately 13 minutes
  • Cost: approximately $1.40
  • Framework: PyTorch 2.4.1, transformers 5.x, torchrun DDP

Comparison with v1

instruct-v1 instruct-v2
Format Alpaca (single-turn) ChatML (multi-turn)
Dataset size 49K 368K (26x)
Final loss 2.918 1.5
Max length 512 1024
Training 2x A5000, 12 min 16x RTX 4090, 13 min

Benchmarks

kk-socio-cultural-bench-mc (7111 questions, 4 choices)

Model Accuracy
instruct-v1 10.4%
instruct-v2 10.9%
Random baseline 25.0%

Kaz-Offline-Arena (500 questions, GPT-4o judge, 0-10)

Model Avg Score Avg Tokens
instruct-v1 0.48/10 24.7
instruct-v2 0.00/10 694.7

152M parameters is critically insufficient for open-ended QA. The model learned the ChatML format and generates longer responses, but output quality is incoherent. Scaling to >1B parameters is needed.

Limitations

  • 152M parameters: limited factual knowledge and reasoning capability
  • Kazakh-only; may produce mixed-language output for ambiguous prompts
  • Training data is machine-translated (EN to KK), which may introduce translation artifacts
  • Not suitable for production use without further alignment

License

Apache 2.0

Citation

Part of the SLM project — Small Language Models for Kazakh.

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

Model tree for stukenov/sozkz-core-llama-150m-kk-instruct-v2

Finetuned
(2)
this model

Dataset used to train stukenov/sozkz-core-llama-150m-kk-instruct-v2

Collection including stukenov/sozkz-core-llama-150m-kk-instruct-v2