Files
fitcoach-3b/README.md

133 lines
5.1 KiB
Markdown
Raw Permalink Normal View History

---
license: llama3.2
base_model: unsloth/Llama-3.2-3B-Instruct-bnb-4bit
library_name: transformers
tags:
- sft
- trl
- unsloth
- fitness
- nutrition
- coaching
- conversational
- merged
datasets:
- Harsh-k-007/fitcoach-conversations
pipeline_tag: text-generation
---
# FitCoach 3B (Merged, fp16)
A fully merged, full-precision (fp16) fine-tune of Llama 3.2 3B Instruct, acting as
**FitCoach** — a conversational fitness and nutrition intake coach. This is the
lightweight option in the FitCoach model family, alongside the
[8B LoRA adapter](https://huggingface.co/Harsh-k-007/fitcoach-8b-adapter).
Try it live: [FitCoach Space](https://huggingface.co/spaces/Harsh-k-007/fitcoach)
## Model Details
- **Base model:** `unsloth/Llama-3.2-3B-Instruct-bnb-4bit` (loaded in 4-bit for
training via Unsloth, then merged to 16-bit for deployment)
- **Format:** merged weights, fp16 — no adapter required, load directly
- **Adapter (during training):** LoRA, rank 16, alpha 16, dropout 0, targeting all
attention and MLP projection layers (`q/k/v/o_proj`, `gate/up/down_proj`)
- **Training framework:** Unsloth `FastLanguageModel` + TRL `SFTTrainer`
- **Training data:** [`Harsh-k-007/fitcoach-conversations`](https://huggingface.co/datasets/Harsh-k-007/fitcoach-conversations)
— 1,407 synthetic coaching conversations (95/5 train/eval split for this run)
- **Sequence length:** 2048 tokens, with sequence packing (`bfd` strategy)
- **Precision:** bf16 training on a single T4 GPU (Google Colab free tier)
- **Epochs:** 2, effective batch size 8 (2 × 4 grad accumulation), cosine LR
schedule, peak LR 2e-4
## Intended Use
FitCoach is a **conversational intake coach** for fitness and nutrition. Given a
user's goal, it asks **one question at a time** to gather the relevant context, then
generates a structured plan.
Scope is intentionally narrow:
- **Meal plans** (~60% of training data): collects goal, age/height/weight, dietary
restrictions, activity level
- **Workout plans** (~40% of training data): collects goal, experience level, days
per week, equipment access
The 3B model is intended as a **lighter, faster** alternative to the 8B adapter —
useful where latency or memory matters more than maximum response quality.
### Out of scope
- Injuries, medical conditions, or any medical advice
- Macro/calorie arithmetic — the model can *describe* macro targets conceptually but
is **not reliable at computing them**; treat any numeric macro breakdown as
approximate, not verified
- Unprompted macro generation — the model does not currently generate macros unless
explicitly asked (known dataset gap, planned for v2)
## How to Use
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_id = "Harsh-k-007/fitcoach-3b"
tokenizer = AutoTokenizer.from_pretrained(model_id)
tokenizer.pad_token = "<|finetune_right_pad_id|>"
model = AutoModelForCausalLM.from_pretrained(
model_id,
dtype=torch.float16,
device_map="auto",
)
model.eval()
messages = [
{"role": "system", "content": "You are FitCoach, a friendly fitness and nutrition coach."},
{"role": "user", "content": "Create a simple fat-loss meal plan with Indian food options."},
]
encoded = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
input_ids = encoded["input_ids"] if hasattr(encoded, "keys") else encoded
input_ids = input_ids.to(model.device)
output = model.generate(
input_ids,
max_new_tokens=512,
do_sample=True,
temperature=0.7,
top_p=0.9,
pad_token_id=128004,
)
print(tokenizer.decode(output[0][input_ids.shape[-1]:], skip_special_tokens=True))
```
## Training Procedure
- **Method:** Supervised fine-tuning (SFT) with TRL `SFTTrainer`, using Unsloth's
`FastLanguageModel` for memory-efficient LoRA training (gradient checkpointing via
`use_gradient_checkpointing="unsloth"`), then merged to full precision via
`save_pretrained_merged(..., save_method="merged_16bit")`
- **Loss:** full-conversation loss (`train_on_responses_only` / assistant-only
masking was not applied in this run — a documented future optimization once
reliably supported for the Llama 3 chat template)
- **Chat template:** Llama 3.2 (`unsloth.chat_templates.get_chat_template`)
- **Optimizer:** `adamw_8bit`, weight decay 0.01, cosine schedule, 17 warmup steps
- **Hardware:** Google Colab T4 (free tier), with Drive checkpointing for
resumability across the 90-minute idle / 12-hour session limits
## Known Limitations
- **Macro arithmetic is hallucinated.** The model isn't reliable at computing
calorie/macro numbers. A v2 release plans to add a calculator/tool layer for this.
- **Macros aren't generated unprompted.** The dataset under-represents this, so the
model needs to be asked explicitly. Planned fix for v2 via dataset augmentation.
- **No assistant-only loss** in this training run (see above).
- As the smaller model in the family, expect slightly less consistent intake
behavior and plan structure compared to the 8B adapter.
## Citation
If you use this model, please link back to this repo and the
[training dataset](https://huggingface.co/datasets/Harsh-k-007/fitcoach-conversations).