File size: 6,533 Bytes
f0b10bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52998a8
f0b10bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52998a8
f0b10bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
---
license: mit
language:
- tr
base_model:
- meta-llama/Llama-3.1-8B
pipeline_tag: question-answering
library_name: adapter-transformers
tags:
- education
- turkish
- chatbot
- asistant
---
# Llama3.1 Turkish Educational ChatBot

[EN]

## About the Project

This project is a fine-tuned version of the **Meta LLaMA 3.1 8B** large language model, specifically adapted to respond to **Turkish educational question-answer** prompts. The main goal is to deliver fluent, informative, and context-aware answers in Turkish, suitable for general inquiry and learning support.

The model was fine-tuned using the **LoRA** technique on a small scale (1% of trainable parameters) and published on Hugging Face:

🔗 [metehanayhan/Llama3-1_Turkish_ChatBot](https://huggingface.co/metehanayhan/Llama3-1_Turkish_ChatBot)

---

## Training Summary

| Feature | Value |
| --- | --- |
| Base Model | Meta LLaMA 3.1 8B |
| Fine-Tuning Method | Supervised Fine-Tuning (SFT) |
| LoRA Usage | Yes (%1 of model trained) |
| Training Data | Turkish question–answer pairs |
| Number of Training Samples | 17,587 |
| Epochs | 1 |
| Total Training Steps | 2,199 |
| Learning Rate | 2e-5 |
| Total Batch Size | 8 |
| Training Duration (approx.) | ~3 hours |
| Trainable Parameters | 83M / 8B (1.05%) |
| Quantization | 4-bit |

---

## Data Format

The dataset consists of Turkish question–answer pairs provided in CSV format. Each row represents a complete educational sample.

Example:

```
question,answer
What can be done to prevent climate change?,
"To combat climate change, actions like reducing fossil fuel usage and transitioning to renewable energy sources are essential..."
```

A total of 17,587 such examples were used for fine-tuning.

---

## Use Case

This model is intended to serve as an educational assistant in Turkish. It can answer questions related to:

- Informative, general-knowledge, or school-related topics
- Support for curious learners and students

---

## Quick Start

```python
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline

tokenizer = AutoTokenizer.from_pretrained("metehanayhan/Llama3-1_Turkish_ChatBot")
model = AutoModelForCausalLM.from_pretrained("metehanayhan/Llama3-1_Turkish_ChatBot")

qa_pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
print(qa_pipe("İklim değişikliği neden önemlidir?", max_new_tokens=200)[0]["generated_text"])
```

---

## Performance Notes

The model performs well on Turkish QA-style prompts that resemble the training distribution:

- 🔸 Fluent and natural Turkish sentence construction
- 🔸 Answers are contextually aligned with the prompt

The model shows strong generalization, even with limited training, due to the LoRA technique and high-quality data.

<p align="center">
  <img src="image.png" width="600"/>
</p>


---

## Deployment

The model is shared on Hugging Face with 4-bit quantization and is ready for low-resource inference. It has also been exported in GGUF format for use in compatible environments.

---

## Additional Notes

- The training was performed using `Trainer` with standard SFT configuration.
- `random_state = 3407` was used to ensure reproducibility.
- Although fine-tuned on just 1% of parameters, the model responds effectively across a wide range of Turkish topics.

---

[TR]

# Llama3.1 Türkçe Eğitim Odaklı ChatBot

## Proje Hakkında

Bu model, **Meta LLaMA 3.1 8B** tabanlı büyük bir dil modelidir ve Türkçe dilinde, eğitim odaklı **soru-cevap (QA)** verisiyle fine-tune edilmiştir. Amaç, kullanıcıların bilgi arayışına doğal, akıcı ve anlamlı yanıtlar sunabilen bir yardımcı oluşturmaktır.

Model, %1 oranında LoRA yöntemiyle optimize edilmiş ve Hugging Face platformuna aktarılmıştır:

🔗 [metehanayhan/Llama3-1_Turkish_ChatBot](https://huggingface.co/metehanayhan/Llama3-1_Turkish_ChatBot)

---

## Eğitim Özeti

| Özellik | Değer |
| --- | --- |
| Temel Model | Meta LLaMA 3.1 8B |
| Eğitim Yöntemi | Supervised Fine-Tuning (SFT) |
| İnce Ayar Tekniği | LoRA |
| Eğitim Verisi | Türkçe Eğitim Q/A |
| Eğitim Örneği Sayısı | 17,587 |
| Eğitim Epoch’u | 1 |
| Toplam Eğitim Adımı (steps) | 2,199 |
| Öğrenme Oranı | 2e-5 |
| Toplam Batch Size | 8 |
| Eğitim Süresi (yaklaşık) | 3 saat |
| Eğitilen Parametre Oranı | %1 (83M / 8B) |
| Quantization | 4-bit |

---

## Veri Formatı

Veri kümesi, her satırı bir soru-cevap çifti olan Türkçe bir CSV dosyasından oluşmaktadır. Örnek:

```
soru,cevap
İklim değişikliğine karşı neler yapılabilir?,
"İklim değişikliğiyle mücadele için fosil yakıt kullanımının azaltılması, yenilenebilir enerjiye geçiş gibi önlemler alınabilir..."
```

Toplam 17,587 satır veriyle eğitim gerçekleştirilmiştir.

---

## Amaç ve Kullanım Alanı

Model, aşağıdaki türde sorulara doğal dilde bilgi sunmak amacıyla geliştirilmiştir:

- Açıklayıcı, öğretici, genel kültür soruları
- Öğrencilerin veya meraklı bireylerin bilgi edinme taleplerine destek
- Cevap üretimi sırasında özgün, tutarlı ve doğal Türkçe dil kullanımı

---

## Hızlı Başlangıç

```python
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline

tokenizer = AutoTokenizer.from_pretrained("metehanayhan/Llama3-1_Turkish_ChatBot")
model = AutoModelForCausalLM.from_pretrained("metehanayhan/Llama3-1_Turkish_ChatBot")

qa_pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
print(qa_pipe("İklim değişikliği neden önemlidir?", max_new_tokens=1024)[0]["generated_text"])
```

---

## Performans

Model, eğitim verisine benzer sorularda oldukça doğal, akıcı ve içerik açısından doyurucu cevaplar üretmektedir. LoRA yöntemi sayesinde düşük hesaplama kaynağı ile etkili bir öğrenme gerçekleştirilmiştir. Eğitim sırasında gözlemlenen bazı bulgular:

- 🔸 Cevaplar Türkçe dil yapısına uygun
- 🔸 Soruyla bağlamsal olarak ilişkili

<p align="center">
  <img src="image.png" width="600"/>
</p>


---

## Yayınlama

Model, Hugging Face üzerinde quantize edilmiş biçimde (4-bit) paylaşılmıştır ve inference için kullanıma hazırdır. GGUF biçimiyle de dışa aktarılmıştır.

---

## Notlar

- Eğitim random_state=3407 ile tekrarlanabilirlik için sabitlenmiştir.
- Eğitim süreci `Trainer` altyapısıyla gerçekleştirilmiş ve standart veri ön işleme yapılmıştır.
- Model, küçük eğitimle geniş bilgi alanlarında doğal cevaplar üretme yeteneğine sahiptir.

---