An interactive journey through Artificial Intelligence, Large Language Models, AI Agents, Fine-Tuning, RAG, and more โ with visual diagrams, real examples, and hands-on demos.
Follow this roadmap from AI fundamentals to advanced techniques
The science of making machines think, learn, and act intelligently
Artificial Intelligence (AI) is a branch of computer science focused on building systems that can perform tasks typically requiring human intelligence โ such as understanding language, recognizing images, making decisions, and learning from experience.
Turing proposes the Turing Test โ a benchmark for machine intelligence.
The term "Artificial Intelligence" is coined. The field is officially born.
One of the first natural language processing programs created at MIT.
IBM's chess computer defeats the world champion, showcasing computational AI power.
AlexNet wins ImageNet, igniting the deep learning era with neural networks.
Google's "Attention Is All You Need" paper revolutionizes NLP and AI.
OpenAI releases ChatGPT, bringing LLMs to mainstream adoption worldwide.
AI agents, reasoning models, and multimodal systems become the frontier.
Specialized in one task. Most AI today falls here.
Human-level intelligence across all domains.
Surpasses all human intelligence combined.
The model learns from labeled data โ input-output pairs where the correct answer is provided during training.
The model finds hidden patterns in data without any labels. It discovers structure on its own.
An agent learns by interacting with an environment, receiving rewards or penalties for its actions.
The model creates its own labels from data โ e.g., predicting the next word in a sentence. This is how most LLMs are trained.
The engines behind modern AI โ understanding how they work
A Large Language Model is a deep learning model trained on massive amounts of text data. It learns statistical patterns of language to predict, generate, and understand text. Think of it as a powerful autocomplete that has read most of the internet.
At the heart of every modern LLM is the Transformer, introduced in the 2017 paper "Attention Is All You Need" by Google.
Converts words/tokens into numerical vectors the model can process
Adds position information so the model knows word order
Allows each word to "look at" every other word to understand context
Processes attention output through neural network layers
Produces probability distribution over vocabulary for next token
Self-attention lets each word attend to all others. Click on words to see attention patterns:
๐ Click any word to see what it "attends to" (which other words help determine its meaning)
LLMs don't read words โ they read tokens. A token can be a word, part of a word, or a character.
Model is trained on massive text corpus (trillions of tokens from books, websites, code). It learns to predict the next word.
Model is trained on high-quality demonstration data โ human-written examples of helpful, accurate responses.
Humans rank model outputs. A reward model is trained on these preferences, then used to improve the LLM via reinforcement learning.
Model sizes have grown exponentially. Parameters are the learned weights of the model.
Click to learn more โ
Controls randomness. Low (0.0) = deterministic, factual. High (1.0+) = creative, diverse. Like adjusting how "adventurous" the model is.
Click to learn more โ
Maximum input+output tokens. GPT-4 Turbo: 128K tokens. Claude 3: 200K tokens. Gemini 1.5: 1M+ tokens. Larger = more context the model can "remember."
Click to learn more โ
When LLMs generate plausible-sounding but incorrect information. They predict likely text, not truth. This is why RAG and grounding are important.
Click to learn more โ
The art of crafting inputs to get better outputs. Techniques include: few-shot examples, chain-of-thought, role-playing, and structured prompts.
Click to learn more โ
Using a trained model to generate outputs. Training is expensive and rare. Inference happens every time you chat with an AI โ it's the production usage.
Click to learn more โ
Models that handle multiple data types: text + images + audio + video. GPT-4o, Gemini, and Claude 3 are multimodal โ they can "see" and "hear."
Understanding the AI model landscape and choosing the right approach
Meta's flagship open model. Highly capable, commercially usable.
European AI lab. Efficient MoE architecture. Strong performance per size.
Chinese lab. Strong reasoning. Competitive with frontier closed models.
Fully open models with training data transparency.
Small but mighty. Designed for edge and mobile deployment.
Multilingual. Strong coding and math capabilities.
Market leader. Multimodal. o-series adds chain-of-thought reasoning.
Constitutional AI. Excellent at coding, analysis, and long context tasks.
Natively multimodal. 1M+ token context. Deep Google integration.
Elon Musk's AI. Real-time information. Integrated with X/Twitter.
Performance across common benchmarks (illustrative scores, higher is better):
What's your top priority?
You need data privacy. Can you run models on your own servers?
You want peak performance. What's your use case?
You want lowest cost. What scale are you working at?
You want full customization. What kind?
Use Llama 3.1 70B or Mistral Large on your own GPU infrastructure. Full privacy, no data leaves your servers. Tools: vLLM, Ollama, or TGI for serving.
Use Azure OpenAI Service or AWS Bedrock with data processing agreements. Or use Ollama locally for smaller models (Phi-3, Llama 8B).
Use GPT-4o / o3 or Claude Opus 4 for the best general reasoning. For math/science, Gemini 2.0 is strong. DeepSeek R1 (open) is a competitor.
Claude Opus 4 leads for coding. GPT-4o and DeepSeek Coder (open) are excellent. For fast completion: Codestral (Mistral) or Qwen Coder.
GPT-4o and Gemini 2.0 lead in vision+text. For open models: LLaVA or Llama 3.2 Vision.
Use Ollama to run models locally for free. Try Llama 3.1 8B, Phi-3, or Mistral 7B. For cloud: free tiers of ChatGPT, Claude, or Gemini.
Run Llama 3.1 70B or Mixtral 8x7B on cloud GPUs (Together AI, Fireworks, Replicate). Much cheaper than closed API pricing at scale.
Start with Llama 3.1 or Mistral. Use LoRA/QLoRA for efficient fine-tuning. Tools: Hugging Face, Axolotl, Unsloth. See the Fine-Tuning chapter below!
Any model works with RAG! Use LangChain or LlamaIndex with a vector database (Pinecone, Chroma, Weaviate). See the RAG chapter below!
Autonomous systems that perceive, reason, plan, and act
An AI Agent is an autonomous system that uses an LLM as its "brain" to perceive its environment, make decisions, use tools, and take actions to achieve goals โ often in multi-step workflows without constant human guidance.
Reasoning & Decision Making
User input, environment observation, tool outputs
Break tasks into steps, create strategies
Short-term (context) + Long-term (vector DB)
APIs, code execution, web search, databases
Execute decisions, interact with world
Analyze input, reason about the task, and plan next action
Execute a tool call, write code, or generate a response
Review the result, check if the goal is achieved
User: "What's the weather in Tokyo and should I bring an umbrella?"
Call external APIs and tools to complete tasks.
Multi-turn dialogue with memory and personality.
Write, debug, and refactor code autonomously.
Gather, analyze, and synthesize information.
Multiple specialized agents collaborating.
Control a computer like a human user.
Most popular framework. LangGraph adds stateful, graph-based agent workflows.
langchain.com โMulti-agent conversation framework. Agents debate and collaborate.
autogen docs โProduction-ready framework focused on reliability and observability.
GitHub โCustomizing pre-trained models for your specific needs
Fine-tuning is the process of taking a pre-trained model and further training it on a smaller, specialized dataset to adapt it for specific tasks, domains, or behaviors. Think of it as teaching a well-educated generalist to become a domain expert.
Cheapest & fastest. Craft better prompts with examples.
Effort: Low | Cost: FreeAdd external knowledge without changing the model.
Effort: Medium | Cost: LowModify model weights for specialized behavior.
Effort: High | Cost: Medium-HighBuild entire model. Only for major labs.
Effort: Extreme | Cost: $MillionsUpdates all model parameters. Most powerful but most expensive.
Pre-trained Model (all params)
โ
โผ Train on your data
โ
Updated Model (all params modified)
โข Requires: Full GPU memory (VRAM) for model + gradients + optimizer
โข Llama 70B: ~140GB VRAM minimum (4x A100 80GB)
โข Best for: Large datasets, significant behavior changes
Freezes original weights, trains small "adapter" matrices. 99%+ fewer trainable parameters.
Original Weight Matrix W (frozen) โโโ W ร input
+
Low-Rank Matrices AรB (trainable) โโ (AรB) ร input
โข Original: 4096ร4096 = 16.7M parameters
โข LoRA (rank 8): 4096ร8 + 8ร4096 = 65K parameters
โข 99.6% parameter reduction!
โข Adapters are tiny (~10-100MB) and swappable
from peft import LoraConfig, get_peft_model
lora_config = LoraConfig(
r=8, # Rank of adapter
lora_alpha=16, # Scaling factor
target_modules=["q_proj", "v_proj"], # Which layers to adapt
lora_dropout=0.05,
task_type="CAUSAL_LM"
)
model = get_peft_model(base_model, lora_config)
model.print_trainable_parameters()
# Output: trainable params: 4,194,304 || all params: 6,738,415,616 || 0.06%
Combines LoRA with 4-bit quantization. Fine-tune a 70B model on a single GPU!
Model: Llama 2 70B
Full Fine-Tuning: ~140 GB VRAM (4ร A100)
LoRA (16-bit): ~70 GB VRAM (2ร A100)
QLoRA (4-bit + LoRA): ~20 GB VRAM (1ร A100 or RTX 4090!)
How: Model weights quantized to 4-bit (NF4)
while LoRA adapters train in 16-bit precision
Align models with human preferences using feedback or direct preference optimization.
Step 1: Collect human preference data
โ Pairs of (prompt, chosen_response, rejected_response)
Step 2 (RLHF): Train a reward model
โ Then use PPO to optimize the LLM against the reward model
Step 2 (DPO): Skip the reward model
โ Directly optimize the LLM on preference pairs
โ Simpler, more stable, increasingly preferred
Tools: trl library (Hugging Face), TRL's DPOTrainer
Format your data as instruction-response pairs. Typically need 100-10,000+ high-quality examples.
{
"instruction": "Summarize this medical report",
"input": "Patient presents with acute bronchitis...",
"output": "The patient has acute bronchitis with symptoms..."
}
Pick a base model (e.g., Llama 3.1 8B) and PEFT method (LoRA/QLoRA). Consider model size vs. available hardware.
Set hyperparameters: learning rate (~2e-4), batch size, epochs (1-3), LoRA rank, target modules.
Run training, monitor loss curves. Should see decreasing, smooth loss. Watch for overfitting.
Test on held-out data. Merge LoRA adapters into base model. Deploy using vLLM, TGI, or Ollama.
Grounding AI responses in your own data
Retrieval-Augmented Generation (RAG) is a technique that enhances LLM responses by first retrieving relevant information from external knowledge bases, then including that context in the prompt. This grounds the AI's answers in factual, up-to-date data โ reducing hallucinations and enabling domain-specific knowledge without fine-tuning.
Embeddings convert text into numerical vectors where similar meanings are close together in vector space.
In real embeddings, each text becomes a vector of 768-3072 numbers. Similar texts have vectors pointing in similar directions (high cosine similarity).
Combine vector (semantic) search with keyword (BM25) search for better retrieval.
Use a cross-encoder model to re-rank retrieved chunks by relevance after initial retrieval.
Generate multiple query variations, retrieve for each, then combine results.
An AI agent that decides when and what to retrieve, can chain multiple searches.
Build a knowledge graph from documents, traverse relationships for richer context.
Evaluate retrieved docs for relevance, fall back to web search if corpus is insufficient.
from langchain_community.document_loaders import PyPDFLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain_openai import OpenAIEmbeddings, ChatOpenAI
from langchain_community.vectorstores import Chroma
from langchain.chains import RetrievalQA
# 1. Load and chunk documents
loader = PyPDFLoader("company_handbook.pdf")
docs = loader.load()
splitter = RecursiveCharacterTextSplitter(
chunk_size=1000,
chunk_overlap=200
)
chunks = splitter.split_documents(docs)
# 2. Create embeddings and store in vector DB
embeddings = OpenAIEmbeddings(model="text-embedding-3-small")
vectorstore = Chroma.from_documents(chunks, embeddings)
# 3. Create retrieval chain
llm = ChatOpenAI(model="gpt-4o", temperature=0)
qa_chain = RetrievalQA.from_chain_type(
llm=llm,
retriever=vectorstore.as_retriever(search_kwargs={"k": 5}),
return_source_documents=True
)
# 4. Ask questions!
result = qa_chain.invoke({"query": "What is our PTO policy?"})
print(result["result"])
print("Sources:", [doc.metadata for doc in result["source_documents"]])
Learn by doing โ hands-on experiments to solidify your understanding
See how temperature affects LLM output. Adjust the slider and generate text:
Compare different prompting strategies on the same task:
Classify this review as positive or negative:
"The battery life is amazing but the screen is too dim."
Classify these reviews:
"Great camera!" โ Positive
"Terrible build quality" โ Negative
"Good value for money" โ Positive
Now classify: "The battery life is amazing but the screen is too dim."
Classify this review. Think step by step:
1) Identify positive aspects
2) Identify negative aspects
3) Weigh overall sentiment
Review: "The battery life is amazing but the screen is too dim."
See how data flows through a neural network. Click neurons to activate them and watch signals propagate:
Type two sentences and see how similar they are in embedding space (simulated cosine similarity):
Estimate monthly costs for different AI models based on your usage:
1/6: What architecture powers most modern LLMs?
2/6: What does RAG stand for?
3/6: Which technique reduces fine-tuning parameters by 99%+?
4/6: Which is an open-source model?
5/6: In an agent loop, what comes after "Think"?
6/6: What reduces hallucinations by grounding AI in external data?