🤖✨ Generative AI Lab
From "reconstruct this digit" to "answer my question like a wise oracle" — the full generative arc


12 experiments tracing the entire family tree of Generative AI — from a humble autoencoder to a GPT-powered Q&A bot. 🌳
📖 What's This All About?
This lab is basically a guided tour through the evolution of Generative AI — starting with models that just reconstruct what you fed them, and ending with a Large Language Model answering your questions like it's got somewhere to be.
Along the way: probabilistic latent spaces, adversarial rivalries, artistic style theft (the legal kind), and a transformer built from absolute scratch.
- 🧬 Autoencoders & Variational Autoencoders (VAEs)
- ⚡ Restricted Boltzmann Machines (energy-based models)
- 📈 Autoregressive models (FVSBN, NADE)
- 🎭 GANs — Vanilla & Progressive
- 🎨 Neural Style Transfer
- 🧠 Transformer language modeling from scratch
- ✍️ GPT-2 fine-tuning
- 💬 OpenAI API-powered Question Answering
🧪 The Experiments
| Week/Exp | Model | Core Idea | Dataset |
|---|
| Week 1 | Autoencoder | Learn to compress & reconstruct | MNIST |
| Week 2 | Restricted Boltzmann Machine | Energy-based feature learning | — |
| Week 3 | Variational Autoencoder (VAE) | Probabilistic latent generation | Fashion-MNIST |
| Week 4 | FVSBN | Autoregressive sequence modeling | AirPassengers · Bitcoin |
| Week 5 | NADE | Autoregressive density estimation | — |
| Week 6 | Improved NADE Variants | Better training & sampling | — |
| Exp 7 | Vanilla GAN | Adversarial image generation | CIFAR-10 |
| Exp 8 | Progressive GAN | High-res image synthesis | LSUN |
| Exp 9 | Neural Style Transfer | Content + style fusion | CIFAR-10 |
| Exp 10 | Transformer LM | Attention-based language modeling | WikiText-2 |
| Exp 11 | GPT-2 Fine-Tuning | Sentiment + text generation | IMDB Reviews |
| Exp 12 | OpenAI GPT Q&A | Prompt engineering + inference | — |
🧬 Week 1 — "Squish It, Then Un-Squish It"
Autoencoder
The gateway drug of generative modeling: compress an image into a latent code, then rebuild it.
Workflow: Load MNIST → Preprocess → Encode → Learn latent representation → Decode → Reconstruct → Visualize
Applications: Image compression · Feature extraction · Noise reduction
⚡ Week 2 — "Energy, But Make It a Neural Network"
Restricted Boltzmann Machine (RBM)
An unsupervised, energy-based model that learns hidden representations via Contrastive Divergence.
Covers: Contrastive Divergence · Hidden Layer Representation · Energy-Based Modeling
Applications: Recommendation systems · Representation learning · Dimensionality reduction
🎲 Week 3 — "Autoencoder, But It Rolls Dice"
Variational Autoencoder (VAE)
Adds a probabilistic twist: instead of a fixed latent code, you get a distribution to sample from.
Workflow: Encoder → Latent Distribution → Reparameterization Trick → Decoder → Sample & Reconstruct
Applications: Image generation · Representation learning · Compression
📈 Week 4 — "Predicting the Next Thing, One Step at a Time"
Fully Visible Sigmoid Belief Network (FVSBN)
Autoregressive probabilistic modeling applied to real sequential data — including, yes, Bitcoin prices.
Datasets: AirPassengers Time Series · Bitcoin Price Dataset
Applications: Financial forecasting · Demand prediction · Sequential data modeling
🎯 Week 5 — "Density Estimation, Seriously This Time"
Neural Autoregressive Distribution Estimator (NADE)
Models high-dimensional probability distributions one conditional at a time.
Covers: Autoregressive density estimation · Likelihood estimation · Sequential prediction
Applications: Density estimation · Image modeling · Data generation
🔧 Week 6 — "NADE, Now With Upgrades"
Improved NADE Variants
Refining the NADE recipe with better training strategies, sampling methods, and evaluation.
Covers: Improved training · Better sampling · Model comparison · Performance evaluation
🎭 Experiment 7 — "Generator vs Discriminator, the Rematch"
Vanilla GAN
Two networks, one adversarial standoff, and a stream of increasingly convincing fake CIFAR-10 images.
Workflow: Generator ↔ Discriminator → Adversarial training → Fake image generation
Applications: Image generation · Data augmentation · Synthetic datasets
📐 Experiment 8 — "Same GAN, But It Levels Up"
Progressive GAN (ProGAN)
Growing the GAN progressively — low resolution first, then scaling up — for stable, high-res image synthesis.
Covers: Progressive growing · Stable GAN training · Multi-resolution learning
Applications: High-resolution image generation · Digital art · AI-generated content
🎨 Experiment 9 — "Borrowing Van Gogh's Brush, Digitally"
Neural Style Transfer
Blend a content image with a style image using feature extraction and a carefully balanced loss function.
Workflow: Content image + Style image → Feature extraction → Style loss + Content loss → Optimize → Stylized output
Applications: Artistic image generation · Image editing · Creative AI
🧠 Experiment 10 — "Building a Transformer From Actual Scratch"
Transformer Language Model
No shortcuts here — positional encoding, multi-head attention, and encoder/decoder layers, all hand-assembled.
Covers: Positional Encoding · Multi-Head Attention · Feed Forward Networks · Encoder/Decoder Layers
Metrics: Training Loss · Validation Loss · Perplexity
Applications: Language modeling · Text prediction · Machine translation
✍️ Experiment 11 — "GPT-2 Learns Your Vibe"
GPT-2 Fine-Tuning
Fine-tuning a pretrained GPT-2 for both sentiment classification and text generation on movie reviews.
Workflow: Tokenize → Load GPT-2 → Fine-tune → Classify sentiment → Generate text → Evaluate
Applications: Sentiment analysis · Content generation · Conversational AI
💬 Experiment 12 — "Ask and You Shall Receive (via API)"
OpenAI GPT Question Answering
A practical Q&A application built on prompt engineering and the OpenAI API — no training required, just good prompts.
Workflow: User question → Prompt engineering → GPT response → Display answer
Applications: AI chatbots · Intelligent assistants · Customer support · Educational tutors
🛠️ Tech Stack
| Category | Tools |
|---|
| Core |  |
| Deep Learning |  |
| Transformers & LLMs |  |
| Utils |  |
📂 Datasets Used
| Dataset | Used For | Vibe |
|---|
| 🔢 MNIST | Autoencoder | "Digit, but blurrier, but still recognizable" |
| 👕 Fashion-MNIST | VAE | "Clothes, probabilistically" |
| ✈️ AirPassengers | Time Series Modeling | "Old but gold time-series classic" |
| 💰 Bitcoin Dataset | Autoregressive Prediction | "Predicting chaos, one step at a time" |
| 🖼️ CIFAR-10 | GAN & Style Transfer | "Tiny images, big adversarial energy" |
| 🌆 LSUN | Progressive GAN | "Scenes worth generating at high-res" |
| 📖 WikiText-2 | Transformer LM | "Wikipedia, but for training attention" |
| 🎬 IMDB Reviews | GPT-2 Fine-Tuning | "Teaching GPT-2 to judge movies" |
📊 The Complete Workflow
flowchart LR
A[📥 Data Collection] --> B[🧹 Preprocessing]
B --> C[🏗️ Model Development]
C --> D[🏋️ Training]
D --> E[🔮 Inference]
C -.-> C1[Autoencoder / VAE / RBM]
C -.-> C2[FVSBN / NADE]
C -.-> C3[GAN / ProGAN]
C -.-> C4[Style Transfer]
C -.-> C5[Transformer / GPT-2]
C -.-> C6[OpenAI API]
1. Data Collection
Download benchmark datasets → Load image and text data.
2. Data Preprocessing
Normalization → Tokenization → Image resizing → Batch preparation.
3. Model Development
Autoencoder, RBM, VAE, FVSBN, NADE, GAN, Progressive GAN, Neural Style Transfer, Transformer, GPT-2.
4. Model Training
Forward propagation → Loss computation → Backpropagation → Optimization → Validation.
5. Inference
Image generation · Text generation · Question answering · Style transfer · Sentiment prediction.
📁 Project Structure
Generative-AI-Lab/
│
├── GENAILAB.ipynb # All 12 experiments, start to finish
├── README.md # You are here 👋
├── requirements.txt # Dependencies
└── datasets/ # Local dataset storage
⚙️ Quick Start
1️⃣ Clone it
git clone https://github.com/SiriNandinii/Generative-AI-Lab.git
cd Generative-AI-Lab
2️⃣ Install the goodies
pip install torch torchvision torchaudio
pip install transformers datasets
pip install openai
pip install matplotlib numpy
3️⃣ Fire up Jupyter
jupyter notebook
4️⃣ Open & run
GENAILAB.ipynb → Run All Cells ▶️
🔑 Heads up: Experiment 12 needs an OpenAI API key set as an environment variable. GANs and Transformers appreciate a GPU too.