FitCoach 8B (LoRA Adapter)

A LoRA adapter fine-tuned on top of Llama 3.1 8B Instruct to act as FitCoach — a conversational fitness and nutrition intake coach.

Try it live: FitCoach Space

Model Details

  • Base model: unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit (loaded in 4-bit for training via Unsloth)
  • Adapter type: 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 — 1,407 synthetic coaching conversations (95/5 train/eval split for this run)
  • Sequence length: 1536 tokens, with sequence packing (bfd strategy)
  • Precision: bf16 training on a single T4 GPU (Google Colab free tier)
  • Epochs: 2, effective batch size 8 (1 × 8 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

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

The adapter was trained against a 4-bit base, but at deployment it's loaded against the full-precision instruct model — QLoRA adapters are compatible with the full-precision version of the same architecture, and this avoids requiring bitsandbytes at inference time.

from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch

base_model_id = "unsloth/Meta-Llama-3.1-8B-Instruct"
adapter_id = "Harsh-k-007/fitcoach-8b-adapter"

tokenizer = AutoTokenizer.from_pretrained(base_model_id)
tokenizer.pad_token = "<|finetune_right_pad_id|>"

base_model = AutoModelForCausalLM.from_pretrained(
    base_model_id,
    dtype=torch.float16,
    device_map="auto",
)
model = PeftModel.from_pretrained(base_model, adapter_id)
model.eval()

messages = [
    {"role": "system", "content": "You are FitCoach, a friendly fitness and nutrition coach."},
    {"role": "user", "content": "Build me a 4-day gym workout plan for muscle gain."},
]

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")
  • 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.1 (unsloth.chat_templates.get_chat_template)
  • Optimizer: adamw_8bit, weight decay 0.01, cosine schedule, 10 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).

Citation

If you use this model, please link back to this repo and the training dataset.

Downloads last month
65
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Harsh-k-007/fitcoach-8b-adapter

Dataset used to train Harsh-k-007/fitcoach-8b-adapter

Space using Harsh-k-007/fitcoach-8b-adapter 1