Saken Tukenov commited on
Migrated from saken-tukenov/kazakh-gpt2-8m
Browse files- README.md +77 -0
- config.json +34 -0
- generation_config.json +12 -0
- model.safetensors +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +10 -0
README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- kk
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
library_name: transformers
|
| 6 |
+
tags:
|
| 7 |
+
- gpt2
|
| 8 |
+
- kazakh
|
| 9 |
+
- causal-lm
|
| 10 |
+
- from-scratch
|
| 11 |
+
- soz
|
| 12 |
+
pipeline_tag: text-generation
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# Kazakh GPT-2 8M (Soz)
|
| 16 |
+
|
| 17 |
+
A small GPT-2 language model trained from scratch on Kazakh text. Part of the Soz project for building native Kazakh language models.
|
| 18 |
+
|
| 19 |
+
## Overview
|
| 20 |
+
|
| 21 |
+
| Property | Value |
|
| 22 |
+
|----------|-------|
|
| 23 |
+
| **Parameters** | ~8M |
|
| 24 |
+
| **Architecture** | GPT-2 |
|
| 25 |
+
| **Vocab size** | 50,257 |
|
| 26 |
+
| **Hidden dim** | 128 |
|
| 27 |
+
| **Layers** | 6 |
|
| 28 |
+
| **Attention heads** | 4 |
|
| 29 |
+
| **FFN inner dim** | 512 |
|
| 30 |
+
| **Training data** | [kazakh-clean-pretrain](https://huggingface.co/datasets/saken-tukenov/kazakh-clean-pretrain) (~80M tokens) |
|
| 31 |
+
| **Epochs** | 2 |
|
| 32 |
+
| **Final train loss** | ~6.4 |
|
| 33 |
+
| **Tokenizer** | [kazakh-gpt2-50k](https://huggingface.co/saken-tukenov/kazakh-gpt2-50k) |
|
| 34 |
+
| **License** | Apache 2.0 |
|
| 35 |
+
|
| 36 |
+
## Design
|
| 37 |
+
|
| 38 |
+
This is the smallest model in the Soz GPT-2 family. At ~8M parameters with ~80M training tokens, it is approximately Chinchilla-optimal (tokens-to-params ratio of ~10:1). It serves as a baseline for scaling experiments.
|
| 39 |
+
|
| 40 |
+
## Usage
|
| 41 |
+
|
| 42 |
+
```python
|
| 43 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 44 |
+
|
| 45 |
+
tokenizer = AutoTokenizer.from_pretrained("saken-tukenov/kazakh-gpt2-50k")
|
| 46 |
+
model = AutoModelForCausalLM.from_pretrained("saken-tukenov/kazakh-gpt2-8m")
|
| 47 |
+
|
| 48 |
+
input_ids = tokenizer("Қазақстан — ", return_tensors="pt").input_ids
|
| 49 |
+
output = model.generate(input_ids, max_new_tokens=50, do_sample=True, temperature=0.8)
|
| 50 |
+
print(tokenizer.decode(output[0], skip_special_tokens=True))
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
## Training Details
|
| 54 |
+
|
| 55 |
+
- Trained from scratch using the Soz training pipeline
|
| 56 |
+
- Optimizer: AdamW
|
| 57 |
+
- Precision: bfloat16
|
| 58 |
+
- Hardware: NVIDIA A10 GPUs
|
| 59 |
+
|
| 60 |
+
## Project
|
| 61 |
+
|
| 62 |
+
Part of the [Soz — Kazakh Language Models](https://github.com/saken-tukenov) project, a research effort to build open-source language models for Kazakh.
|
| 63 |
+
|
| 64 |
+
## Citation
|
| 65 |
+
|
| 66 |
+
```bibtex
|
| 67 |
+
@misc{tukenov2026soz,
|
| 68 |
+
title={Soz: Small Language Models for Kazakh},
|
| 69 |
+
author={Tukenov, Saken},
|
| 70 |
+
year={2026},
|
| 71 |
+
url={https://huggingface.co/saken-tukenov/kazakh-gpt2-8m}
|
| 72 |
+
}
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
## License
|
| 76 |
+
|
| 77 |
+
Apache 2.0
|
config.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation_function": "gelu_new",
|
| 3 |
+
"add_cross_attention": false,
|
| 4 |
+
"architectures": [
|
| 5 |
+
"GPT2LMHeadModel"
|
| 6 |
+
],
|
| 7 |
+
"attn_pdrop": 0.1,
|
| 8 |
+
"bos_token_id": 2,
|
| 9 |
+
"dtype": "float32",
|
| 10 |
+
"embd_pdrop": 0.1,
|
| 11 |
+
"eos_token_id": 0,
|
| 12 |
+
"initializer_range": 0.02,
|
| 13 |
+
"layer_norm_epsilon": 1e-05,
|
| 14 |
+
"model_type": "gpt2",
|
| 15 |
+
"n_embd": 128,
|
| 16 |
+
"n_head": 4,
|
| 17 |
+
"n_inner": 512,
|
| 18 |
+
"n_layer": 6,
|
| 19 |
+
"n_positions": 1024,
|
| 20 |
+
"pad_token_id": 1,
|
| 21 |
+
"reorder_and_upcast_attn": false,
|
| 22 |
+
"resid_pdrop": 0.1,
|
| 23 |
+
"scale_attn_by_inverse_layer_idx": false,
|
| 24 |
+
"scale_attn_weights": true,
|
| 25 |
+
"summary_activation": null,
|
| 26 |
+
"summary_first_dropout": 0.1,
|
| 27 |
+
"summary_proj_to_labels": true,
|
| 28 |
+
"summary_type": "cls_index",
|
| 29 |
+
"summary_use_proj": true,
|
| 30 |
+
"tie_word_embeddings": true,
|
| 31 |
+
"transformers_version": "5.1.0",
|
| 32 |
+
"use_cache": false,
|
| 33 |
+
"vocab_size": 50257
|
| 34 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 2,
|
| 4 |
+
"eos_token_id": [
|
| 5 |
+
0
|
| 6 |
+
],
|
| 7 |
+
"output_attentions": false,
|
| 8 |
+
"output_hidden_states": false,
|
| 9 |
+
"pad_token_id": 1,
|
| 10 |
+
"transformers_version": "5.1.0",
|
| 11 |
+
"use_cache": true
|
| 12 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3629867ad26de1ca422c7aa68f2429cf982976b01f881ea3543b828268119d4f
|
| 3 |
+
size 31022800
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"bos_token": "<|startoftext|>",
|
| 4 |
+
"eos_token": "<|endoftext|>",
|
| 5 |
+
"is_local": true,
|
| 6 |
+
"model_max_length": 1024,
|
| 7 |
+
"pad_token": "<|padding|>",
|
| 8 |
+
"tokenizer_class": "TokenizersBackend",
|
| 9 |
+
"unk_token": null
|
| 10 |
+
}
|