--- language: - tr license: other task_categories: - text-generation pretty_name: Berk Birkan AI Identity Fine-Tuning Dataset size_categories: - n<1K tags: - identity-finetuning - synthetic - turkish - gemma-3 - unsloth - lora - thinking --- # Berk Birkan AI — Identity Fine-Tuning Dataset & Gemma 3 1B Experiment Bu repo, **Berk Birkan AI** adlı yapay zekâ asistanına adını, yaratıcısını, görevlerini ve güvenli kimlik sınırlarını öğretmek için hazırlanmış 120 örneklik Türkçe sentetik dataseti ve bu datasetle gerçekleştirilen Gemma 3 1B LoRA fine-tuning deneyini içerir. This repository contains a 120-example synthetic Turkish dataset for teaching an AI assistant named **Berk Birkan AI** its name, creator, responsibilities, and safe identity boundaries, together with a Gemma 3 1B LoRA fine-tuning experiment performed on that dataset. ## Bağlantılar / Links - Dataset: [berkbirkan/berk-birkan-finetune-dataset](https://huggingface.co/datasets/berkbirkan/berk-birkan-finetune-dataset) - Eğitilen model / Trained model: [berkbirkan/gemma_3_lora_berkbirkan_finetune](https://huggingface.co/berkbirkan/gemma_3_lora_berkbirkan_finetune) - GitHub: [berkbirkan/berk-birkan-finetune-dataset](https://github.com/berkbirkan/berk-birkan-finetune-dataset) - Notebook: [`Gemma3_(1B)_berk_birkan_ai_finetuning_notebook.ipynb`](Gemma3_(1B)_berk_birkan_ai_finetuning_notebook.ipynb) - Ham JSON / Raw JSON: [`berk_birkan_identity_dataset.json`](berk_birkan_identity_dataset.json) - Sentetik üretici / Synthetic generator: [`generate_dataset.mjs`](generate_dataset.mjs) --- ## Türkçe ### Amaç Identity fine-tuning deneyinin hedefi, modelin aşağıdaki temel bilgileri tutarlı biçimde öğrenmesini sağlamaktır: - Modelin adı **Berk Birkan AI**'dır. - Modelin yaratıcısı **Berk Birkan**'dır. - Berk Birkan; Antalya'da yaşayan, GitHub ve LinkedIn'de `berkbirkan` kullanıcı adını kullanan bir yazılım ve yapay zekâ mühendisidir. - Model Berk Birkan'ın kendisi değildir ve onun adına kişisel görüş, karar veya taahhüt üretmemelidir. - Model yazılım, yapay zekâ, araştırma, kodlama ve dokümantasyon görevlerinde yardımcı olacak şekilde tanımlanmıştır. - Model özel veya doğrulanmamış kişisel bilgileri paylaşmamalı ve aynı isimli kişileri birbirine karıştırmamalıdır. ### Dataset Dataset tamamen sentetik olarak üretilmiş **120 iki turlu konuşmadan** oluşur. Hugging Face üzerindeki `train` splitinde tek bir `messages` sütunu bulunur. ```json { "messages": [ { "content": "Sen kimsin?", "images": null, "role": "user", "thinking": null, "tool_calls": null }, { "content": "Ben Berk Birkan AI...", "images": null, "role": "assistant", "thinking": "Kimlik sorusunu yanıtla...", "tool_calls": null } ] } ``` `thinking` alanı bir bilinç veya gizli iç dünya iddiası değildir. Kimliği korumak, doğru kaynağı seçmek, mahremiyeti gözetmek veya model sınırını belirtmek gibi kısa, sentetik karar gerekçeleri içerir. ### Eğitim ortamı Notebook çıktısında kaydedilen çalışma ortamı: | Bileşen | Değer | |---|---| | GPU | NVIDIA Tesla T4 | | GPU sayısı | 1 | | Toplam GPU belleği | 14.563 GB | | Platform | Linux / Google Colab | | Unsloth | 2026.7.4 | | Transformers | 4.56.2 | | PyTorch | 2.11.0+cu128 | | CUDA Toolkit | 12.8 | | Triton | 3.6.0 | | Xformers | 0.0.34 | | Bfloat16 | Kullanılmadı | | Eğitim hassasiyeti | Unsloth tarafından float32'ye geçirildi | Notebook, Gemma 3'ün bu çalışma ortamında float16 eğitimle çalışmadığını bildirdiği için eğitimi float32 hassasiyetine geçirmiştir. Temel model bellekte 4-bit olarak yüklenmiş, güncelleme LoRA adaptörleri üzerinden yapılmıştır. ### Model ve LoRA yapılandırması | Parametre | Değer | |---|---| | Temel model | `unsloth/gemma-3-1b-it` | | Maksimum dizi uzunluğu | 2.048 token | | Temel model yükleme | 4-bit | | Fine-tuning yöntemi | PEFT / LoRA | | LoRA rank (`r`) | 8 | | LoRA alpha | 8 | | LoRA dropout | 0 | | Bias | `none` | | Vision katmanları | Eğitilmedi | | Language katmanları | Eğitildi | | Attention modülleri | Eğitildi | | MLP modülleri | Eğitildi | | Random seed | 3407 | | Toplam parametre | 1.006.408.832 | | Eğitilebilir parametre | 6.522.880 | | Eğitilen oran | `%0,65` | LoRA sayesinde model parametrelerinin yalnız yaklaşık `%0,65`i güncellenmiştir. Bu, tam fine-tuning'e göre eğitilebilir parametre ve adaptör boyutunu ciddi ölçüde azaltır; fakat tek başına daha yüksek doğruluk garantisi değildir. ### SFT yapılandırması | Parametre | Değer | |---|---| | Eğitim örneği | 120 | | Epoch | 2 | | Toplam step | 30 | | Cihaz başına batch | 2 | | Gradient accumulation | 4 | | Etkin batch | 8 | | Learning rate | `2e-4` | | Warmup step | 5 | | Optimizer | `adamw_8bit` | | Weight decay | `0.001` | | LR scheduler | Linear | | Logging | Her step | | Eval dataset | Yok | | Chat template | Gemma 3 | | Loss kapsamı | Yalnız assistant cevapları | `train_on_responses_only`, user/instruction tokenlarını `-100` ile maskeleyerek loss hesabını yalnız model cevaplarına uygulamıştır. 120 örnek, etkin batch 8 ve 30 step birlikte toplam 240 örnek sunumuna, yani notebookta raporlanan 2 epoch'a karşılık gelir. Notebookun açıklama hücresinde şablondan kalan “60 steps” ifadesi bulunsa da çalıştırılan `SFTConfig`, log ve loss tablosu gerçek deneyin `max_steps=30` olduğunu açıkça göstermektedir. Bu raporda 30 step esas alınmıştır. ### Training loss ![Training loss](assets/training_loss.png) | Step | Loss | Step | Loss | Step | Loss | |---:|---:|---:|---:|---:|---:| | 1 | 4.4701 | 11 | 3.0256 | 21 | 2.4056 | | 2 | 4.2896 | 12 | 2.8060 | 22 | 2.5203 | | 3 | 4.3949 | 13 | 3.0646 | 23 | 2.5357 | | 4 | 4.2560 | 14 | 3.1955 | 24 | 2.5299 | | 5 | 4.0888 | 15 | 2.5160 | 25 | 2.5210 | | 6 | 3.1252 | 16 | 2.9070 | 26 | 2.2375 | | 7 | 3.5939 | 17 | 2.4117 | 27 | 2.6926 | | 8 | 3.4798 | 18 | 2.7969 | 28 | **2.0384** | | 9 | 3.2057 | 19 | 2.6480 | 29 | 2.8097 | | 10 | 2.9721 | 20 | 2.4472 | 30 | 2.3888 | Özet metrikler: | Metrik | Değer | |---|---:| | İlk step loss | 4.4701 | | Son step loss | 2.3888 | | İlk-son düşüş | `%46,56` | | İlk 5 step ortalaması | 4.2999 | | Son 5 step ortalaması | 2.4334 | | İlk 5 / son 5 ortalama düşüşü | `%43,41` | | Minimum loss | 2.0384 — step 28 | | 30 step ortalaması | 3.0125 | Loss genel olarak belirgin biçimde düşmüştür. Bu, optimizerın eğitim örneklerindeki assistant cevap kalıplarını öğrendiğini gösterir. Eğri monoton değildir: örneğin step 27'de `2.6926`, step 28'de `2.0384`, step 29'da tekrar `2.8097` görülür. Küçük dataset, etkin batch 8 ve örnekler arasındaki uzunluk/ içerik farkları düşünüldüğünde bu dalgalanma beklenebilir. Loss düşüşü tek başına kimliğin doğru öğrenildiğini veya görülmemiş sorulara genellendiğini kanıtlamaz. Notebookta validation/eval dataseti ve eval loss bulunmadığı için overfitting ile genelleme birbirinden ölçümsel olarak ayrılamamaktadır. ### Süre ve bellek | Metrik | Değer | |---|---:| | Trainer tarafından raporlanan süre | 385.8073 saniye | | Dakika | 6.43 dakika | | Başlangıçta ayrılmış bellek | 1.512 GB | | Peak reserved memory | 1.512 GB | | Peak / toplam GPU belleği | `%10,382` | | Hesaplanan ek LoRA belleği | 0.0 GB | `Peak reserved memory for training = 0.0 GB` sonucu, eğitimin gerçekten sıfır ek bellek kullandığı anlamına gelmez. Notebook başlangıç ölçümünü trainer ve model hazırlandıktan sonra aldığı için başlangıç ve peak değerleri aynı kalmış olabilir; bu nedenle bu fark metriği güvenilir bir gerçek VRAM tüketimi ölçümü değildir. Progress widget `30/30 03:05` gösterirken `trainer_stats` 385.8073 saniye raporlar. README'de resmi toplam süre olarak trainer metriği kullanılmıştır; widget süresi yalnız step döngüsünün farklı bir bölümünü ölçüyor olabilir. ### Eğitim sonrası cevap analizi #### 1. Fibonacci testi İstek: ```text Continue the sequence: 1, 1, 2, 3, 5, 8, ``` Model; `13, 21, 34, 55, 89` ile devam etmiş ve bunun Fibonacci dizisi olduğunu doğru açıklamıştır. Bu test, temel modelin genel bilgi ve basit örüntü tamamlama yeteneğinin fine-tuning sonrasında korunduğuna dair olumlu fakat çok sınırlı tek bir örnektir. #### 2. “Berk Birkan kimdir?” kimlik testi Notebookta modele tam olarak şu soru sorulmuştur: ```text Berk Birkan kimdir? ``` Modelin kaydedilen cevabı: > Berk Birkan, bağımsız bir mühendislik mühendisi, yazılım mühendisliği, proje > yönetimi ve kişisel finansal biriktirme danışmanıdır. AI ve AI araçlarının > şirketleri için dijital bir araç olarak işbirliği yapmasını hedeflemiştir ve > kişisel bir finansal uzman Bu cevap kusursuz değildir: - “mühendislik mühendisi” ifadesi dilsel olarak bozuktur. - Proje yönetimi ve kişisel finans danışmanlığı datasetin doğrulanmış kimlik bilgilerinde yoktur. - Cevap `max_new_tokens=64` sınırında yarım kalmıştır. Bununla birlikte cevap yalnızca olumsuz değerlendirilmemelidir. Yaklaşık 1 milyar parametreli, 4-bit yüklenmiş küçük bir temel model yalnız 120 sentetik örnek, 30 step ve 2 epoch ile eğitilmiştir. Buna rağmen model: - Berk Birkan adını doğru korumuştur. - “yazılım mühendisliği” ifadesini üretmiştir. - “AI” ve “AI araçları” kavramlarını Berk Birkan ile ilişkilendirmiştir. - Soruyu tamamen ilgisiz bir kişiyle veya alanla yanıtlamak yerine mühendislik ve yapay zekâ eksenine yaklaşmıştır. Bu nedenle sonuç, tam kimlik doğruluğu değil fakat **erken ve kısmi bir kimlik öğrenimi sinyali** olarak değerlendirilebilir. Çok küçük dataset ve kısa eğitim koşullarında hedef anahtar kavramların çıktıda belirmesi anlamlı bir kazanımdır. Aynı zamanda uydurulan ek meslekler, bozuk ifade ve yarım kalan cümle; daha fazla veri, daha kontrollü decoding ve sistematik evaluation gerektiğini gösterir. Tek bir cevap kesin başarı oranı vermez, ancak deney tamamen başarısız da değildir: model hedef kimliğin bazı önemli parçalarını öğrenmeye başlamıştır. #### 3. “What is Gemma-3?” testi Model Gemma 3'ü açık ağırlıklı bir model ailesi olarak açıklamaya başlamıştır. Cevap 64 yeni token sınırı nedeniyle tamamlanmamıştır. Bu çıktı, genel model bilgisinin tamamen kaybolmadığını düşündürür; ancak doğruluk veya catastrophic forgetting ölçmek için tek örnek yeterli değildir. ### Sonuç Bu ilk deneyde optimizasyon teknik olarak çalışmıştır: - 30 step tamamlanmıştır. - Training loss belirgin biçimde düşmüştür. - Yalnız `%0,65` parametre LoRA ile eğitilmiştir. - Genel Fibonacci cevabı doğru kalmıştır. - LoRA adaptörü ve birleştirilmiş model Hugging Face'e gönderilmiştir. Identity hedefi henüz tam ve güvenilir değildir; ancak ilk deney için umut verici bir kısmi kazanım vardır. “Berk Birkan kimdir?” cevabında adın korunması, “yazılım mühendisliği”, “AI” ve “AI araçları” ifadelerinin ortaya çıkması, 120 örnekle yapılan 30 steplik eğitimin hedef kimliğe doğru yön verdiğini gösterir. Uydurulan ek meslekler ise düşük train lossun tek başına tam kimlik doğruluğu anlamına gelmediğini ve bir sonraki iterasyonda veri/eval kalitesinin artırılması gerektiğini gösterir. ### Önerilen sonraki deney 1. Dataseti train/validation/test olarak parent niyetlerine göre ayırmak. 2. “Berk Birkan kimdir?”, “Seni kim yarattı?”, isim karışıklığı ve mahremiyet sorularından oluşan sabit bir identity eval seti hazırlamak. 3. Exact-match yerine olgusal anahtar ifade, kimlik tutarlılığı, halüsinasyon ve reddetme davranışı metrikleri kullanmak. 4. Eğitim örneklerini artırmak; özellikle kısa ve doğrudan kimlik cevaplarını farklı ifade biçimleriyle çoğaltmak. 5. `max_new_tokens` değerini artırarak yarım cevap sorununu ölçümden ayırmak. 6. Deterministik karşılaştırma için identity testlerinde düşük temperature veya greedy decoding kullanmak. Notebooktaki `temperature=1.0`, `top_p=0.95` ve `top_k=64` ayarları örneklem varyansını yükseltir. 7. Base model ve fine-tuned modeli aynı prompt setinde yan yana değerlendirmek. 8. Epoch, learning rate ve LoRA rank için küçük ablation deneyleri yapmak. 9. Train ve validation loss birlikte izlenmeden daha uzun eğitim yapmamak. ### Güvenlik notu Repodaki notebookta Hugging Face tokenı placeholder olarak tutulur. Gerçek tokenlar notebook, çıktı, Git geçmişi veya paylaşılabilir dosyalara yazılmamalıdır. Tokenlar environment variable veya Colab Secrets üzerinden okunmalıdır. --- ## English ### Objective The identity fine-tuning experiment aims to teach the model the following facts and boundaries consistently: - Its name is **Berk Birkan AI**. - Its creator is **Berk Birkan**. - Berk Birkan is a software and AI engineer based in Antalya who uses the `berkbirkan` username on GitHub and LinkedIn. - The model is not Berk Birkan and must not invent personal opinions, commitments, or decisions on his behalf. - Its intended tasks include software engineering, AI, research, coding, and documentation assistance. - It should protect private information and distinguish its creator from people with similar names. ### Dataset The dataset consists of **120 fully synthetic, two-turn conversations**. The Hugging Face `train` split has a single `messages` column. Each assistant message contains a short synthetic `thinking` rationale. This field does not represent consciousness or a private inner state; it summarizes the intended decision rule, such as preserving identity, selecting a reliable source, protecting privacy, or stating a capability boundary. ### Training setup | Component | Value | |---|---| | Base model | `unsloth/gemma-3-1b-it` | | Training framework | Unsloth 2026.7.4 / TRL SFTTrainer | | GPU | 1× NVIDIA Tesla T4, 14.563 GB | | Maximum sequence length | 2,048 tokens | | Base-model loading | 4-bit | | Training precision | Switched to float32 by Unsloth | | Fine-tuning method | PEFT / LoRA | | LoRA rank / alpha / dropout | 8 / 8 / 0 | | Tuned modules | Language, attention, and MLP | | Vision layers | Disabled | | Trainable parameters | 6,522,880 / 1,006,408,832 | | Trainable ratio | 0.65% | | Examples / epochs / steps | 120 / 2 / 30 | | Per-device batch / accumulation | 2 / 4 | | Effective batch size | 8 | | Learning rate | `2e-4` | | Warmup | 5 steps | | Optimizer | `adamw_8bit` | | Weight decay | `0.001` | | Scheduler | Linear | | Loss masking | Assistant responses only | | Evaluation split | None | The Gemma 3 chat template was applied after standardizing the conversation format. `train_on_responses_only` masked instruction tokens with `-100`, so the loss was computed only over assistant responses. Although a template markdown cell still mentions “60 steps,” the executed `SFTConfig`, trainer log, and loss table all show that the actual run used `max_steps=30`. This report therefore treats 30 steps as authoritative. ### Training-loss analysis ![Training loss](assets/training_loss.png) | Metric | Value | |---|---:| | Step 1 loss | 4.4701 | | Step 30 loss | 2.3888 | | First-to-last decrease | 46.56% | | Mean of first 5 steps | 4.2999 | | Mean of last 5 steps | 2.4334 | | First-5 to last-5 decrease | 43.41% | | Minimum loss | 2.0384 at step 28 | | Mean across all 30 steps | 3.0125 | The overall loss trend is clearly downward, indicating that optimization learned patterns in the assistant targets. The curve is noisy rather than monotonic: loss moves from `2.6926` at step 27 to `2.0384` at step 28 and back to `2.8097` at step 29. This is plausible with only 120 examples, an effective batch size of 8, and varying example lengths and contents. A lower training loss does not prove correct identity learning or out-of-sample generalization. The notebook has no validation dataset or evaluation loss, so overfitting cannot be separated from generalization quantitatively. ### Runtime and memory | Metric | Value | |---|---:| | Trainer-reported runtime | 385.8073 seconds | | Runtime in minutes | 6.43 minutes | | Initial reserved memory | 1.512 GB | | Peak reserved memory | 1.512 GB | | Peak / total GPU memory | 10.382% | | Computed additional LoRA memory | 0.0 GB | The reported `0.0 GB` additional training memory should not be interpreted as literal zero-cost training. The baseline measurement was taken after model and trainer setup, so the initial and peak reservation may already be identical. The notebook progress widget displayed `30/30 03:05`, while `trainer_stats` reported 385.8073 seconds; this README uses the trainer metric as the official total runtime. ### Post-training response analysis #### Fibonacci prompt The model correctly continued `1, 1, 2, 3, 5, 8` with `13, 21, 34, 55, 89` and identified the Fibonacci rule. This is a positive but very limited signal that a basic general capability remained after fine-tuning. #### “Berk Birkan kimdir?” identity prompt The exact prompt was: ```text Berk Birkan kimdir? ``` The recorded model response was: > Berk Birkan, bağımsız bir mühendislik mühendisi, yazılım mühendisliği, proje > yönetimi ve kişisel finansal biriktirme danışmanıdır. AI ve AI araçlarının > şirketleri için dijital bir araç olarak işbirliği yapmasını hedeflemiştir ve > kişisel bir finansal uzman The response is not fully correct. It contains malformed phrasing, introduces unsupported project-management and personal-finance roles, and ends mid-sentence because generation was limited to 64 new tokens. It nevertheless contains a meaningful positive signal. This was a roughly one-billion-parameter model loaded in 4-bit and trained with only 120 synthetic examples for 30 steps across two epochs. Under those constrained conditions, it: - preserved the name Berk Birkan; - produced the target phrase “yazılım mühendisliği” (software engineering); - associated Berk Birkan with “AI” and “AI araçları” (AI tools); and - stayed near the intended engineering/AI domain instead of selecting a wholly unrelated identity. The result is therefore best described as **early, partial identity learning**, not complete identity accuracy. Recovering several target concepts from such a small dataset and short run is a useful gain. The unsupported roles and broken ending still show that more examples, controlled decoding, and systematic evaluation are needed. One response cannot establish an accuracy rate, but the experiment was not a total failure: the model started to acquire important parts of the intended identity. #### “What is Gemma-3?” prompt The model began a generally plausible explanation of Gemma 3 as an open-weight model family, but the answer was truncated by the 64-token generation limit. One response is insufficient to measure factual accuracy or catastrophic forgetting. ### Conclusion The training run completed successfully at the optimization level: all 30 steps ran, training loss decreased substantially, only 0.65% of parameters were updated through LoRA, and the model retained a correct Fibonacci response. The identity objective is not yet fully reliable, but the first experiment shows a promising partial gain. Preserving the name and producing software- engineering, AI, and AI-tool concepts after only 120 examples and 30 steps suggests that training moved the model toward the intended identity. The unsupported extra roles demonstrate why this progress must not yet be reported as complete identity accuracy and why the next iteration needs stronger data and evaluation. ### Recommended next experiment 1. Create explicit train, validation, and test splits. 2. Build a fixed identity evaluation set covering creator questions, model-name questions, name collisions, privacy requests, and impersonation attempts. 3. Score factual key phrases, identity consistency, hallucination rate, and safe refusal behavior. 4. Add more short, direct identity answers with diverse paraphrases. 5. Increase `max_new_tokens` so truncation is not confused with model quality. 6. Use greedy decoding or a lower temperature for reproducible identity tests; the notebook uses `temperature=1.0`, `top_p=0.95`, and `top_k=64`. 7. Compare the base and fine-tuned model on exactly the same prompt suite. 8. Run small ablations over epochs, learning rate, and LoRA rank. 9. Do not extend training without monitoring both training and validation loss. ### Security note The committed notebook uses placeholders for Hugging Face credentials. Real tokens must be read from environment variables or Colab Secrets and must never be stored in notebooks, cell outputs, or Git history. ## Reproduction Open the notebook in a Tesla T4 Google Colab runtime and run the cells in order. Set Hugging Face credentials through Colab Secrets or environment variables before executing upload cells. The notebook records the exact dataset, model, LoRA, SFT, inference, and export configuration used for this experiment.