Master AI fundamentals with hands-on labs covering LLM prompting, model fine-tuning, RAG architectures, and AI safety. Build real-world AI solutions through interactive scenarios.
GenAI Foundation Labs - Module 1
Start your AI journey with fundamental concepts and hands-on implementation across major AI platforms and frameworks.
Lab 1: Prompt Engineering Fundamentals
LLM / Beginner
Scenario: Building an AI Customer Support Agent
TechSupport Inc. wants to deploy an AI-powered customer support agent. Your task is to craft effective prompts that guide the LLM to provide accurate, helpful, and safe responses. Learn prompt structure, system messages, few-shot learning, and output formatting techniques.
Learning Objectives:
System Prompts: Design effective system messages for role-based behavior
Few-Shot Learning: Provide examples to guide model output format
Chain-of-Thought: Implement reasoning chains for complex queries
Output Control: Structure responses with JSON and markdown formatting
AI Prompt Builder
ChatGPT / Claude Style
⏳ Pending
⏳ Pending
⏳ Pending
⏳ Pending
⏳ Pending
⏳ Pending
Agent response will appear here after testing...
Live Prompt Preview
# System Prompt(Not configured yet)# Examples(No examples added)# Settings
Reasoning: Standard
Output: Plain Text
Guardrails: None
Progress:0/6 tasks completed
Score: 0/100
0%
Lab Completed!
Excellent prompt engineering!
Lab 2: RAG Architecture Implementation
RAG / Intermediate
Scenario: Building a Knowledge Base Q&A System
LegalTech Corp needs an AI system that can answer questions about their 10,000+ legal documents. Build a Retrieval-Augmented Generation (RAG) pipeline that retrieves relevant documents and generates accurate answers with citations.
Learning Objectives:
Document Chunking: Split documents into optimal chunk sizes
Vector Embeddings: Convert text to semantic vectors
Context Injection: Augment prompts with retrieved knowledge
📋 Step-by-Step Instructions
Step 1: Initialize Vector Database
🎯 Goal: Set up a vector store to hold document embeddings
📝 What is a Vector Database?
A vector database stores text as high-dimensional vectors (embeddings). Similar text = similar vectors. This enables semantic search - finding relevant content by meaning, not just keywords.
💻 Set Embedding Model: set_embedding_model text-embedding-3-small
🔍 Popular Vector DBs:
• Pinecone - Managed, scalable
• Chroma - Open source, local
• Weaviate - Feature-rich
• FAISS - Facebook's library, fast
💡 Pro Tip: text-embedding-3-small is cost-effective. Use text-embedding-3-large for higher accuracy on complex documents.
Step 2: Configure Document Chunking
🎯 Goal: Split documents into optimal-sized pieces for retrieval
📝 Why Chunking Matters:
LLMs have context limits. Chunking breaks documents into digestible pieces. Too small = lost context. Too large = irrelevant noise. Finding the sweet spot is crucial!
💻 Set Chunk Size: set_chunk_size 512
💻 Set Overlap (prevents cutting sentences): set_chunk_overlap 50
💡 Chunk Strategies: "fixed" = split by token count, "semantic" = split by meaning/paragraphs, "recursive" = tries multiple separators.
📊 Rule of thumb: 512 tokens for precise Q&A, 1024 for summarization, 256 for FAQ-style retrieval.
Step 3: Ingest Documents
🎯 Goal: Process documents, create embeddings, store in vector DB
📝 What Happens During Ingestion:
1. Documents are loaded and parsed
2. Text is split into chunks
3. Each chunk is converted to a vector (embedding)
4. Vectors + metadata stored in database
💻 Create the Chain: create_rag_chain --retriever vectordb --llm gpt-4 --template "Answer based on context: {context}\n\nQuestion: {query}"
💡 Template Tips: Include "If the answer is not in the context, say 'I don't know'" to reduce hallucinations!
🎓 Exam Tip: Chain types: "stuff" (all chunks in one prompt), "map_reduce" (process chunks separately), "refine" (iteratively improve).
Step 6: Test RAG System
🎯 Goal: Verify the system retrieves and answers correctly
💻 Run a Test Query: query_rag "What are the liability limitations in contract #A-2024-001?"
💻 Inspect Retrieved Chunks: show_retrieved_chunks
✅ What to Verify:
• Are retrieved chunks relevant?
• Does the answer cite sources?
• Is the response accurate to the context?
• Are hallucinations avoided?
🎓 Learning Checkpoint: Can you explain the full RAG flow? Query → Embed → Search → Retrieve → Augment Prompt → Generate → Return!
⛔ Common Mistake: Don't skip reranking for production systems - it dramatically improves answer quality!
RAG Pipeline Console
rag-lab@ai:~$
Progress:0/6 tasks completed
Score: 0/100
0%
Lab Completed!
Great RAG implementation!
Lab 3: Model Fine-Tuning Basics
Fine-Tuning / Intermediate
Scenario: Custom Model for Medical Terminology
HealthAI needs a model fine-tuned on medical terminology for accurate clinical note summarization. Learn to prepare training data, configure fine-tuning parameters, and evaluate model performance.
Training Monitoring: Track loss and validation metrics
Model Evaluation: Test fine-tuned model performance
📋 Step-by-Step Instructions
Step 1: Prepare Training Data
🎯 Goal: Validate your training dataset format and quality
📝 Training Data Format:
Fine-tuning requires JSONL format with conversation structure:
{"messages": [{"role": "system", "content": "..."}, {"role": "user", "content": "..."}, {"role": "assistant", "content": "..."}]}
💻 Validate Data File: validate_jsonl ./training_data/medical_notes.jsonl
💻 View Data Statistics: show_data_stats
🔍 Quality Checklist:
• Minimum 50-100 examples (500+ recommended)
• Consistent format across examples
• High-quality, accurate responses
• Diverse coverage of use cases
🎯 Goal: Set up hyperparameters for optimal training
📝 Key Hyperparameters:
• Epochs: How many times to iterate through data
• Learning Rate: How fast the model adapts
• Batch Size: Examples processed together
💻 Set Hyperparameters: set_hyperparams --epochs 3 --learning_rate 0.0001 --batch_size 4
💡 Epoch Guide: 1-2 for large datasets, 3-4 for medium, 5+ for small. Too many = overfitting!
💰 Cost Estimate: ~$0.008/1K tokens for training. A 5000-example dataset costs roughly $10-20.
Step 3: Start Training
🎯 Goal: Launch the fine-tuning job and monitor progress
📝 What Happens During Training:
1. Model loads your training data
2. Weights are adjusted based on examples
3. Loss is calculated after each batch
4. Model checkpoint saved after each epoch
💻 Start the Training Job: start_training
💻 Watch Progress in Real-Time: watch_training_progress
⏱️ Training Time: Typically 10-30 minutes for small datasets, up to several hours for large ones.
Step 4: Monitor Training Metrics
🎯 Goal: Analyze training metrics to ensure model is learning
📝 Key Metrics to Watch:
• Training Loss: Should decrease over epochs
• Validation Loss: Should track training loss
• If val loss increases while train decreases = overfitting!
✅ Good Signs: Smooth loss curve, val loss close to train loss, final loss < 0.1
⚠️ Warning Signs: Loss spikes, val loss diverging from train, loss not decreasing
Step 5: Deploy Fine-Tuned Model
🎯 Goal: Make your trained model available for inference
📝 Deployment Considerations:
• Model ID is unique to your fine-tuned version
• Inference costs same as base model
• Can be used via same API endpoints
💻 Deploy the Model: deploy_model --model-id ft:gpt-3.5-turbo:medical:2024
💡 Pro Tip: Keep your base model available for A/B testing. Compare fine-tuned vs base on real queries!
Step 6: Test Fine-Tuned Model
🎯 Goal: Validate model performance on real-world inputs
💻 Test with Domain Input: test_model "Summarize: Patient presents with acute myocardial infarction..."
💻 Compare Base vs Fine-Tuned: compare_base_vs_finetuned
✅ Evaluation Criteria:
• Domain-specific terminology accuracy
• Response format consistency
• Factual correctness
• Appropriate tone and style
🎓 Learning Checkpoint: When to fine-tune vs. use prompting? Fine-tune for: consistent format, domain terminology, style. Use prompting for: flexibility, quick iteration.
📊 Production Tip: Set up automated evaluation with held-out test set. Track accuracy, latency, and user feedback over time.