Tutorials

Learn it by running it

461 free tutorials on Python, SQL, machine learning, generative AI and statistics. The examples run right in the page, so you can change the code and see what happens.

Try:

Latest tutorials

Newest first · 1 to 30 of 461

  1. Generative AI and NLPLLM Temperature, Top-P, and Top-K Explained, With Python SimulationsBuild temperature, top-p, top-k, and min-p sampling from scratch in Python. Interactive code, probability visuals, and a per-task cheat sheet.20 min read13 runnable examples
  2. Generative AI and NLPOpenAI API Python Tutorial, Chat Completions, Streaming & Error HandlingLearn to use the OpenAI API in Python. Master chat completions, streaming responses, error handling, retries, and async calls with runnable examples.18 min read4 runnable examples
  3. Generative AI and NLPBuild a Python AI Chatbot with Memory Using LangChainLearn to build a Python AI chatbot with conversation memory using LangChain and LangGraph. Master 5 memory strategies, add a Streamlit UI, and persist chats to SQLite.10 min readCode to run on your machine
  4. Generative AI and NLPBuild a BPE Tokenizer from Scratch in Python, Step-by-Step GuideBuild a working BPE tokenizer in Python step by step. Learn how LLMs split text into tokens, implement byte pair encoding, and count tokens with tiktoken.15 min read17 runnable examples
  5. Practice exercises101 Polars Exercises for Data Analysis (with Solutions)Master Polars with 101 hands-on exercises and solutions, covering DataFrames, groupby, joins, window functions, lazy eval, and more.15 min read161 runnable examples
  6. Generative AI and NLPZero-Shot vs Few-Shot Prompting: Complete GuideBuild a text classifier that hits 90%+ accuracy using only prompt engineering. Learn zero-shot, one-shot, and few-shot prompting with hands-on Python examples.13 min read12 runnable examples
  7. Generative AI and NLPTransformer Attention from Scratch in NumPy (Python)Build transformer attention from scratch in NumPy with runnable code. Scaled dot-product, multi-head attention, causal masking, and heatmaps step by step.15 min read23 runnable examples
  8. Generative AI and NLPTrain a Custom Tokenizer with HuggingFace (Python)Learn to train custom BPE and WordPiece tokenizers with HuggingFace for medical, legal, and domain-specific NLP. Includes evaluation metrics and code.9 min read4 runnable examples
  9. Generative AI and NLPtiktoken vs HuggingFace Tokenizers: Benchmark GuideBenchmark tiktoken vs HuggingFace Tokenizers on speed, vocabulary, and encoding. Runnable Python code, migration guide, and decision framework for your LLM apps.11 min read2 runnable examples
  10. Generative AI and NLPLLM Structured Output: JSON Mode & Pydantic GuideLearn LLM structured output in Python with 3 methods: OpenAI JSON schema, Claude tool extraction, and Instructor. Build a type-safe invoice parser with Pydantic.10 min readCode to run on your machine
  11. Generative AI and NLPMamba & State Space Models: Build a Mini SSM LayerBuild a Mamba SSM layer from scratch in NumPy. Learn selective state spaces, implement selective scan, and benchmark SSM vs attention scaling with runnable code.16 min read16 runnable examples
  12. Generative AI and NLPSpeculative Decoding: Faster LLM Inference (Python)Build a speculative decoding simulator in Python. Learn the draft-verify algorithm, measure acceptance rates, and understand when it speeds up LLM inference.15 min read16 runnable examples
  13. Generative AI and NLPRLHF & DPO Explained: Simulate Alignment in PythonBuild a reward model, PPO loop, and DPO training from scratch in NumPy. Compare RLHF vs DPO side-by-side with runnable code.12 min read23 runnable examples
  14. Generative AI and NLPLLM API Retry & Fallback: Build a Resilient ClientBuild a resilient LLM client in Python with retry, fallback chains, circuit breakers, and rate limiting, pure Python, runnable code, no SDKs needed.8 min read1 runnable example
  15. Generative AI and NLPPrompt Engineering Tutorial for Beginners (2026)Master prompt engineering basics with Python. Learn the Role-Task-Format framework, zero-shot prompting, and build a testing harness that measures prompt accuracy.17 min read21 runnable examples
  16. Generative AI and NLPPositional Embeddings: RoPE & ALiBi Explained (Python)Build sinusoidal, RoPE, and ALiBi positional embeddings from scratch in NumPy. Runnable code, heatmaps, and a clear comparison of all three schemes.12 min read22 runnable examples
  17. Generative AI and NLPOpenAI Function Calling Tutorial in Python (2026)Learn OpenAI function calling in Python with 3 working tools. Build the tool-use loop, handle parallel calls, and design schemas using raw HTTP requests.13 min read6 runnable examples
  18. Generative AI and NLPOpenAI Batch API: Process 10K Prompts at 50% CostMaster the OpenAI Batch API in Python: build a reusable pipeline for 10,000+ prompts at 50% cost with JSONL formatting, progress polling, and error handling.11 min read19 runnable examples
  19. Generative AI and NLPOpenAI Chat Completions API: Complete Python GuideMaster the OpenAI API in Python with raw HTTP requests. Learn chat completions, streaming, parameters, error handling, retries, and cost tracking with runnable examples.12 min read3 runnable examples
  20. Generative AI and NLPOllama Tutorial: Run LLMs Locally (Llama, Mistral)Learn to run LLMs locally with Ollama. Install Llama, Mistral, and DeepSeek, use the OpenAI-compatible Python API, and build a local-to-cloud fallback client.12 min read1 runnable example
  21. Generative AI and NLPMultimodal AI Tutorial: GPT-4o Vision & Audio APILearn multimodal AI in Python with GPT-4o, Claude, and Gemini vision APIs. Build image classification, chart analysis, receipt OCR, and audio transcription with raw HTTP.13 min read2 runnable examples
  22. Generative AI and NLPBuild a Multi-Provider LLM Toolkit (Python Project)Build a zero-dep LLM toolkit in Python, unified client for OpenAI, Claude, Gemini, Ollama with cost tracking, retry, streaming, and structured output.15 min read20 runnable examples
  23. Generative AI and NLPLLM API Router: Groq, Together AI & OpenRouterBuild a multi-provider LLM router in Python with cost-based routing, latency tracking, and automatic fallbacks across Groq, Together AI, and OpenRouter.13 min read8 runnable examples3 exercises
  24. Generative AI and NLPMixture of Experts (MoE): Build a Router in PythonBuild a Mixture of Experts (MoE) layer in Python with NumPy. Router, top-k gating, load balancing, and expert networks, with runnable code and exercises.14 min read13 runnable examples
  25. Generative AI and NLPMHA vs GQA vs MQA: Attention & KV Cache GuideBuild MHA, GQA, and MQA attention from scratch in NumPy. Calculate KV cache VRAM for Llama 3 70B, Mistral 7B, and any model with a reusable calculator.12 min read19 runnable examples
  26. Generative AI and NLPLost-in-the-Middle: Fix LLM Position Bias (Python)Measure and fix LLM position bias with Python. Build a needle-in-haystack test, plot the U-shaped curve, and implement position reordering.12 min read7 runnable examples
  27. Generative AI and NLPLong-Context LLMs: Sliding Window Summarization GuideBuild a sliding window summarization pipeline in Python that handles documents exceeding LLM context windows. Map-reduce and recursive strategies with raw HTTP API calls.11 min read4 runnable examples
  28. Generative AI and NLPLLM Streaming Tutorial: SSE in Python Step-by-StepStream LLM tokens from OpenAI, Claude, and Gemini in Python using SSE and async generators. Includes FastAPI server, backpressure handling, and runnable code.10 min readCode to run on your machine
  29. Generative AI and NLPLLM Scaling Laws: Model Comparison Dashboard (2026)Learn LLM scaling laws and compare GPT, Claude, Gemini, Llama, Mistral, and DeepSeek on benchmarks, pricing, and context windows with interactive Python charts.13 min read14 runnable examples
  30. Generative AI and NLPTemperature, Top-p & Top-k in LLMs Explained (Python)Master LLM temperature, top-k, and top-p with interactive Python simulations. Runnable code, exercises, and a sampling playground to build real intuition.10 min read10 runnable examples