Skip to content

Latest commit

ย 

History

History
296 lines (239 loc) ยท 8.4 KB

File metadata and controls

296 lines (239 loc) ยท 8.4 KB

๐ŸŒณ Decision Trees: When to Use What Technique

๐ŸŽฏ Main Decision Tree

I want to fine-tune an LLM
โ”œโ”€โ”€ What's your experience level?
โ”‚   โ”œโ”€โ”€ Beginner โ†’ Start with Basic LoRA
โ”‚   โ”œโ”€โ”€ Intermediate โ†’ What's your goal?
โ”‚   โ”‚   โ”œโ”€โ”€ Better conversations โ†’ Try DPO Training
โ”‚   โ”‚   โ”œโ”€โ”€ Domain expertise โ†’ Use task-specific datasets
โ”‚   โ”‚   โ”œโ”€โ”€ Multiple languages โ†’ Use Qwen2.5
โ”‚   โ”‚   โ””โ”€โ”€ Vision + text โ†’ Use Qwen2-VL
โ”‚   โ””โ”€โ”€ Advanced โ†’ What's your use case?
โ”‚       โ”œโ”€โ”€ Research โ†’ Full fine-tuning or high-rank LoRA
โ”‚       โ”œโ”€โ”€ Production โ†’ DPO + evaluation pipeline
โ”‚       โ””โ”€โ”€ Experimentation โ†’ Quick LoRA experiments

๐Ÿ” Model Selection Decision Tree

Step 1: What's Your Hardware?

๐Ÿ“ฑ Google Colab T4 (15GB) or similar

  • โœ… Phi-3 Mini (3.8B) - Best efficiency
  • โœ… Llama-3-8B - Best general performance
  • โœ… Qwen2.5-7B - Best multilingual
  • โœ… Qwen2-VL-7B - Vision-language tasks
  • โŒ Models >20B - Won't fit

๐Ÿ’ป Mid-range GPU (24GB)

  • โœ… All 7B-8B models
  • โœ… GPT-OSS-20B - Advanced reasoning
  • โš ๏ธ 30B models (tight fit)
  • โŒ 70B+ models

๐Ÿ–ฅ๏ธ High-end GPU (40GB+)

  • โœ… All models up to 70B
  • โœ… Full precision training
  • โœ… Large batch sizes

Step 2: What's Your Task?

๐Ÿ“ Text Generation & Creative Writing

  • Best: Llama-3-8B-Instruct
  • Alternative: GPT-OSS-20B
  • Budget: Phi-3 Mini

๐Ÿ’ป Code Generation & Programming

  • Best: Phi-3 Mini (specialized for coding)
  • Alternative: CodeLlama-7B
  • Advanced: GPT-OSS-20B

๐ŸŒ Multilingual Tasks

  • Best: Qwen2.5-7B (29+ languages)
  • Alternative: Llama-3-8B
  • Specialized: mT5 variants

๐Ÿงฎ Mathematical Reasoning

  • Best: Qwen2.5-7B (math-optimized)
  • Alternative: GPT-OSS-20B
  • Specialized: MathCodeT5

๐Ÿ–ผ๏ธ Vision-Language Tasks

  • Best: Qwen2-VL-7B (image + text)
  • Alternative: LLaVA variants
  • Specialized: GPT-4V fine-tuned

๐Ÿ’ฌ Conversational AI

  • Best: Llama-3-8B-Instruct + DPO
  • Alternative: Qwen2.5-7B
  • Budget: Phi-3 Mini

โš™๏ธ Technique Selection Decision Tree

Fine-Tuning Method Decision

def choose_finetuning_method(memory_gb, time_budget, quality_need):
    if memory_gb < 16:
        return "LoRA + 4-bit quantization"
    elif time_budget == "fast" and quality_need == "good":
        return "LoRA + Unsloth"
    elif quality_need == "highest":
        return "Full fine-tuning"
    else:
        return "LoRA + 8-bit"

Training Configuration Decision Tree

๐ŸŽฏ Your Priority?

  • ๐Ÿ’พ Memory Efficiency
    • Use 4-bit quantization
    • LoRA rank: 8-16
    • Batch size: 1
    • Gradient accumulation: 4-8
  • โšก Training Speed
    • Use Unsloth optimizations
    • Mixed precision (fp16/bf16)
    • Higher batch size
    • Gradient checkpointing: False
  • ๐ŸŽฏ Model Quality
    • Higher LoRA rank: 32-64
    • More training epochs: 3-5
    • Lower learning rate: 1e-4
    • Larger dataset
  • ๐Ÿ’ฐ Cost Efficiency
    • Use Google Colab
    • Phi-3 Mini model
    • Short training runs
    • 4-bit quantization

๐Ÿ“Š Dataset Size Decision Tree

๐Ÿ“š How much data do you have?

< 100 examples

  • โš ๏ธ Too small for good results
  • ๐Ÿ’ก Use few-shot prompting instead
  • ๐Ÿ”„ Or augment with synthetic data

100 - 1,000 examples

  • โœ… Perfect for LoRA fine-tuning
  • ๐Ÿ“ Focus on high-quality curation
  • โฑ๏ธ Training time: 10-30 minutes

1,000 - 10,000 examples

  • โœ… Excellent for most use cases
  • ๐ŸŽฏ Can use higher LoRA ranks
  • โฑ๏ธ Training time: 30 minutes - 2 hours

10,000+ examples

  • โœ… Great for specialized domains
  • ๐Ÿ”„ Consider full fine-tuning
  • ๐Ÿ“Š Split into train/validation sets
  • โฑ๏ธ Training time: 2+ hours

๐ŸŽจ Use Case Specific Recommendations

๐ŸŽ“ Educational Applications

Math Tutoring

  • Model: Qwen2.5-7B (math-specialized)
  • Method: LoRA + mathematical datasets
  • Training: 1,000 problem-solution pairs
  • Post-processing: DPO for explanation quality

Language Learning

  • Model: Qwen2.5-7B (multilingual)
  • Method: LoRA + conversation datasets
  • Training: Native speaker dialogues
  • Evaluation: Fluency + grammar checks

Code Teaching

  • Model: Phi-3 Mini (code-optimized)
  • Method: LoRA + coding instruction datasets
  • Training: Code explanation pairs
  • Testing: Code generation accuracy

๐Ÿ’ผ Business Applications

Customer Service

  • Model: Llama-3-8B + DPO training
  • Dataset: Historical support tickets
  • Training: Helpful vs unhelpful responses
  • Deployment: API with safety filters

Content Generation

  • Model: GPT-OSS-20B (creativity)
  • Method: LoRA + brand voice data
  • Training: Company writing samples
  • Quality: Human review process

Data Analysis

  • Model: Qwen2.5-7B (structured data)
  • Method: LoRA + analysis examples
  • Training: Question-insight pairs
  • Output: JSON formatted results

๐Ÿ”ฌ Research Applications

Vision-Language Research

  • Model: Qwen2-VL-7B
  • Method: LoRA + multimodal datasets
  • Training: Image-text pairs
  • Evaluation: Multimodal benchmarks

Scientific Literature

  • Model: GPT-OSS-20B (reasoning)
  • Method: Full fine-tuning or high-rank LoRA
  • Training: Domain-specific papers
  • Output: Research insights

๐Ÿ”„ Iterative Improvement Decision Tree

๐ŸŽฏ After Initial Training

Model performance is...

  • ๐Ÿ˜ž Poor (< 60% accuracy)
    • ๐Ÿ” Check data quality
    • ๐Ÿ“Š Increase dataset size
    • โš™๏ธ Adjust learning rate
    • ๐Ÿ”„ Try different model
  • ๐Ÿ˜ Okay (60-80% accuracy)
    • ๐Ÿ“ˆ Increase LoRA rank
    • ๐ŸŽฏ Add more training epochs
    • ๐Ÿ”ง Try DPO training
    • ๐Ÿ“š Improve dataset quality
  • ๐Ÿ˜Š Good (80%+ accuracy)
    • ๐Ÿš€ Ready for deployment!
    • ๐Ÿ“Š Set up evaluation pipeline
    • ๐Ÿ”„ Consider model distillation
    • ๐Ÿ“ˆ Monitor production performance

๐Ÿ› ๏ธ Quick Decision Flowcharts

โšก 30-Second Model Choice

I need a model for...

  • ๐Ÿ“ฑ Mobile deployment โ†’ Phi-3 Mini
  • ๐Ÿ’ฌ Chatbot โ†’ Llama-3-8B + DPO
  • ๐ŸŒ Multiple languages โ†’ Qwen2.5-7B
  • ๐Ÿงฎ Math problems โ†’ Qwen2.5-7B
  • ๐Ÿ’ป Code tasks โ†’ Phi-3 Mini
  • ๐Ÿ–ผ๏ธ Vision + text โ†’ Qwen2-VL-7B
  • ๐Ÿ”ฌ Research โ†’ GPT-OSS-20B

โšก 30-Second Technique Choice

I want...

  • ๐Ÿ’พ Lowest memory โ†’ LoRA + 4-bit
  • โšก Fastest training โ†’ LoRA + Unsloth
  • ๐ŸŽฏ Best quality โ†’ Full fine-tuning
  • ๐Ÿ’ฐ Cheapest โ†’ LoRA + Colab T4
  • ๐Ÿค– Better responses โ†’ DPO training
  • ๐Ÿ–ผ๏ธ Vision capabilities โ†’ Vision model + LoRA

๐Ÿ“‹ Decision Checklist

Before starting fine-tuning, check:

  • Hardware Requirements: Can my GPU handle the model?
  • Dataset Quality: Do I have clean, relevant data?
  • Time Budget: How long can I train?
  • Quality Expectations: What accuracy do I need?
  • Deployment Target: Where will this model run?
  • Budget Constraints: What can I afford to spend?

๐ŸŽฏ Common Decision Scenarios

Scenario 1: "I'm a student with limited budget"

โœ… Solution:

  • Platform: Google Colab (free)
  • Model: Phi-3 Mini
  • Method: LoRA + 4-bit quantization
  • Dataset: Small, curated dataset
  • Time: Quick experiments

Scenario 2: "I need production-ready chatbot"

โœ… Solution:

  • Platform: Cloud GPU (Runpod/Lambda)
  • Model: Llama-3-8B-Instruct
  • Method: SFT + DPO training
  • Dataset: Conversational data + preferences
  • Evaluation: Human feedback loop

Scenario 3: "I want to experiment with techniques"

โœ… Solution:

  • Platform: Mixed (Colab + cloud)
  • Models: Multiple small models
  • Method: Rapid LoRA experiments
  • Dataset: Standardized benchmarks
  • Focus: Technique comparison

Scenario 4: "I need vision-language capabilities"

โœ… Solution:

  • Platform: Google Colab T4 or better
  • Model: Qwen2-VL-7B
  • Method: LoRA + 4-bit quantization
  • Dataset: Image-text pairs
  • Use case: OCR, VQA, image understanding

๐Ÿ“Š Decision Matrix

Priority Memory Speed Quality Cost Recommended Setup
Learning Low Medium Medium Low Phi-3 + LoRA + Colab
Research High Low High High GPT-OSS-20B + Full FT
Production Medium High High Medium Llama-3-8B + DPO
Experimentation Low High Medium Low Multiple small models
Vision Tasks Medium Medium High Medium Qwen2-VL + LoRA

Still unsure? โ†’ Ask in Discussions or check Troubleshooting Guide