sixfingerdev's picture
Add English version of model card before Turkish
3e02e98 verified
|
Raw
History Blame Contribute Delete
10.1 kB
---
language:
- tr
license: mit
library_name: transformers
pipeline_tag: text-generation
tags:
- turkish
- chain-of-thought
- reasoning
- thinking
- cot
- fine-tuned
- experimental
- kayra
datasets:
- sixfingerdev/kayra-thinking-data
base_model: sixfingerdev/kayra-1-exp
---
# 🧠 Kayra-1-Thinking-Exp
**A thinking Turkish language model — Chain-of-Thought reasoning fine-tune of Kayra-1-exp**
This is an experimental fine-tune of [sixfingerdev/kayra-1-exp](https://huggingface.co/sixfingerdev/kayra-1-exp) (86.4M parameters) on a **chain-of-thought reasoning** dataset. It learns to produce step-by-step reasoning within `<|think|>` tags before generating the final answer.
### Model Details
| Property | Value |
|----------|-------|
| **Base Model** | [sixfingerdev/kayra-1-exp](https://huggingface.co/sixfingerdev/kayra-1-exp) |
| **Parameters** | ~86.4M (106.8M with copied tied embeddings) |
| **Architecture** | Transformer Decoder (GPT-style), 10 layers, 640 hidden, 10 heads |
| **Context Length** | 512 tokens |
| **Vocabulary** | 32,000 BPE tokens |
| **Training Data** | [kayra-thinking-data](https://huggingface.co/datasets/sixfingerdev/kayra-thinking-data) (4,191 Turkish reasoning examples) |
| **Version** | Experimental (exp) |
### Training
| Hyperparameter | Value |
|----------------|-------|
| Epochs | 5 |
| Batch Size | 8 (per device) |
| Learning Rate | 5e-5 |
| Scheduler | Cosine (20 steps warmup) |
| Optimizer | AdamW |
| Precision | FP16 |
| Train / Eval Split | 95% / 5% (3,981 / 210) |
| Total Steps | 2,490 |
Eval loss decreased from 2.73 → **2.25** over 5 epochs.
### Dataset
Trained on [kayra-thinking-data](https://huggingface.co/datasets/sixfingerdev/kayra-thinking-data): a curated collection of 4,191 Turkish reasoning examples combining 4 sources — duxx (226), efe (350), Gemma-4 generated (32), and ThinkingData-200K-Turkish (~3,583).
Format:
```text
### Soru: <question>
### Yanit: <|think|><step-by-step reasoning></|think|><final answer>
```
### Usage
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained(
"sixfingerdev/kayra-1-thinking-exp",
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained("sixfingerdev/kayra-1-thinking-exp")
prompt = "### Soru: Türkiye'nin başkenti neresidir?\n\n### Yanit: <|think|>"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(
**inputs,
max_new_tokens=120,
do_sample=True,
temperature=0.3,
top_k=40,
repetition_penalty=1.2,
pad_token_id=tokenizer.pad_token_id,
)
```
Recommended generation parameters: `temperature=0.3`, `top_k=40`, `repetition_penalty=1.2`, `max_new_tokens=100-150`.
### Known Limitations
1. **Model capacity**: 86M parameters is too small for reliable complex reasoning. The model learns the *format* of thinking but struggles with *correct logical inference*.
2. **Function-call contamination**: The ThinkingData-200K source contains tool/API call examples. The model may occasionally generate function-call syntax (`get_name_by_id`, `tool_call`).
3. **Repetition**: Like most small models, it can enter repetitive loops. Use `repetition_penalty` to mitigate.
4. **Tokenizer spacing**: BPE subword tokenization can introduce spaces in Turkish words ("soruyor" → "sor uyor", "düşüneyim" → "düşün eyim").
5. **No factuality guarantee**: This is an experimental model. Do not use in production without verification.
---
# 🧠 Kayra-1-Thinking-Exp (Türkçe)
**Düşünen Türkçe model — Chain-of-Thought reasoning fine-tune of Kayra-1-exp**
Bu model, `sixfingerdev/kayra-1-exp` (86.4M parametre) üzerine **chain-of-thought reasoning** formatında fine-tune edilmiş deneysel bir sürümdür. `<|think|>` etiketleri arasında adım adım muhakeme yapıp ardından nihai cevabı üretmeyi öğrenir.
---
## 📊 Model Details
| Özellik | Değer |
|---------|-------|
| **Base Model** | [sixfingerdev/kayra-1-exp](https://huggingface.co/sixfingerdev/kayra-1-exp) |
| **Parametreler** | ~86.4M (106.8M with tied embeddings copied) |
| **Mimari** | Transformer Decoder (GPT-style), 10 katman, 640 hidden, 10 heads |
| **Context Length** | 512 token |
| **Vocabulary** | 32,000 BPE token |
| **Eğitim Verisi** | [kayra-thinking-data](https://huggingface.co/datasets/sixfingerdev/kayra-thinking-data) (4,191 Türkçe reasoning örneği) |
| **Sürüm** | Experimental (exp) |
---
## 📈 Training Details
### Hyperparameters
| Parametre | Değer |
|-----------|-------|
| Epochs | 5 |
| Batch Size | 8 (per device) |
| Learning Rate | 5e-5 |
| Scheduler | Cosine (20 step warmup) |
| Optimizer | AdamW |
| Precision | FP16 |
| Train / Eval Split | 95% / 5% (3,981 / 210) |
| Total Steps | 2,490 |
### Training Metrics
| Step | Train Loss | Eval Loss |
|------|-----------|-----------|
| 200 | 4.26 | 2.73 |
| 400 | 3.87 | 2.54 |
| 600 | 3.72 | 2.45 |
| 800 | 3.60 | 2.38 |
| 1000 | 3.43 | 2.33 |
| 1200 | 3.28 | 2.30 |
| 1400 | 3.18 | 2.28 |
| 1600 | 3.04 | 2.27 |
| 1800 | 2.93 | 2.26 |
| 2000 | 2.83 | 2.25 |
| 2200 | 2.65 | 2.25 |
| 2400 | 2.60 | **2.248** |
| 2490 | 2.56 | 2.248 |
Loss monotonik olarak düştü, eval loss 2.25'te plateu yaptı. Daha fazla epoch overfitting riski taşır.
### Weight Tying Fix
Kayra-1-exp'in checkpoint'ında `lm_head.weight` bulunmaz (`tie_word_embeddings=True`). Eğitim öncesi `lm_head.weight.data.copy_(model.tok_emb.weight.data)` ile embedding ağırlıkları kopyalanır. Transformers 5.x'te `tie_word_embeddings=False` ile kaydedilir, böylece checkpoint save hatası önlenir.
---
## 📦 Dataset
Fine-tune verisi: **[kayra-thinking-data](https://huggingface.co/datasets/sixfingerdev/kayra-thinking-data)**
4 kaynaktan derlenmiş, dedupe edilmiş 4,191 Türkçe reasoning örneği:
| Kaynak | Adet | Açıklama |
|--------|------|----------|
| duxx | 226 | Türkçe matematik problemleri + CoT çözüm |
| efe | 350 | Türkçe matematik reasoning |
| Gemma-4 (E2B-it) | 32 | Gemma ile üretilip Türkçeleştirilmiş |
| ThinkingData-200K-Turkish | ~3,583 | İngilizce ThinkingData-200K'nın Türkçe çevirisi |
Her örnek şu formattadır:
```text
### Soru: <soru>
### Yanit: <|think|><adım adım muhakeme></|think|><nihai cevap>
```
---
## 🚀 Usage
### Yükleme
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained(
"sixfingerdev/kayra-1-thinking-exp",
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained("sixfingerdev/kayra-1-thinking-exp")
```
### Generate
```python
prompt = "### Soru: Türkiye'nin başkenti neresidir?\n\n### Yanit: <|think|>"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(
**inputs,
max_new_tokens=120,
do_sample=True,
temperature=0.3,
top_k=40,
repetition_penalty=1.2,
pad_token_id=tokenizer.pad_token_id,
)
generated = outputs[0][inputs.input_ids.shape[1]:]
print(tokenizer.decode(generated, skip_special_tokens=False))
```
**Önerilen generation parametreleri:**
- `temperature`: 0.3-0.4 (düşük = daha deterministik)
- `top_k`: 40
- `repetition_penalty`: 1.15-1.25 (tekrarlamayı azaltır)
- `max_new_tokens`: 100-150 (512 context sınırı)
- `do_sample`: True
### Output Format
Model çıktısı şu pattern'i takip eder:
```
<|think|>Öncelikle, <adım 1>. Sonra, <adım 2>. ... </|think|><nihai cevap>
```
Not: Model bazen `</|think|>` kapatma etiketi üretmez. Bu durumda tüm çıktı thinking aşaması olarak kabul edilmelidir.
---
## ⚠️ Limitations & Known Issues
### 1. Model Kapasitesi
86M parametre karmaşık muhakeme için çok küçüktür. Model **muhakeme formatını** öğrenir ancak **doğru mantıksal çıkarımı** tutarlı şekilde yapamaz.
### 2. Function-Call Contamination
ThinkingData-200K verisi tool/API çağrısı formatında örnekler içerir. Model bazen `get_name_by_id`, `tool_call` gibi fonksiyon çağrısı syntax'ı üretebilir.
### 3. Tekrarlama (Repetition)
Küçük modellerde yaygın olduğu gibi, model uzun generation'larda tekrara girebilir. `repetition_penalty` ve `no_repeat_ngram_size` ile kontrol edilebilir.
### 4. Tokenizer Spacing
BPE tokenizer bazı kelimelerde boşluk ekler ("soruyor" → "sor uyor", "düşüneyim" → "düşün eyim"). Bu, tokenizer'ın alt kelime bölümlemesinden kaynaklanır ve model çıktısında görülebilir.
### 5. Doğruluk Garantisi Yok
Bu deneysel bir modeldir. Ürettiği bilgilerin doğruluğu garanti edilmez. Production kullanımı için uygun değildir.
---
## 🧪 Sample Outputs
### Türkiye'nin başkenti neresidir?
```
Tamam, kullanıcı Türkiye'nin başkentini soruyor. Türkiye'nin başkenti nedir ve nerede olduğunu bilmek istiyorlar. Kullanılabilir işlevleri kontrol edeyim...
```
→ Doğru yanıtı üretmekte zorlanır, function-call pattern'ine kayar.
### 2+2 kaç eder?
```
Doğrudan sonuca atlamadan önce verilenleri düzenli okuyorum. İlk olarak, ikinci veya üçüncü şahıs zamirlerinden kaçınmam gerekiyor...
```
→ </|think|> kapatır ama matematiksel doğruluk zayıftır.
---
## 🔬 Comparison: Base vs Fine-tuned
| Özellik | kayra-1-exp (base) | kayra-1-thinking-exp |
|---------|-------------------|---------------------|
| Loss | 3.75 (base eval) | 2.25 (fine-tune eval) |
| Reasoning Format | Yok | `<|think|>` CoT formatı |
| Yanıt Yapısı | Serbest metin | Soru → Düşünce → Cevap |
| Doğruluk | Düşük (85M hallücinasyon) | Düşük (kapasite sınırı) |
---
## 📜 License
MIT License — Ticari ve akademik kullanım serbesttir.
---
## 🙏 Acknowledgments
- **Base model**: [sixfingerdev/kayra-1-exp](https://huggingface.co/sixfingerdev/kayra-1-exp) — Sıfırdan Türkçe eğitilmiş GPT
- **Dataset**: [kayra-thinking-data](https://huggingface.co/datasets/sixfingerdev/kayra-thinking-data)
- **Framework**: PyTorch, HuggingFace Transformers
- **Inspired by**: DeepSeek-R1, ThinkingData-200K
---
**Kayra-1-Thinking-Exp***Küçük modeller de düşünebilir* 🧠