AI/ML - Local LLMs, Vector Databases & RAG
Status: Active
Last Updated: 2026-08-26
Category: Artificial Intelligence & Machine Learning
Prerequisites: kb/basics/, kb/containers/docker-basics
Tags: ai, ml, llm, ollama, vector-db, rag, embeddings, fine-tuning, self-hosted
Summary
Run your own AI infrastructure with local LLMs (Ollama), vector databases (Qdrant/Milvus), and Retrieval Augmented Generation (RAG) systems. From simple chatbot to production AI applications, fully self-hosted and private.
๐ฏ Learning Philosophy
AI on Your Hardware:
Cloud AI APIs โ Local LLMs โ Your Data Stays Home
(Pay per token) (Free, private) (Full control)
This directory teaches AI/ML assuming no AI background but strong interest in running models locally. Progressive implementation from simple LLM inference through production RAG systems.
๐ Learning Path
Prerequisites: Docker basics, Python fundamentals
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PHASE 1: LLM Fundamentals โ
โ โโ What are LLMs โ
โ โโ Models vs APIs โ
โ โโ Ollama setup (local LLMs) โ
โ โโ Running your first model โ
โ โโ Model selection guide โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PHASE 2: LLM Integration โ
โ โโ OpenAI-compatible API โ
โ โโ Python SDK usage โ
โ โโ Prompt engineering basics โ
โ โโ Context windows and tokens โ
โ โโ Streaming responses โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PHASE 3: Vector Databases โ
โ โโ Embeddings explained โ
โ โโ Vector similarity search โ
โ โโ Qdrant setup โ
โ โโ Storing and querying vectors โ
โ โโ Semantic search โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PHASE 4: RAG Systems โ
โ โโ What is RAG โ
โ โโ Document chunking โ
โ โโ Building RAG pipeline โ
โ โโ LangChain integration โ
โ โโ Production RAG patterns โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PHASE 5: Advanced & Fine-tuning โ
โ โโ Model quantization โ
โ โโ Fine-tuning basics โ
โ โโ Multi-modal models โ
โ โโ Agent frameworks โ
โ โโ GPU optimization โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Articles in This Directory
โ Recently Created (2026-08-26 headless-browser research session)
- embeddings-vector-db โ Embeddings & cosine similarity, Ollama embedding models, Qdrant Compose setup, semantic search demo in Python. โ CREATED 2026-08-26
- rag-pipeline โ RAG end-to-end: chunking strategies, embedding + storage, retrieval + prompt assembly, minimal Python pipeline. โ CREATED 2026-08-26
๐ข Phase 1: LLM Fundamentals (Start Here)
Understanding Large Language Models:
llm-introduction - What are LLMs
- How LLMs work (simplified)
- Transformers architecture
- Parameters and model sizes
- Cloud vs local LLMs
- Privacy considerations
- Prerequisites: None
- Time: 2 hours
- Resources:
[โโโโโโโโโโ]20% - Conceptual
ollama-setup - Run LLMs locally
- Ollama installation
- GPU vs CPU inference
- Downloading models
- First inference
- Model management
- Prerequisites: Docker basics
- Time: 1-2 hours
- Resources:
[โโโโโโโโโโ]60% - 8GB+ RAM, GPU optional
model-selection-guide - Choosing the right model
- Llama 3, Mistral, Phi-3
- Model size trade-offs
- Speed vs quality
- Hardware requirements
- Task-specific models
- Prerequisites: Ollama running
- Time: 2 hours
- Resources:
[โโโโโโโโโโ]30%
ollama-cli-basics - Command-line usage
- ollama run
- ollama list, pull, rm
- Prompt from stdin
- Model parameters
- System prompts
- Prerequisites: Ollama installed
- Time: 1-2 hours
- Resources:
[โโโโโโโโโโ]30%
๐ก Phase 2: LLM Integration (Build Applications)
ollama-api - OpenAI-compatible API
- REST API overview
- /api/generate endpoint
- /api/chat endpoint
- Streaming responses
- API authentication
- Prerequisites: Ollama basics, HTTP
- Time: 2-3 hours
- Resources:
[โโโโโโโโโโ]40%
python-llm-integration - Python SDK
- Ollama Python library
- Basic chat implementation
- Conversation memory
- Error handling
- Async usage
- Prerequisites: Python basics
- Time: 3-4 hours
- Resources:
[โโโโโโโโโโ]50%
prompt-engineering - Crafting effective prompts
- Prompt structure
- System prompts
- Few-shot learning
- Chain-of-thought
- Prompt templates
- Prerequisites: LLM experience
- Time: 3-4 hours
- Resources:
[โโโโโโโโโโ]40%
context-and-tokens - Understanding limits
- Token counting
- Context window sizes
- Truncation strategies
- Sliding windows
- Memory management
- Prerequisites: LLM integration
- Time: 2-3 hours
- Resources:
[โโโโโโโโโโ]40%
llm-streaming - Real-time responses
- SSE (Server-Sent Events)
- Streaming with Python
- WebSocket integration
- Frontend display
- Prerequisites: Web basics
- Time: 2-3 hours
- Resources:
[โโโโโโโโโโ]50%
๐ Phase 3: Vector Databases (Semantic Search)
embeddings-explained - Vector representations
- What are embeddings
- Sentence transformers
- Semantic similarity
- Dimensionality
- Embedding models
- Prerequisites: LLM basics
- Time: 2-3 hours
- Resources:
[โโโโโโโโโโ]40%
qdrant-setup - Vector database
- Qdrant installation (Docker)
- Collections and vectors
- Distance metrics
- Filtering
- Web UI
- Prerequisites: Docker basics
- Time: 2-3 hours
- Resources:
[โโโโโโโโโโ]50% - 2GB RAM
vector-storage-operations - CRUD operations
- Inserting vectors
- Similarity search
- Payload filtering
- Batch operations
- Python SDK usage
- Prerequisites: Qdrant running
- Time: 3-4 hours
- Resources:
[โโโโโโโโโโ]60%
semantic-search-basics - Finding similar content
- Generating embeddings
- Indexing documents
- Search queries
- Ranking results
- Hybrid search
- Prerequisites: Vector database
- Time: 3-4 hours
- Resources:
[โโโโโโโโโโ]60%
vector-db-alternatives - Other options
- Milvus
- Weaviate
- ChromaDB
- Pgvector (Postgres)
- Comparison matrix
- Prerequisites: Vector concepts
- Time: 2 hours
- Resources:
[โโโโโโโโโโ]40%
๐ด Phase 4: RAG Systems (Production AI)
rag-introduction - Retrieval Augmented Generation
- What is RAG
- Why RAG vs fine-tuning
- RAG architecture
- Use cases
- Benefits and limitations
- Prerequisites: LLM + vectors
- Time: 2 hours
- Resources:
[โโโโโโโโโโ]30%
document-chunking - Splitting documents
- Chunking strategies
- Chunk size optimization
- Overlap considerations
- Metadata extraction
- Document loaders
- Prerequisites: RAG concepts
- Time: 2-3 hours
- Resources:
[โโโโโโโโโโ]40%
rag-pipeline-basics - Building RAG
- Ingestion pipeline
- Retrieval step
- Augmentation
- Generation
- End-to-end example
- Prerequisites: LLM + vector DB
- Time: 4-5 hours
- Resources:
[โโโโโโโโโโ]70%
langchain-integration - RAG framework
- LangChain overview
- Document loaders
- Vector stores
- Retrieval chains
- Chat with documents
- Prerequisites: Python, RAG basics
- Time: 4-5 hours
- Resources:
[โโโโโโโโโโ]70%
rag-production-patterns - Scaling RAG
- Caching strategies
- Re-ranking results
- Citation extraction
- Multi-query RAG
- Evaluation metrics
- Prerequisites: RAG experience
- Time: 4-5 hours
- Resources:
[โโโโโโโโโโ]80%
โซ Phase 5: Advanced & Fine-tuning (Expert Level)
model-quantization - Smaller, faster models
- What is quantization
- GGUF format
- Q4, Q5, Q8 models
- Speed vs accuracy
- Creating quantized models
- Prerequisites: LLM experience
- Time: 3-4 hours
- Resources:
[โโโโโโโโโโ]60%
fine-tuning-basics - Custom models
- When to fine-tune
- LoRA adapters
- Dataset preparation
- Training process
- Evaluation
- Prerequisites: ML basics, GPU
- Time: 6-8 hours
- Resources:
[โโโโโโโโโโ]90% - 16GB+ VRAM
multi-modal-models - Vision + Language
- LLaVA (vision models)
- Image understanding
- OCR with LLMs
- Audio models
- Prerequisites: LLM proficiency
- Time: 3-4 hours
- Resources:
[โโโโโโโโโโ]80%
agent-frameworks - Autonomous AI
- What are agents
- Tool use
- ReAct pattern
- LangGraph
- Multi-agent systems
- Prerequisites: Advanced LLM usage
- Time: 5-6 hours
- Resources:
[โโโโโโโโโโ]80%
gpu-optimization - Hardware acceleration
- CUDA setup
- VRAM management
- Batch processing
- Model parallelism
- Inference optimization
- Prerequisites: GPU hardware
- Time: 4-5 hours
- Resources:
[โโโโโโโโโโ]90%
๐ What Comes Next?
After mastering local AI:
For Applications:
- kb/basics/python-advanced - App development
For Infrastructure:
- kb/containers/gpu-containers - GPU in Docker
For Observability:
- kb/observability/ai-monitoring - LLM metrics
For Security:
- kb/security/ai-security - Secure AI systems
๐ Resource Requirements
Ollama (CPU):
- Small models (3B-7B): 8GB RAM
[โโโโโโโโโโ]40% - Medium models (13B-15B): 16GB RAM
[โโโโโโโโโโ]60% - Large models (30B+): 32GB+ RAM
[โโโโโโโโโโ]90%
Ollama (GPU):
- 7B models: 6GB VRAM
[โโโโโโโโโโ]40% - 13B models: 12GB VRAM
[โโโโโโโโโโ]60% - 70B models: 48GB+ VRAM
[โโโโโโโโโโ]100%
Vector Databases:
- Qdrant (small): 1GB RAM
[โโโโโโโโโโ]30% - Qdrant (millions of vectors): 8GB+ RAM
[โโโโโโโโโโ]80%
RAG System (Ollama + Vector DB + App):
- Minimal: 10GB RAM
[โโโโโโโโโโ]50% - Comfortable: 16GB RAM + GPU
[โโโโโโโโโโ]70% - Production: 32GB RAM + 12GB VRAM
[โโโโโโโโโโ]90%
Learning Time Investment:
- LLM Basics: 1-2 weeks
[โโโโโโโโโโ]40% - Integration: 2-3 weeks
[โโโโโโโโโโ]50% - Vector Databases: 1-2 weeks
[โโโโโโโโโโ]40% - RAG Systems: 3-4 weeks
[โโโโโโโโโโ]70% - Advanced Topics: 2-3 months
[โโโโโโโโโโ]90% - Production Mastery: 6-12 months
[โโโโโโโโโโ]100%
๐ ๏ธ Recommended Tool Stack
LLM Inference:
- Ollama
[โโโโโโโโโโ]Required - Easiest local LLMs - vLLM
[โโโโโโโโโโ]70% - Production inference - LocalAI
[โโโโโโโโโโ]60% - OpenAI alternative
Vector Databases:
- Qdrant
[โโโโโโโโโโ]90% - Fast, Rust-based - Milvus
[โโโโโโโโโโ]80% - Scalable, feature-rich - ChromaDB
[โโโโโโโโโโ]70% - Simple, embedded - Pgvector
[โโโโโโโโโโ]60% - Postgres extension
RAG Frameworks:
- LangChain
[โโโโโโโโโโ]90% - Most popular - LlamaIndex
[โโโโโโโโโโ]80% - RAG-focused - Haystack
[โโโโโโโโโโ]70% - NLP pipelines
Embeddings:
- sentence-transformers
[โโโโโโโโโโ]90% - Python library - Ollama embeddings
[โโโโโโโโโโ]80% - Built-in
Supporting Tools:
- Open WebUI
[โโโโโโโโโโ]80% - ChatGPT-like UI - AnythingLLM
[โโโโโโโโโโ]70% - RAG UI - LiteLLM
[โโโโโโโโโโ]60% - Unified API
๐ก Pro Tips for Local AI
- Start with Ollama: Easiest way to run local LLMs
- GPU is Optional: CPU works, just slower
- 7B Models Sweet Spot: Good balance of speed/quality
- RAG > Fine-tuning: For most use cases
- Chunk Size Matters: 500-1000 tokens usually optimal
- Test Multiple Models: Different models for different tasks
- Quantization is Your Friend: Q4 models are fast
- Monitor VRAM: Easy to run out of memory
- Streaming is Better UX: Show results as they generate
- Embeddings are Cheap: Cache them aggressively
๐ Common AI/ML Pitfalls
Pitfall 1: Running Huge Models
- 70B model on 16GB RAM = swap thrashing
- Fix: Start with 7B-13B models
Pitfall 2: Ignoring Context Limits
- Dumping 50 pages into prompt
- Fix: Use RAG for large documents
Pitfall 3: No Evaluation
- Not testing output quality
- Fix: Define metrics, test systematically
Pitfall 4: Over-engineering
- Complex agent systems for simple tasks
- Fix: Start simple, add complexity when needed
Pitfall 5: Poor Chunking
- Too small = no context, too large = irrelevant
- Fix: Experiment, 500-1000 tokens typical
Pitfall 6: Ignoring Latency
- Huge models in user-facing apps
- Fix: Smaller models, caching, async
Pitfall 7: No Prompt Versioning
- Changing prompts breaks things
- Fix: Version control prompts
Pitfall 8: Trusting Outputs Blindly
- LLMs hallucinate, confidently
- Fix: Validation, citations, human review
๐ Related KB Sections
- kb/containers/ - Docker for AI services
- kb/infrastructure/ - IaC for AI infra
- kb/observability/ - Monitor AI systems
- kb/security/ - Secure AI deployments
- kb/basics/python-basics - Python skills
๐ Change Log
2026-01-30
- Created AI/ML directory structure
- Defined complete learning path from LLMs to RAG
- Established Ollama + Qdrant + LangChain as core stack
- Listed all planned articles with time estimates
- Added resource requirements for AI workloads
- Emphasized self-hosted, privacy-focused approach
- Organized by learning phases (1-5)
- Added tool recommendations with ratings
- Cross-referenced related KB sections
- Included production AI patterns
๐ค Remember: You don't need cloud APIs to run AI! Ollama makes local LLMs dead simple. Start with a 7B model, add RAG with Qdrant for your documents, and build AI apps that keep your data private. GPU optional - CPU works fine for many use cases!
Change Log
- 2026-08-26: Added 2 new articles created via headless-browser web research session; marked planned items as created.