gemma-3-1b-turkish-recipes
LoRA fine-tune (merged, bf16) of unsloth/gemma-3-1b-pt that generates Turkish recipe preparation steps from a title, ingredient list and optional servings/times.
Prompt format
Plain-text template (the base model has no chat template). The model completes the numbered steps after Hazırlanışı: and ends with <eos>.
Tarif adı: Mercimek Çorbası
Porsiyon: 4 kişilik
Malzemeler:
- 1 su bardağı kırmızı mercimek
- 1 adet kuru soğan
- 1 adet havuç
- 1 yemek kaşığı tereyağı
- 7 su bardağı sıcak su
- Tuz
Görev: Bu malzemelerle tarifin hazırlanışını Türkçe olarak açıkla.
Hazırlanışı:
1. ...
Optional lines Porsiyon:, Hazırlık süresi:, Pişirme süresi: are omitted when unknown.
Usage
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("thealper2/gemma-3-1b-turkish-recipes", dtype=torch.bfloat16, device_map="cuda")
tokenizer = AutoTokenizer.from_pretrained("thealper2/gemma-3-1b-turkish-recipes")
prompt = """Tarif adı: Mercimek Çorbası
Malzemeler:
- 1 su bardağı kırmızı mercimek
- 1 adet kuru soğan
- 1 adet havuç
- 7 su bardağı sıcak su
- Tuz
Görev: Bu malzemelerle tarifin hazırlanışını Türkçe olarak açıkla.
Hazırlanışı:
"""
inputs = tokenizer(prompt, return_tensors="pt").to(model.device) # adds <bos>
out = model.generate(**inputs, max_new_tokens=512, do_sample=True, temperature=0.7, top_p=0.9, repetition_penalty=1.05)
print(tokenizer.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Training data
- Dataset:
mmkocak/turkish-recipes-175K(Apache-2.0), revision3f77bffa83f6542f196e81795b7214c2fc77394a - Records: 174,975 raw → 173,338 after cleaning (train 152,645 / validation 10,360 / test 10,333)
- Cleaning: HTML entity/tag removal, Unicode NFC, URL/social-media sentence removal, title noise removal; quantities and units unchanged; no missing values imputed
- Removed: near-duplicates 834, encoding errors 377, over-length 423 (dropped, not truncated), other 3
- Near-duplicate clusters (title+ingredient set, MinHash-LSH on steps) resolved so no recipe spans two splits (187 cross-split clusters fixed)
- Max sequence length: 1024 tokens (covers 99.76% of train)
Training procedure
| parameter | value |
|---|---|
| method | LoRA (16-bit base weights), Unsloth + TRL SFTTrainer |
| loss | completion-only (prompt tokens masked with -100), EOS supervised |
| LoRA r / alpha / dropout | 16 / 16 / 0.0 |
| target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| learning rate / scheduler | 0.0002 / cosine, warmup ratio 0.03 |
| batch (per device × grad. accum.) | 8 × 2 = 16 sequences |
| epochs | 1 |
| optimizer / weight decay / grad clip | adamw_8bit / 0.01 / 1.0 |
| precision | bf16 |
| seed | 3407 |
| train examples | 50,000 (seeded random subset of 152,645) |
| steps / train tokens | 3,125 / 19,381,510 |
| hardware / time | NVIDIA GeForce RTX 5060 Ti / 70.13 min |
| software | torch 2.11.0+cu128, transformers 5.19.0, trl 0.24.0, peft 0.18.1, unsloth 2026.10.3 |
Evaluation
- Validation loss (completion tokens, 2,000 examples): 1.351 (best checkpoint)
Completion perplexity on a fixed test subset (prompt-conditioned, completion tokens only):
| model | perplexity |
|---|---|
| base | 5.539 |
| finetuned | 3.957 |
Generation heuristics on 50 held-out test recipes (sampling, T=0.7):
| metric | base | finetuned | reference steps |
|---|---|---|---|
| ingredient coverage | 0.7929 | 0.6982 | 0.8109 |
| extraneous ingredient stems / output | 1.3 | 1.18 | 1.94 |
| numbered-list format rate | 0.18 | 1 | 1 |
| repeated 4-gram ratio | 0.0114 | 0.0002 | 0 |
| 10-gram overlap with train | 0.0038 | 0.0072 | 0.0135 |
| ROUGE-L vs reference | 0.1212 | 0.1428 | 1 |
Heuristics are lexical (stem matching); they indicate trends and do not replace human review.
Limitations
- Generates only the preparation steps; quantities, times and temperatures in the output can be invented and are not validated.
- No nutrition information is modelled.
- Servings in the source data are partly coarse buckets (e.g. 3/5/7/9/13) from the original sites.
- Trained on scraped home-cooking recipes; style and quality follow the source sites.
License
Derived from Gemma 3; use is subject to the Gemma Terms of Use and Prohibited Use Policy. Training data: Apache-2.0.