Week 5: Fine-Tuning and Model Security

Overview

Fine-tune models with LoRA/QLoRA and implement secure model distribution.

Topics

#TypeTitlePlatformDuration
5.1VideoWhen to Fine-Tune vs RAGConcept10 min
5.2VideoDatabricks Fine-TuningDatabricks10 min
5.3LabFine-Tune in DatabricksDatabricks40 min
5.4VideoLoRA/QLoRA from ScratchSovereign10 min
5.5LabFine-Tune with entrenarSovereign45 min
5.6VideoModel Encryption and SigningSovereign10 min
5.7LabSecure Model Pipeline with pachaSovereign35 min
5.8VideoEU AI Act and GovernanceConcept8 min
5.9QuizFine-Tuning and Security15 min

Sovereign AI Stack Components

  • entrenar for LoRA/QLoRA training
  • pacha for ChaCha20-Poly1305 encryption

Key Concepts

LoRA (Low-Rank Adaptation)

  • Freeze base model weights
  • Add trainable low-rank matrices
  • Scaling factor: alpha / r
  • Target modules: q_proj, v_proj, k_proj

QLoRA

  • Quantized base model (4-bit)
  • Double quantization for memory efficiency
  • Paged optimizers for large batches

Fine-Tuning vs RAG

AspectFine-TuningRAG
KnowledgeBaked into weightsRetrieved at runtime
UpdatesRequires retrainingUpdate index only
CostHigher computeLower compute
Use caseStyle/behavior changeKnowledge access