|
|
--- |
|
|
license: cc-by-4.0 |
|
|
language: |
|
|
- tr |
|
|
- en |
|
|
datasets: |
|
|
- berhaan/Turkish-CodeAlpaca-20k |
|
|
base_model: vngrs-ai/Kumru-2B-Base |
|
|
pipeline_tag: text-generation |
|
|
tags: |
|
|
- kumru |
|
|
- mistral |
|
|
- code-generation |
|
|
- turkish |
|
|
- qlora |
|
|
library_name: transformers |
|
|
--- |
|
|
|
|
|
# 🦜 Kumru-2B-CodeAlpaca (Turkish Code Generation Model) |
|
|
|
|
|
## Model Summary |
|
|
**Kumru-2B-CodeAlpaca**, Türkçe kod üretimi görevleri için fine-tune edilmiş bir dil modelidir. |
|
|
Model, **vngrs-ai/Kumru-2B-Base** tabanlı olup **Turkish-CodeAlpaca-20k** veri kümesiyle |
|
|
**QLoRA** yöntemi (4-bit LoRA adaptasyonu) kullanılarak eğitilmiştir. |
|
|
|
|
|
Model, Türkçe komutlardan Python, SQL, HTML, PHP ve C gibi dillere kod üretebilir. |
|
|
|
|
|
--- |
|
|
|
|
|
## 🧠 Model Details |
|
|
| Özellik | Değer | |
|
|
|----------|--------| |
|
|
| **Base Model** | [vngrs-ai/Kumru-2B-Base](https://huggingface.co/vngrs-ai/Kumru-2B-Base) | |
|
|
| **Fine-tune Dataset** | [berhaan/Turkish-CodeAlpaca-20k](https://huggingface.co/datasets/berhaan/Turkish-CodeAlpaca-20k) | |
|
|
| **Parameters** | ≈ 2B | |
|
|
| **Method** | QLoRA (4-bit, NF4 quantization) | |
|
|
| **Framework** | 🤗 Transformers + TRL + PEFT | |
|
|
| **Language** | Turkish (primary), English (secondary code syntax) | |
|
|
| **License** | CC-BY-4.0 | |
|
|
| **Author** | [@berhaan](https://huggingface.co/berhaan) | |
|
|
|
|
|
--- |
|
|
|
|
|
## ⚙️ Training Configuration |
|
|
| Parametre | Değer | |
|
|
|------------|--------| |
|
|
| **Hardware** | NVIDIA A100 40GB | |
|
|
| **Batch Size** | 8 × 2 (gradient accumulation) | |
|
|
| **Sequence Length** | 512 | |
|
|
| **Learning Rate** | 2e-4 | |
|
|
| **Epochs** | 3 | |
|
|
| **Optimizer** | paged_adamw_8bit | |
|
|
| **Precision** | bfloat16 | |
|
|
| **LoRA Config** | r=16, α=32, dropout=0.05 | |
|
|
|
|
|
--- |
|
|
|
|
|
## 📊 Evaluation Results |
|
|
(expected +30–50%) |
|
|
|
|
|
> Fine-tuned model, Türkçe kodlama görevlerinde taban modele göre belirgin gelişme göstermiştir. |
|
|
> Özellikle Python ve SQL örneklerinde daha kısa ve doğru fonksiyonlar üretmektedir. |
|
|
|
|
|
--- |
|
|
|
|
|
## 💻 Usage Example |
|
|
|
|
|
```python |
|
|
from transformers import AutoTokenizer, AutoModelForCausalLM |
|
|
import torch |
|
|
|
|
|
model_id = "berhaan/kumru-2b-codealpaca" |
|
|
tokenizer = AutoTokenizer.from_pretrained(model_id) |
|
|
model = AutoModelForCausalLM.from_pretrained( |
|
|
model_id, |
|
|
torch_dtype=torch.bfloat16, |
|
|
device_map="auto" |
|
|
) |
|
|
|
|
|
prompt = "Girilen sayının asal olup olmadığını kontrol eden bir Python fonksiyonu yaz. Yalnızca kodu döndür." |
|
|
|
|
|
inputs = tokenizer(prompt, return_tensors="pt", return_token_type_ids=False).to(model.device) |
|
|
|
|
|
outputs = model.generate( |
|
|
**inputs, |
|
|
max_new_tokens=128, |
|
|
repetition_penalty=1.15, |
|
|
no_repeat_ngram_size=5, |
|
|
do_sample=False, # Tutarlı (asal sayı) çıktısı almak için |
|
|
eos_token_id=tokenizer.eos_token_id, |
|
|
pad_token_id=tokenizer.pad_token_id |
|
|
) |
|
|
output_text = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True) |
|
|
print("--- ÜRETİLEN KOD ---") |
|
|
print(output_text.strip()) |
|
|
``` |
|
|
""" |
|
|
|
|
|
--- ÜRETİLEN KOD --- |
|
|
# Asal sayı kontrolü |
|
|
def is_prime(num): |
|
|
if num < 2: |
|
|
return False |
|
|
for i in range(2, int(num**0.5) + 1): |
|
|
if num % i == 0: |
|
|
return False |
|
|
return True |
|
|
""" |
|
|
## ⚖️ Limitations & Biases |
|
|
Kumru-2B-CodeAlpaca, Türkçe kod üretiminde oldukça başarılı olsa da aşağıdaki sınırlamalara dikkat edilmelidir: |
|
|
|
|
|
- **Dil Uyumu:** Model, yalnızca Türkçe açıklama ve talimatlar üzerinde eğitildiği için İngilizce promptlarda performansı düşebilir. |
|
|
- **Kod Tutarlılığı:** Uzun veya çok adımlı algoritmalarda bazen gereksiz tekrarlar veya fazladan çıktılar üretebilir. |
|
|
- **Çıktı Güvenliği:** Üretilen kodlar doğrudan çalıştırılmadan önce mutlaka gözden geçirilmelidir; çünkü mantıksal veya sözdizimsel hatalar oluşabilir. |
|
|
- **Yaratıcılık – Doğruluk Dengesi:** `temperature` parametresi yükseltildiğinde yaratıcı ama hatalı kodlar üretebilir. |
|
|
|
|
|
Model, profesyonel geliştiriciler için yardımcı araç olarak kullanılmalı, doğrudan üretim ortamlarında denetimsiz kullanılmamalıdır. |
|
|
|
|
|
--- |
|
|
|
|
|
## 🌱 Environmental Impact |
|
|
| Özellik | Değer | |
|
|
|----------|--------| |
|
|
| **GPU** | NVIDIA A100 (40 GB) | |
|
|
| **Training Süresi** | ~1.5 saat | |
|
|
|
|
|
Eğitim süreci sırasında enerji verimliliği için karma hassasiyet (bfloat16) ve 4-bit quantization kullanılmıştır. |
|
|
|
|
|
--- |
|
|
|
|
|
## 📚 Citation |
|
|
|
|
|
**APA:** |
|
|
> Berhan A. (2025). *Kumru-2B-CodeAlpaca: A Turkish Instruction-Tuned Code Generation Model*. Hugging Face. https://huggingface.co/berhaan/kumru-2b-codealpaca |
|
|
|
|
|
**BibTeX:** |
|
|
```bibtex |
|
|
@misc{berhaan2025kumru2bcodealpaca, |
|
|
author = {Berhan, A.}, |
|
|
title = {Kumru-2B-CodeAlpaca: A Turkish Instruction-Tuned Code Generation Model}, |
|
|
year = {2025}, |
|
|
howpublished = {\url{[https://huggingface.co/berhaan/kumru-2b-codealpaca](https://huggingface.co/berhaan/kumru-2b-codealpaca)}}, |
|
|
} |