TSjB commited on
Commit
08b4ae5
·
verified ·
1 Parent(s): 70fa1fa

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +150 -0
README.md ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: TSjB/QM-4B
3
+ library_name: transformers
4
+ model_name: QM-4B-AWQ
5
+ tags:
6
+ - qarachay-malqar
7
+ - caucasian-languages
8
+ - turkic-languages
9
+ - karachay-balkar
10
+ - multilingual
11
+ - trl
12
+ - sft
13
+ - unsloth
14
+ language:
15
+ - krc
16
+ - ru
17
+ - en
18
+ license: cc-by-nc-sa-4.0
19
+ ---
20
+
21
+ # QM-4B-AWQ: with Qarachay-Malqar Language
22
+
23
+ A quantized model based on TSjB/QM-4B.
24
+
25
+ ## Description
26
+
27
+ QM-4B-AWQ is a language model with an extended tokenizer and fine-tuning for Qarachay-Malqar language support (къарачай-малкъар тил).
28
+
29
+ ### Training Stages:
30
+
31
+ 1. **Tokenizer expansion** — added tokens for Qarachay-Malqar: replacement from 150k to 130k tokens (tokenizer trained in Qarachay-Malqar (76.5%), English (11.5%), Russian (11.5%) and Circassian (5%)) (the number of symbols/tokens has been increased in Qarachay-Malqar compared to the original tokenizer: 1.78 -> 5.38)
32
+ 2. **Embeddings-only Training** — training only embedding layers (3 epochs, LR=2e-4)
33
+ 3. **Full Fine-Tune** — full fine-tuning of all model layers (1 epoch, LR=5e-6)
34
+
35
+ ## Training Metrics
36
+
37
+ | Stage | Train Loss | Eval Loss | Parameters |
38
+ |-------|------------|-----------|------------|
39
+ | Embeddings-only | 4.27 | 4.49 | 8.4% (332M) |
40
+ | Full FT (1 epoch) | 4.16 | 4.36 | 100% (3.97B) |
41
+
42
+ ## Usage
43
+
44
+ ```python
45
+ from transformers import AutoModelForCausalLM, AutoTokenizer
46
+ import torch
47
+
48
+ model = AutoModelForCausalLM.from_pretrained(
49
+ "TSjB/QM-4B-AWQ",
50
+ dtype=torch.bfloat16,
51
+ device_map="auto",
52
+ trust_remote_code=True
53
+ )
54
+
55
+ tokenizer = AutoTokenizer.from_pretrained(
56
+ "TSjB/QM-4B-AWQ",
57
+ trust_remote_code=True
58
+ )
59
+
60
+ # With chat template
61
+ messages = [
62
+ {"role": "system", "content": "Сен къарачай-малкъар тилде болушлукъчуса. Соруўлагъа къысха, тюз эм ачыкъ джуўабла бер. Орусча неда ингилизче сорсала — ол тилде джуўаб бер."},
63
+ {"role": "user", "content": "Не зат билесе Къарачай юсюнден?"}
64
+ ]
65
+ text = tokenizer.apply_chat_template(
66
+ messages,
67
+ tokenize=False,
68
+ add_generation_prompt=True,
69
+ enable_thinking=False
70
+ )
71
+
72
+ inputs = tokenizer(text, return_tensors="pt").to(model.device)
73
+
74
+ if 'token_type_ids' in inputs:
75
+ inputs.pop('token_type_ids')
76
+
77
+ outputs = model.generate(
78
+ **inputs,
79
+ max_new_tokens=100,
80
+ temperature=0.7,
81
+ top_p=0.9,
82
+ do_sample=True,
83
+ repetition_penalty=1.2,
84
+ no_repeat_ngram_size=4,
85
+ pad_token_id=tokenizer.pad_token_id,
86
+ eos_token_id=tokenizer.eos_token_id,
87
+ )
88
+
89
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
90
+ ```
91
+
92
+ ## Recommended Generation Parameters
93
+
94
+ ```python
95
+ generation_config = {
96
+ "max_new_tokens": 200,
97
+ "temperature": 0.7,
98
+ "top_p": 0.9,
99
+ "do_sample": True,
100
+ "repetition_penalty": 1.2, # important to avoid repetitions
101
+ "no_repeat_ngram_size": 3, # optional
102
+ }
103
+ ```
104
+
105
+ ## Supported Languages
106
+
107
+ - Qarachay-Malqar (къарачай-малкъар тил)
108
+ - Russian
109
+ - English
110
+ - Other languages from the base Qwen3 model
111
+
112
+ ## Limitations
113
+
114
+ - The model was fine-tuned on text data (continued pretraining), not on dialogues
115
+ - May switch between languages within a single response
116
+ - Additional instruction tuning is recommended for better instruction following
117
+
118
+ ## Training Data
119
+
120
+ The model was trained on a multilingual text corpus including:
121
+ - Qarachay-Malqar texts
122
+ - Russian texts
123
+ - English texts
124
+
125
+ ## License
126
+
127
+ cc-by-nc-sa-4.0
128
+
129
+ ## Citation
130
+
131
+ ```bibtex
132
+ @misc{qm4bawq202+,
133
+ title={QM-4B-AWQ: Qarachay-Malqar language support},
134
+ author={TSjB},
135
+ year={2026},
136
+ publisher={HuggingFace},
137
+ url={https://huggingface.co/TSjB/QM-4B}
138
+ }
139
+ ```
140
+
141
+ ## Framework Versions
142
+
143
+ - TRL: 0.24.0
144
+ - Transformers: 4.57.3
145
+ - Pytorch: 2.9.0
146
+ - Unsloth: optimized training
147
+
148
+
149
+ ## Authors
150
+ [Bogdan Tewunalany](https://t.me/bogdan_tewunalany), [Ali Berberov](https://t.me/ali_berberov)