A newer version of the Gradio SDK is available: 6.20.0
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
Tech Advisor: a Gradio chatbot fine-tuned on AWS DevOps Agent documentation. Uses NVIDIA Llama-3.1-Nemotron-Nano-4B-v1.1 as the base model, fine-tuned with QLoRA. Deployed to Hugging Face Spaces with ZeroGPU (no cloud APIs at inference).
Architecture
app.pyβ Gradio text chat interface using@spaces.GPUdecorator for ZeroGPU. Loads model via transformersAutoModelForCausalLM+AutoTokenizer. Text-only (no vision).training/β Offline pipeline (runs on EC2 with GPU, not in the Space):prepare_data.pyβ Converts raw markdown docs intraining/data/raw/into instruction-response JSONL pairstrain.pyβ QLoRA fine-tuning (4-bit NF4, LoRA r=16 on q/k/v/o projections)push_to_hub.pyβ Merges adapter into base model and pushes to HF Hub
Commands
# Run the Gradio app locally (requires GPU or will be very slow on CPU)
python app.py
# Training pipeline (run on GPU instance)
python training/prepare_data.py # raw docs β training/data/train.jsonl
pip install -r training/requirements.txt
python training/train.py # QLoRA fine-tune β training/output/
python training/push_to_hub.py # merge + push to HF Hub
Deployment
Two git remotes:
originβ GitHubspaceβ Hugging Face Space (git push space mainto deploy)
Hardware: ZeroGPU in HF Spaces. No secrets or API keys needed.
Key Configuration
MODEL_IDinapp.pycontrols which model is loaded at inference (base or fine-tuned)HUB_REPOintraining/push_to_hub.pyis the target HF repo for the merged model- Training hyperparams in
training/train.py: epochs=3, batch=2, grad_accum=8, lr=2e-4, max_seq_length=4096