Text Generation
Transformers
Safetensors
Karachay-Balkar
Russian
English
qwen3
qarachay-malqar
caucasian-languages
turkic-languages
karachay-balkar
multilingual
trl
sft
unsloth
conversational
text-generation-inference
compressed-tensors
Instructions to use TSjB/QM-4B-AWQ with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use TSjB/QM-4B-AWQ with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="TSjB/QM-4B-AWQ") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("TSjB/QM-4B-AWQ") model = AutoModelForCausalLM.from_pretrained("TSjB/QM-4B-AWQ", device_map="auto") 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 TSjB/QM-4B-AWQ with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "TSjB/QM-4B-AWQ" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TSjB/QM-4B-AWQ", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/TSjB/QM-4B-AWQ
- SGLang
How to use TSjB/QM-4B-AWQ 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 "TSjB/QM-4B-AWQ" \ --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": "TSjB/QM-4B-AWQ", "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 "TSjB/QM-4B-AWQ" \ --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": "TSjB/QM-4B-AWQ", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use TSjB/QM-4B-AWQ with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for TSjB/QM-4B-AWQ to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for TSjB/QM-4B-AWQ to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for TSjB/QM-4B-AWQ to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="TSjB/QM-4B-AWQ", max_seq_length=2048, ) - Docker Model Runner
How to use TSjB/QM-4B-AWQ with Docker Model Runner:
docker model run hf.co/TSjB/QM-4B-AWQ
Create README.md
Browse files
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)
|