GENAIGenerative AI
All Courses
overview

What is Generative AI?

Generative AI creates new content โ€” text, images, code, audio โ€” by learning statistical patterns from large amounts of training data. LLMs like GPT-4, Claude, and Gemini are the most widely used form today.

Key Concepts

ConceptPlain-English Meaning
TokenThe basic unit of text an LLM processes โ€” roughly 3โ€“4 characters per token
Context WindowMaximum tokens the model can "see" at once (e.g., 128k for Claude 3.5)
TemperatureControls randomness โ€” 0 = deterministic, 1+ = creative/random
HallucinationWhen the model generates plausible-sounding but incorrect facts
Foundation ModelA large pre-trained model that can be adapted to many tasks
In-Context LearningGuiding the model with examples in the prompt โ€” no retraining needed

Current Model Landscape (2026)

Claude Sonnet 4.6GPT-4oGemini 1.5 ProLlama 3.1MistralQwen

Interactive Notebook

โšก
Notebook: What is GenAI
Tokenisation, LLM landscape, temperature, cost estimation
First load ~30-60s ยท Saves automatically
Open Notebook

Quiz

Test your understanding -- 10 questions, 70% to pass.

Take Quiz
prompt patterns

Prompt Engineering

The art and science of writing prompts that reliably produce the output you want. No retraining required โ€” the right prompt can transform model behavior instantly.

Core Patterns

PatternWhen to useExample
Zero-shotSimple tasks with clear instructions"Summarize this in 3 bullet points."
Few-shotWhen you need format consistencyShow 2โ€“3 examples before the actual request
Chain of ThoughtMath, reasoning, multi-step problems"Think step by step before answering."
Role PromptingTone and expertise control"You are a senior ML engineer reviewing code."
Output FormatStructured output (JSON, table)"Return as JSON with keys: name, score, reason."
DelimitersPrevent prompt injectionWrap user input in <doc>...</doc>

Code Example โ€” OpenAI API

prompt_engineering.py
from openai import OpenAI

client = OpenAI()

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[
        {"role": "system", "content": "You are a Python code reviewer."},
        {"role": "user",   "content": f"Review this code:\n\n<code>\n{code}\n</code>"}
    ],
    temperature=0.2,
)
print(response.choices[0].message.content)

Interactive Notebook

โšก
Notebook: Prompt Engineering
Zero-shot, few-shot, CoT, ReAct, role prompting
First load ~30-60s ยท Saves automatically
Open Notebook

Quiz

Test your understanding -- 10 questions, 70% to pass.

Take Quiz
074 ยท postsilicon-validation-rag + chromadb-rag-tutorials

RAG โ€” Retrieval-Augmented Generation

Ground LLM responses in your own documents. RAG retrieves relevant chunks from a vector database and injects them into the prompt โ€” reducing hallucination and enabling domain-specific Q&A.

RAG Architecture

Indexing Pipeline (offline)

Documents
โ†’
Chunking
โ†’
Embeddings
โ†’
Vector DB

Query Pipeline (real-time)

User Query
โ†’
Embed Query
โ†’
Similarity Search
โ†’
Top-k Chunks
โ†’
LLM + Context
โ†’
Grounded Answer

Code Example

rag_pipeline.py
import chromadb
from openai import OpenAI

client = OpenAI()
chroma = chromadb.Client()
collection = chroma.get_or_create_collection("docs")

def embed(text):
    res = client.embeddings.create(input=text, model="text-embedding-3-small")
    return res.data[0].embedding

def rag_query(question):
    q_vec = embed(question)
    results = collection.query(query_embeddings=[q_vec], n_results=3)
    context = "\n".join(results["documents"][0])

    resp = client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[{"role": "user",
                   "content": f"Context:\n{context}\n\nQ: {question}"}]
    )
    return resp.choices[0].message.content

๐Ÿ’ก Document Q&A Assistant

This is the core pattern behind project-01 on this platform. Build a full RAG system with document upload, ChromaDB, and FastAPI backend.

Build This Project โ†’

Interactive Notebook

โšก
Notebook: RAG
Chunking, TF-IDF retrieval, ChromaDB, RAGAS
First load ~30-60s ยท Saves automatically
Open Notebook

Quiz

Test your understanding -- 10 questions, 70% to pass.

Take Quiz
075 ยท domain-llm-finetuning

Fine-Tuning LLMs

Adapt a pre-trained LLM to your domain or style using a small labeled dataset. LoRA and PEFT make this feasible on consumer hardware.

When Fine-Tuning is Worth It

โœ… Fine-tune when:
  • You need consistent tone/format that prompting can't achieve
  • Domain-specific terminology is critical
  • You have 500+ high-quality examples
โŒ Use RAG instead when:
  • You need up-to-date or changing information
  • You want to cite sources
  • Your dataset is <100 examples

LoRA Key Idea

Instead of updating all model weights, LoRA decomposes the weight update matrix into two small low-rank matrices. This dramatically reduces trainable parameters (often by 10,000ร—) while achieving similar quality to full fine-tuning.

Interactive Notebook

โšก
Notebook: Fine-Tuning
DistilBERT, LoRA, instruction tuning
First load ~30-60s ยท Saves automatically
Open Notebook

Quiz

Test your understanding -- 10 questions, 70% to pass.

Take Quiz
chroma, pinecone, supabase pgvector

Embeddings & Vector Databases

Convert text, images, and code into dense numerical vectors. Use vector similarity search to find semantically similar content โ€” the foundation of RAG, recommendation systems, and semantic search.

Vector DB Comparison

DatabaseBest forNotes
ChromaDBLocal dev, prototypesEasy to run, Python-native
PineconeProduction, managedScalable, fully managed cloud
Supabase pgvectorPostgres-based appsSQL + vector search in one DB
QdrantOpen-source productionPayload filtering, self-hosted
WeaviateMulti-modal searchGraphQL API, schemas

Interactive Notebook

โšก
Notebook: Embeddings
Cosine similarity, semantic search, ChromaDB, Pinecone
First load ~30-60s ยท Saves automatically
Open Notebook

Quiz

Test your understanding -- 10 questions, 70% to pass.

Take Quiz
evaluation patterns

LLM Evaluation

How do you know your LLM application is working? Evaluation is one of the hardest problems in GenAI engineering. Multiple strategies are needed โ€” no single metric tells the full story.

Evaluation Strategies

StrategyWhat it measuresWhen to use
BLEU / ROUGEN-gram overlap with reference textTranslation, summarization with gold references
Human EvaluationRelevance, coherence, helpfulnessGold standard, but expensive
LLM-as-JudgeUse a strong LLM to score outputsScalable, automated, can use Likert or pairwise
RAG-SpecificFaithfulness, answer relevance, context recallRAGAs framework
Task-specificF1, accuracy, exact match on benchmarksClassification, extraction tasks

Interactive Notebook

โšก
Notebook: LLM Evaluation
BLEU, ROUGE-1, LLM-as-judge, RAGAS framework
First load ~30-60s ยท Saves automatically
Open Notebook

Quiz

Test your understanding -- 10 questions, 70% to pass.

Take Quiz
huggingface ecosystem

HuggingFace Ecosystem

The open-source hub for ML models, datasets, and deployment. The transformers library is the standard for accessing pre-trained models in Python.

Key Libraries

LibraryPurpose
transformersLoad and run pre-trained models (BERT, GPT-2, Llama, etc.)
datasetsAccess 10,000+ public datasets with one line of code
tokenizersFast tokenization library used by all HF models
PEFTLoRA, prefix tuning, and other efficient fine-tuning methods
SpacesDeploy ML demos (Gradio/Streamlit) for free on HF
Inference APICall HF models via REST API without deploying yourself

Quick Start

hf_pipeline.py
from transformers import pipeline

# Sentiment analysis
clf = pipeline("text-classification")
result = clf("This project guide is excellent!")

# Text generation
gen = pipeline("text-generation", model="gpt2")
text = gen("Machine learning is", max_new_tokens=50)

Interactive Notebook

โšก
Notebook: HuggingFace
pipeline API, datasets, Gradio, free Inference API
First load ~30-60s ยท Saves automatically
Open Notebook

Quiz

Test your understanding -- 10 questions, 70% to pass.

Take Quiz
competition strategy

Kaggle with LLMs

How to approach NLP and LLM-based Kaggle competitions โ€” from EDA to submission, ensembling, and using free GPU quota effectively.

Kaggle LLM Competition Workflow

  1. EDA โ€” Understand label distribution, text length, class balance
  2. Baseline โ€” TF-IDF + Logistic Regression or fine-tuned bert-base
  3. LLM features โ€” Use a frozen LLM to generate embeddings or synthetic labels
  4. Fine-tune โ€” Fine-tune deberta-v3, roberta, or llama3 on task
  5. Ensemble โ€” Blend predictions from multiple models
  6. Submit โ€” Iterate on public LB, avoid public LB overfitting

Interactive Notebook

โšก
Notebook: Kaggle with LLMs
EDA, DeBERTa, K-fold CV, ensemble, competition tips
First load ~30-60s ยท Saves automatically
Open Notebook

Quiz

Test your understanding -- 10 questions, 70% to pass.

Take Quiz