Skip to content

This repository contains resources, labs, and notes from a comprehensive Generative AI course, covering topics such as Natural Language Processing, Large Language Models, and Responsible AI. It aims to help Data Scientists and enthusiasts learn and grow in the field of Generative AI.

License

Notifications You must be signed in to change notification settings

ruslanmv/Generative-AI-Course

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

35 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Generative AI Course - Production-Ready Educational Platform

License Python Status Transformers

A comprehensive, commercial-grade platform for mastering Generative AI, Large Language Models, and Multimodal Systems

What This Offers β€’ Installation β€’ Notebooks β€’ Quick Start β€’ Documentation


🌟 What This Platform Offers

This Generative AI Course is your complete, production-ready toolkit for mastering modern AI. Whether you're a beginner or an experienced practitioner, this platform provides everything you need:

πŸŽ“ For Learners

  • 177+ Hands-On Jupyter Notebooks: Interactive tutorials covering every aspect of Generative AI
  • Step-by-Step Guides: From basic NLP to advanced multimodal models
  • Real-World Examples: Practical implementations you can use immediately
  • Progressive Learning Path: Organized curriculum from fundamentals to advanced topics

πŸ’Ό For Practitioners

  • Production-Ready Code: Deploy LLMs with our FastAPI inference server
  • Fine-Tuning Recipes: Train Llama, Mistral, Gemma, and more with LoRA/QLoRA
  • Optimization Techniques: Quantization (4-bit/8-bit), model compression, efficient inference
  • Enterprise Tools: Automated build system, testing, CI/CD integration

πŸš€ For Businesses

  • Commercial License: Apache 2.0 - free for commercial use
  • Deployment Solutions: Production servers with streaming, health checks, monitoring
  • Scalable Architecture: Multi-worker deployment, load balancing, Docker-ready
  • Professional Standards: PEP 8 compliant, type-hinted, fully documented

πŸ› οΈ What You'll Build

  • Fine-tune Large Language Models for your specific use case
  • Deploy production LLM inference servers with streaming responses
  • Create multimodal AI applications combining vision and language
  • Build RAG (Retrieval Augmented Generation) systems
  • Optimize models for consumer hardware with quantization
  • Implement diffusion models for image generation

πŸ“– About

The Generative AI Course is a production-ready educational platform designed for Data Scientists, ML Engineers, and AI enthusiasts to master the complete spectrum of Generative AI technologies. This repository combines theoretical foundations with hands-on implementation, offering 177+ Jupyter notebooks, production-ready Python modules, and deployment solutions for real-world applications.

What Makes This Different?

  • Production-Ready Code: All modules follow industry best practices with comprehensive type hints, docstrings, and error handling
  • Modern Development Stack: Built with uv package manager, automated testing, and CI/CD-ready infrastructure
  • Comprehensive Coverage: From fundamentals to advanced topics including LLMs, diffusion models, multimodal systems, and deployment
  • Hands-On Learning: 177+ interactive notebooks covering every aspect of Generative AI
  • Enterprise Deployment: Production FastAPI servers, quantization, and optimization techniques
  • Open Source: Apache 2.0 licensed for commercial and educational use

πŸš€ Installation

Simple 3-Step Installation

# 1. Clone the repository
git clone https://github.com/ruslanmv/Generative-AI-Course.git
cd Generative-AI-Course

# 2. Install Jupyter and core dependencies
pip install jupyter notebook ipykernel

# 3. Start exploring!
jupyter notebook

For Production Use (Recommended)

If you want to use the production FastAPI server and development tools:

# Install uv package manager (faster than pip)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install all dependencies
make install-all

# Or manually with pip
pip install -e ".[all]"

πŸ“ Important Note About Notebook Dependencies

Each notebook may require specific dependencies based on the model or technique it demonstrates:

  • Most notebooks are self-contained and will install their required packages in the first cell
  • Some notebooks require GPU with CUDA support (check the notebook introduction)
  • Cloud notebooks (marked with Colab badges) can run for free on Google Colab
  • Large models may need 16GB+ RAM or cloud resources

Before running a notebook:

  1. Open the notebook and check the first few cells for dependency installation
  2. Run the pip install commands provided in the notebook
  3. Some notebooks include !pip install package_name - these will auto-install

Common notebook-specific dependencies:

  • Fine-tuning notebooks: transformers, peft, trl, bitsandbytes
  • Quantization notebooks: auto-gptq, llama-cpp-python, exllamav2
  • Multimodal notebooks: weaviate-client, opencv-python, scikit-image
  • Diffusion notebooks: diffusers, controlnet_aux

πŸ’‘ Tip: Start with the notebooks in order - early notebooks often explain dependency installation for the entire section.


πŸ““ Interactive Notebooks

All notebooks are directly accessible by clicking the links below. Each notebook is self-contained with installation instructions.

πŸ“Š Data Preparation (17 Notebooks)

Create custom datasets for fine-tuning LLMs from documents, topics, or existing data.

Notebook Description Link
Documents β†’ Dataset Generate instruction/QA datasets from your documents Open Notebook
Topic β†’ Dataset Create datasets from a topic or domain Open Notebook
Alpaca Dataset Generator Original Alpaca-style instruction dataset creation Open Notebook
News Classification Dataset Create classification datasets with GPT-3.5 Open Notebook
Translation Dataset (Bilingual) Prepare bilingual translation datasets Open Notebook
Translation Dataset (Multi-lang) Translation between multiple languages Open Notebook
Romanized Indic Languages Translation to romanized Indic languages Open Notebook
DPO Dataset Formatting Format datasets for Direct Preference Optimization Open Notebook
DPO Translation Dataset Create DPO datasets for translation tasks Open Notebook
Instruction Dataset Prep Prepare instruction-following datasets Open Notebook
Create Custom Dataset General dataset creation utilities Open Notebook
Translation Dataset Creator Build translation training datasets Open Notebook
Translation Inference Test translation models on single examples Open Notebook
Combine Translations Merge and combine translation datasets Open Notebook
Kannada Dataset Merger Merge Kannada language datasets Open Notebook
LLaVA Image Prep Prepare image datasets for LLaVA training Open Notebook
Aarogya Formatting Format Aarogya medical datasets Open Notebook

πŸ”§ Fine-Tuning LLMs (17 Notebooks)

Master parameter-efficient fine-tuning with LoRA, QLoRA, SFT, DPO, and ORPO.

Notebook Model Technique Framework Link
Llama 2 SFT (Google Colab) Llama 2 7B SFT Transformers Open Notebook
Llama 2 QLora Llama 2 7B QLora PEFT Open Notebook
Llama 3 ORPO Llama 3 8B ORPO TRL Open Notebook
Llama 3 Alpaca (Unsloth) Llama 3 8B SFT Unsloth Open Notebook
Mistral 7B SFT Mistral 7B SFT TRL Open Notebook
Mistral 7B DPO Mistral 7B DPO TRL Open Notebook
Mistral 7B (Unsloth) Mistral 7B SFT Unsloth Open Notebook
Mistral Fine-tuning Mistral 7B SFT Transformers Open Notebook
Gemma SFT Gemma 7B SFT Transformers Open Notebook
Gemma (Unsloth) Gemma 7B SFT Unsloth Open Notebook
Gemma Fine-tuning Gemma 2B/7B SFT Transformers Open Notebook
Mixtral Fine-tuning Mixtral 8x7B SFT Transformers Open Notebook
Phi-3 (Unsloth) Phi-3 3.8B SFT Unsloth Open Notebook
TinyLlama + RoPE TinyLlama SFT + RoPE Unsloth Open Notebook
DPO Zephyr Zephyr DPO Unsloth Open Notebook
ORPO (Unsloth) Various ORPO Unsloth Open Notebook
Axolotl Framework CodeLlama SFT Axolotl Open Notebook

Performance Gains: Unsloth notebooks achieve up to 3.9x faster training and 74% less memory usage compared to standard implementations.


⚑ Quantization (6 Notebooks)

Compress models to run on consumer hardware without significant quality loss.

Notebook Format Description Link
Introduction to Quantization 8-bit Foundation of weight quantization Open Notebook
GPTQ Quantization GPTQ 4-bit quantization with GPTQ Open Notebook
GGUF & llama.cpp GGUF Quantize for llama.cpp inference Open Notebook
GGUF Quantization GGUF General GGUF quantization guide Open Notebook
AWQ Quantization AWQ Activation-aware weight quantization Open Notebook
ExLlamaV2 EXL2 Fastest inference with ExLlamaV2 Open Notebook

πŸš€ Deployment & Inference (5 Notebooks)

Production-ready deployment strategies and performance benchmarking.

Notebook Technology Description Link
Llama.cpp Python llama.cpp Inference with llama.cpp Python bindings Open Notebook
vLLM Benchmark vLLM Benchmark vLLM performance Open Notebook
TGI vs vLLM TGI, vLLM Compare Text Generation Inference vs vLLM Open Notebook
Streaming Inference Hugging Face Implement streaming text generation Open Notebook
FastAPI Server FastAPI Production server (see /Deployment/server.py) View Code

🎨 Diffusion Models (7 Notebooks)

Generate and manipulate images with state-of-the-art diffusion techniques.

Notebook Technique Description Link
Negative Prompts Stable Diffusion Control generation with negative prompts Open Notebook
Image-to-Image img2img Transform images with diffusion Open Notebook
Image Interpolation Interpolation Smooth transitions between images Open Notebook
DiffEdit v1 DiffEdit Semantic image editing Open Notebook
DiffEdit v2 DiffEdit Enhanced image editing Open Notebook
DiffEdit v3 DiffEdit Advanced editing techniques Open Notebook
DiffEdit v4 DiffEdit Latest DiffEdit improvements Open Notebook

πŸ–ΌοΈ Multimodal AI (6 Notebooks)

Combine vision, language, and other modalities for advanced AI applications.

Notebook Topic Description Link
Overview of Multimodality Introduction Fundamentals of multimodal AI Open Notebook
Multimodal Search Search Cross-modal search and retrieval Open Notebook
Large Multimodal Models LMMs Understanding LMMs like GPT-4V Open Notebook
Multimodal RAG RAG Retrieval with images and text Open Notebook
Industry Applications Applications Real-world multimodal use cases Open Notebook
Multimodal Recommender Recommendation Build multimodal recommendation systems Open Notebook

πŸ› οΈ Tools & Utilities (6 Notebooks)

Automate common tasks with one-click tools.

Notebook Tool Description Link
AutoQuant Quantization Quantize to GPTQ, GGUF, AWQ, EXL2, HQQ in one click Open Notebook
LazyMergekit Model Merging Merge models using MergeKit easily Open Notebook
LazyAxolotl Fine-tuning Fine-tune in the cloud with Axolotl Open Notebook
LLM AutoEval Evaluation Automatically evaluate LLMs with RunPod Open Notebook
Model Family Tree Visualization Visualize merged model genealogy Open Notebook
ZeroChat Deployment Create Gradio chat UI with ZeroGPU Open Notebook

🧬 Transformers Advanced (118+ Notebooks)

Comprehensive collection covering every aspect of transformer-based models.

NLP Tasks

Notebook Task Link
Text Classification Classification Open Notebook
Text Classification (TF) Classification Open Notebook
Token Classification NER, POS tagging Open Notebook
Question Answering QA Open Notebook
Summarization Summarization Open Notebook
Translation Machine Translation Open Notebook
Language Modeling LM Open Notebook
Language Modeling from Scratch LM Open Notebook

Computer Vision

Notebook Task Link
Image Classification Classification Open Notebook
Image Similarity Similarity Open Notebook
Image Captioning (BLIP) Captioning Open Notebook
Image Captioning (Pix2Struct) Captioning Open Notebook
Semantic Segmentation Segmentation Open Notebook
Segment Anything Segmentation Open Notebook
Zero-Shot Object Detection Detection Open Notebook
Video Classification Video Open Notebook

Audio & Speech

Notebook Task Link
Audio Classification Classification Open Notebook
Speech Recognition ASR Open Notebook
Multi-Lingual Speech Recognition ASR Open Notebook

Time Series & Specialized

Notebook Domain Link
Time Series Transformers Forecasting Open Notebook
Multivariate Informer Forecasting Open Notebook
Protein Folding Biology Open Notebook
Protein Language Modeling Biology Open Notebook
DNA Sequence Modeling Biology Open Notebook
Annotated Diffusion Diffusion Open Notebook

Optimization & Deployment

Notebook Topic Link
ONNX Export Deployment Open Notebook
Benchmark Performance Open Notebook
TPU Training (TF) Training Open Notebook

View all 118+ Transformer notebooks β†’


πŸ“š Transformers Basics (20 Notebooks)

Foundation tutorials for getting started with transformers.

Notebook Topic Link
How to Train a Model Basics Open Notebook
How to Generate Text Generation Open Notebook
Reformer Architecture Architecture Open Notebook
Encoder-Decoder Basics Architecture Open Notebook
Warm Starting Encoder-Decoder Training Open Notebook
Training Decision Transformers RL Open Notebook
Fine-Tuning Whisper Audio Open Notebook
Getting Started with Embeddings Embeddings Open Notebook
Sentiment Analysis on Twitter NLP Open Notebook

View all basics notebooks β†’


πŸ”¬ Other Advanced Topics

Notebook Topic Link
Knowledge Graphs + ChatGPT RAG Open Notebook
Decoding Strategies in LLMs Generation [Open Notebook](Decoding/Decoding_Strategies_in_Large_Language Models.ipynb)
MergeKit Model Merging Open Notebook

⚑ Quick Start

1. Launch Jupyter Lab

# Simple way
jupyter notebook

# Or with the Makefile (if installed production dependencies)
make notebooks

Navigate to any notebook above and start learning!

2. Run the Production LLM Server

# Start the FastAPI server with streaming inference
python Deployment/server.py \
    --model_id mistralai/Mistral-7B-Instruct-v0.2 \
    --quantization \
    --port 8000 \
    --max_new_tokens 512

3. Query the Server

# Using the client
python Deployment/client.py \
    --endpoint http://localhost:8000/query-stream \
    --query "Explain quantum computing in simple terms"

# Or with curl
curl "http://localhost:8000/query-stream/?query=What%20is%20AI?"

4. Fine-Tune Your First Model

Open any fine-tuning notebook, for example:


πŸ“š Documentation

Course Curriculum

The course is organized into 7 comprehensive modules:

  • Fundamentals of Generative AI
  • VAEs, GANs, and Transformer architectures
  • Responsible AI, ethics, and governance
  • Real-world applications
  • Text preprocessing and tokenization
  • Word embeddings (Word2Vec, GloVe, FastText)
  • RNNs, LSTMs, and GRUs
  • Feature extraction techniques
  • Transformer architecture deep dive
  • Attention mechanisms and text generation
  • Pre-training and fine-tuning strategies
  • LoRA, QLoRA, and parameter-efficient methods
  • DPO and RLHF
  • Model evaluation and benchmarking
  • Quantization techniques
  • Vector databases and embeddings
  • Document ingestion and chunking
  • RAG pipelines and orchestration
  • Evaluation frameworks
  • LLM APIs and inference optimization
  • Prompt engineering
  • Production serving (FastAPI, vLLM, TGI)
  • Monitoring and scaling
  • Introduction to diffusion processes
  • Stable Diffusion and ControlNet
  • Fine-tuning and guidance techniques
  • Vision-Language models
  • Image-text alignment
  • Creating custom multimodal models
  • Multimodal retrieval systems

🎯 Key Features

Core Capabilities

  • Large Language Models (LLMs)

    • Fine-tuning with LoRA, QLoRA, and full parameter training
    • Supervised Fine-Tuning (SFT), Direct Preference Optimization (DPO), and ORPO
    • Support for Llama 2/3, Mistral, Gemma, Phi-3, and custom architectures
    • Pre-training pipelines with DeepSpeed integration
  • Model Optimization & Quantization

    • 4-bit/8-bit quantization using BitsAndBytes
    • GPTQ, GGUF, AWQ, and ExLlamaV2 support
    • Memory-efficient inference for consumer hardware
  • Deployment Solutions

    • Production FastAPI server with streaming inference
    • Multi-worker deployment with load balancing
    • Health monitoring and error handling
    • Docker-ready containerization
  • Multimodal AI

    • Vision-Language models (IDEFICS, BLIP, LLaVA)
    • Image captioning and visual question answering
    • Cross-modal retrieval and search
  • Transformers Ecosystem

    • 118+ examples covering NLP, vision, audio, and time-series
    • Semantic segmentation, object detection, and classification
    • Protein folding and DNA sequence modeling

Production Infrastructure

  • Modern Python Packaging: pyproject.toml with uv for fast, reliable dependency management
  • Automated Build System: Comprehensive Makefile with self-documenting targets
  • Testing Framework: Pytest integration with coverage reporting
  • Code Quality: Black, Ruff, and MyPy for formatting, linting, and type checking
  • Documentation: MkDocs-ready structure for professional documentation
  • CI/CD Ready: Pre-commit hooks and automated quality checks

πŸ› οΈ Development

Code Quality

# Format code
make format

# Run linting
make lint

# Type checking
make type-check

# All pre-commit checks
make pre-commit

Testing

# Run tests
make test

# Run tests with coverage
make test-cov

# Run all quality checks
make check

Build and Package

# Clean build artifacts
make clean

# Lock dependencies
make lock-deps

# Update dependencies
make update-deps

πŸ“‹ Project Structure

Generative-AI-Course/
β”œβ”€β”€ src/                      # Main package source
β”œβ”€β”€ Deployment/               # Production FastAPI server
β”‚   β”œβ”€β”€ server.py            # Streaming inference server
β”‚   β”œβ”€β”€ client.py            # Client implementation
β”‚   └── requirements.txt     # Deployment dependencies
β”œβ”€β”€ trainer/                  # Training modules
β”‚   β”œβ”€β”€ sft.py               # Supervised fine-tuning
β”‚   β”œβ”€β”€ pretraining.py       # Pre-training pipeline
β”‚   └── requirements.txt     # Training dependencies
β”œβ”€β”€ Data-Preparation/        # 17 dataset creation notebooks
β”œβ”€β”€ Finetuning/             # 17 fine-tuning notebooks
β”œβ”€β”€ Quantization/           # 6 quantization notebooks
β”œβ”€β”€ Multimodal/             # 6 multimodal notebooks
β”œβ”€β”€ Transformers/           # 118+ transformer notebooks
β”œβ”€β”€ Tools/                  # 6 utility notebooks
β”œβ”€β”€ Docs/                   # Course documentation
β”œβ”€β”€ tests/                  # Test suite
β”œβ”€β”€ pyproject.toml          # Package configuration
β”œβ”€β”€ Makefile                # Build automation
└── LICENSE                 # Apache 2.0 License

πŸ”§ Configuration

Environment Setup

Create a .env file for API keys (optional):

# Hugging Face (for private models)
HF_TOKEN=your_huggingface_token

# Weights & Biases (for experiment tracking)
WANDB_API_KEY=your_wandb_key

# OpenAI (for some data preparation notebooks)
OPENAI_API_KEY=your_openai_key

GPU Configuration

Most notebooks auto-detect GPU. For manual configuration:

import torch
print(f"CUDA available: {torch.cuda.is_available()}")
print(f"CUDA devices: {torch.cuda.device_count()}")

🀝 Contributing

We welcome contributions! Whether it's:

  • πŸ› Bug fixes
  • ✨ New features or notebooks
  • πŸ“š Documentation improvements
  • πŸ§ͺ Test coverage
  • πŸ’‘ Example applications

How to Contribute

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run quality checks (make pre-commit)
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

πŸ“„ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

You can use this commercially - it's free for commercial and educational use!


πŸ‘€ Author

Ruslan Magana Vsevolodovna

Professional Data Scientist specializing in Generative AI, Large Language Models, and Production ML Systems.


πŸ™ Acknowledgments

This project builds upon the excellent work of:

  • Hugging Face for the Transformers library
  • The TRL team for training utilities
  • DeepSpeed and Accelerate teams
  • The open-source AI community

πŸ“Š Project Stats

  • 177+ Jupyter Notebooks: Comprehensive hands-on examples
  • 18 Python Modules: Production-ready implementations
  • 7 Course Modules: Complete curriculum
  • 1.2GB+ Resources: Models, datasets, and examples
  • Apache 2.0 Licensed: Free for commercial use

πŸŽ“ Skills You'll Master

Upon completing this course, you will master:

  • βœ… Large Language Model architecture and fine-tuning
  • βœ… Production deployment and optimization
  • βœ… Quantization and memory efficiency
  • βœ… Multimodal AI systems
  • βœ… RAG and vector databases
  • βœ… Modern ML engineering practices
  • βœ… Enterprise-grade code quality

For a detailed breakdown, see Essential Skills.


πŸ†˜ Support


πŸ—ΊοΈ Roadmap

  • Docker containerization
  • Kubernetes deployment examples
  • Additional model architectures (Claude, GPT-4, etc.)
  • More quantization formats
  • Extended multimodal examples
  • Production monitoring dashboards
  • Automated benchmarking suite

⭐ Star this repository if you find it helpful!

Made with ❀️ by Ruslan Magana

Ready to master Generative AI? Get Started β†’

About

This repository contains resources, labs, and notes from a comprehensive Generative AI course, covering topics such as Natural Language Processing, Large Language Models, and Responsible AI. It aims to help Data Scientists and enthusiasts learn and grow in the field of Generative AI.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages