kitchenbot-chat
LoRA
chat adapter for
bychwa/kitchenbot-base — the second half of a weekend experiment to learn pretrain → SFT on a niche cooking model.
Motivation
After pretraining a tiny recipe LM, I wanted it to answer short cooking questions in a chat format — without full fine-tuning. LoRA on a single RTX 3090 was the right tool: small adapter (~1 MB), fast iteration, same pod as pretrain.
What this repo contains
This Hub repo is a PEFT/LoRA adapter, not a full model. Always load it on top of bychwa/kitchenbot-base.
| LoRA setting | Value |
|---|
Rank r | 16 |
lora_alpha | 32 |
| Dropout | 0.05 |
| Target modules | c_attn, c_proj |
| Task | Causal LM (SFT via TRL) |
Training data
10,000 synthetic Q&A pairs (
data/cooking_qa.jsonl) built from
idoyaaran/mise-recipes with simple templates, e.g.:
- “What are the ingredients for {title}?”
- “How do I make {title}?”
- “What is the first step for {title}?”
Messages use a small Jinja chat template with <|user|> / <|assistant|> tokens (set on the base tokenizer before SFT).
Hardware (RunPod)
Same pod as the base run:
| Spec | Value |
|---|
| GPU | 1× NVIDIA GeForce RTX 3090 (24 GB) |
| CUDA | 13.0 |
| Python | 3.12 |
| Stack | PyTorch 2.5.1+cu121, Transformers 5.14, TRL, PEFT, W&B |
Training procedure
Supervised fine-tuning with trl.SFTTrainer + LoRA.
| Hyperparameter | Value |
|---|
| Learning rate | 2e-4 |
| Batch size | 8 |
| Grad accumulation | 4 |
| Epochs | 2 |
| Max length | 256 |
| Precision | fp16 |
Results (train)
| Metric | Value |
|---|
| Steps | 626 |
| Train runtime | ~152 s |
train_loss | ≈ 4.32 |
| Last logged step loss | ≈ 4.10 |
| Mean token accuracy | ≈ 0.44 |
Train curves only — no formal held-out quiz scoreboard shipped with this release.
Quick start
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3from peft import PeftModel
4
5base_id = "bychwa/kitchenbot-base"
6adapter_id = "bychwa/kitchenbot-chat"
7
8tok = AutoTokenizer.from_pretrained(adapter_id)
9model = AutoModelForCausalLM.from_pretrained(
10 base_id,
11 torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
12 device_map="auto" if torch.cuda.is_available() else None,
13)
14model = PeftModel.from_pretrained(model, adapter_id)
15model.eval()
16
17messages = [{"role": "user", "content": "How do I make garlic butter pasta?"}]
18prompt = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
19inputs = tok(prompt, return_tensors="pt")
20if torch.cuda.is_available():
21 inputs = {k: v.to(model.device) for k, v in inputs.items()}
22
23out = model.generate(
24 **inputs,
25 max_new_tokens=120,
26 do_sample=True,
27 temperature=0.7,
28 top_p=0.9,
29 pad_token_id=tok.eos_token_id,
30)
31print(tok.decode(out[0], skip_special_tokens=True))
Or use the CLI from the training repo:
1export HF_USER=bychwa
2python scripts/07_chat.py
Intended use & limitations
Use: casual home-kitchen Q&A demos, learning how LoRA SFT sits on a custom base, portfolio / teaching.
Limits:
- Still a ~7M model — expect wrong steps, mixed recipes, and confident nonsense
- Answers mirror the synthetic templates; not a chef or nutritionist
- 256-token context
- Not suitable for safety-critical or dietary medical advice
Reproduce
1# after base is trained / downloaded into models/kitchenbot-base
2python scripts/04_build_qa_dataset.py
3python scripts/05_set_chat_template.py
4python scripts/06_finetune_chat.py
License
Apache-2.0 for this adapter. Base model and dataset terms also apply (bychwa/kitchenbot-base, idoyaaran/mise-recipes).
Citations
1@software{vonwerra2020trl,
2 title = {{TRL: Transformers Reinforcement Learning}},
3 author = {von Werra, Leandro and Belkada, Younes and Tunstall, Lewis and Beeching, Edward and Thrush, Tristan and Lambert, Nathan and Huang, Shengyi and Rasul, Kashif and Gallouédec, Quentin},
4 license = {Apache-2.0},
5 url = {https://github.com/huggingface/trl},
6 year = {2020}
7}