A fine-tuned 2B LLM (Qwen2.5-1.5B-Instruct) that reads any dataset sample, auto-detects the finetuning type (image classification, VLM, LLM, text classification), and generates production-ready finetuning code with correctly pinned library versions.
Training Hardware
This model was fine-tuned entirely on CPU (no GPU required):
Fine-tuning on the 522 MB dataset (300K samples) uses ~8-12 GB RAM and all 40 logical processors. Each epoch takes approximately 15-20 hours on this hardware. The LoRA adapter (8-50 MB) is the only file published — the base model stays on HuggingFace Hub.
How the Data Pipeline Works
The training_dataset.jsonl (522 MB) is NOT crawled from the internet directly. It is synthetically generated from crawled real data. Here is the exact pipeline:
data/compatibility_matrix.json — CUDA/Python version compatibility
data/scraped_data.json — raw HTML scraped from PyTorch docs, TF docs, HF releases
Step 2: Synthetic Dataset Generation
scripts/generate_dataset.py takes all crawled data and generates 300,000 unique Q&A pairs programmatically (no LLM involved in generation). This is what produces training_dataset.jsonl at 522 MB.
Each Q&A pair is generated by a Python template engine that:
Picks a category (weighted random selection)
Selects real versions from the crawled pypi_versions.json
Selects real model names, dataset names, hyperparameters
Fills in a human-written template with the selected values
Categories of Data in training_dataset.jsonl
Category
% of Dataset
Example Question
Example Output
Install commands
15%
"Give me libraries for LLM training"
pip install torch==2.12.1 transformers==5.12.1 ... + version table
Version queries
10%
"What PyTorch works with CUDA 11.8?"
Real version compatibility from crawled data
LLM fine-tuning code
8%
"Write a QLoRA script for meta-llama/Llama-2-7b"
Full Python script with pinned versions
Image classification
10%
"How to fine-tune ViT on cifar10?"
Code with torchvision transforms, Trainer
Image training code
5%
"Full training script for resnet-50 on food101"
Production-ready image classification code
VLM fine-tuning
8%
"Fine-tune Qwen2-VL-7B for VQA"
QLoRA multi-modal code with processor
VLM training code
5%
"QLoRA script for LLaVA-1.5-7B"
Full VLM training pipeline
Model specs Q&A
8%
"Compare ViT, ResNet, ConvNeXt"
Table with ImageNet accuracy, GPU memory, throughput
Decision guidance
6%
"Full FT vs LoRA vs QLoRA?"
Decision tree with memory/speed/quality tradeoffs
Dependency Q&A
5%
"What depends on bitsandbytes?"
Real dependency graph from crawled data
Text classification
8%
"Fine-tune BERT for sentiment"
Code with DataCollatorWithPadding
General ML knowledge
4%
"What is gradient checkpointing?"
Curated explanations
Distributed training
5%
"DDP training script"
Multi-GPU code
Why 522 MB?
300,000 unique samples × ~1.7 KB average per Q&A pair = ~510 MB
Diversity is enforced by MD5 hash deduplication (took 554,904 attempts to get 300,000 unique)
Each sample has real pinned versions (not "x.x.x") from the live crawled data
Code samples are full production scripts (30-70 lines each), not snippets
How the Data is NOT Generated
No LLM was used to generate the dataset (no GPT, no LLaMA, no API calls)
No copy-pasting from documentation
No manual writing of 300,000 pairs
The templates were written once by a human (~30 templates), and the Python script combinatorially fills them with real crawled data, real model names, real dataset names, and randomized hyperparameters to create 300K unique variations.
Project Structure
proj-llm-fine/
│
├── data/ # All data (522 MB+)
│ ├── pypi_versions.json # Crawled: 56 packages, 5,751 versions (13.4 MB)
│ ├── dependency_graph.json # Crawled: inter-package deps (266 KB)
│ ├── model_specs.json # 58 open-source models with specs (25 KB)
│ ├── compatibility_matrix.json # CUDA/Python mappings
│ ├── compatibility_summary.json # Latest versions + dep edges
│ ├── scraped_data.json # Raw HTML scraped data
│ ├── hf_model_cards.json # Scraped HF model metadata
│ ├── training_dataset.jsonl # GENERATED: 300K Q&A pairs (522 MB)
│ ├── training_dataset.json # Same as JSON (516 MB)
│ ├── combined_dataset.jsonl # Merged smaller dataset (405 samples, 771 KB)
│ ├── release_dataset.jsonl # Real scraped Q&A (43 pairs, 31 KB)
│ └── comparison_results.json # Before/after eval
│
├── model/ # Base model (git-friendly via config)
│ ├── model_config.json # save_base_model: true/false flag
│ ├── config.json, tokenizer.* # Config (no .safetensors in git)
│ └── chat_template.jinja
│
├── src/ # Python modules
│ ├── app.py # CLI + Gradio + --auto flag
│ ├── dataset_inspector.py # Auto-detect dataset type from samples
│ ├── code_generator.py # Generate finetuning code per detected type
│ ├── version_db.py # Version + deps + model spec lookups
│ └── prompt_builder.py # System prompt with version context
│
├── scripts/ # Build scripts
│ ├── crawl_sub_dependencies.py # 🔹 NEW: crawls 56 packages from PyPI
│ ├── build_model_specs.py # 🔹 NEW: builds model_specs.json
│ ├── collect_data.py # Original PyPI scraper (updated to 50 pkgs)
│ ├── scrape_release_docs.py # HTML scraper (expanded with HF model cards)
│ ├── generate_dataset.py # 🔹 UPDATED: generates 300K pairs (522 MB)
│ ├── fine_tune.py # QLoRA training (--no-save-safetensors flag)
│ └── ...existing scripts
│
├── output/ # Trained LoRA adapters
│ └── adapter-cpu-test/ # 8.7 MB adapter (trained on 43 samples)
│
├── task.md # Knowledge transfer document
├── README.md # This file
├── .gitignore # Excludes model/*.safetensors
├── requirements.txt
└── plan.md
New Features
1. Auto-Detect Dataset Type (--auto)
bash
1# Auto-detect from HuggingFace dataset2python src/app.py --auto cifar10 --generate-only
34# Auto-detect from local file5python src/app.py --auto --file data/samples.jsonl
67# Auto-detect + explain with the fine-tuned LLM8python src/app.py --auto cifar10 --adapter output/adapter-cpu-test
The Dataset Inspector (src/dataset_inspector.py) analyzes 5 samples and detects:
Detected Type
Example Dataset
Recommended Model
Method
image_classification
CIFAR-10, ImageNet, Food101
ViT-B/16, ResNet-50, ConvNeXt-B
Full FT or LoRA
vlm_finetuning
COCO Captions, LLaVA-Instruct
Qwen2-VL-7B, LLaVA-1.5-7B
QLoRA
llm_finetuning
Alpaca, Dolly, chat data
Qwen2.5-1.5B, Mistral-7B
QLoRA
text_classification
IMDB, SST-2, AG News
RoBERTa-base, DeBERTa-v3
LoRA
2. Code Generator (src/code_generator.py)
Generates complete Python scripts with:
Pinned dependency versions from the crawled pypi_versions.json
Proper imports for the detected model type
Data preprocessing (torchvision transforms, tokenization, VLM formatting)
Model setup with PEFT/LoRA/QLoRA config
Training arguments with recommended hyperparameters
1# Ask a question (uses base model from HF Hub)2python src/app.py "How to install PyTorch with CUDA 11.8?"34# With fine-tuned adapter5python src/app.py --adapter output/adapter-cpu-test "Write a QLoRA script"67# Auto-detect dataset8python src/app.py --auto "cifar10" --generate-only
Data Pipeline (if you want to regenerate)
bash
1# Step 1: Crawl live data (56 packages from PyPI)2python scripts/crawl_sub_dependencies.py
34# Step 2: Generate model specs5python scripts/build_model_specs.py
67# Step 3: Generate 300K Q&A pairs (522 MB)8python scripts/generate_dataset.py
910# Step 4: Fine-tune the model11python scripts/fine_tune.py --dataset data/training_dataset.jsonl --epochs 3