Guide
Python / Python Basics / Guide
Python is known for its clean and readable syntax. Unlike other languages, Python uses indentation (whitespace) to define code blocks instead of curly braces {}.
Library Search
Search guides, examples, practice, and runnable labs with ranked results and highlighted snippets.
80 results for Python
Python / Python Basics / Guide
Python is known for its clean and readable syntax. Unlike other languages, Python uses indentation (whitespace) to define code blocks instead of curly braces {}.
Python / Strings / Guide
print(text.strip().replace("World", "Python")) # "Hello Python"
Python / Performance / Guide
Python Performance & Optimization
Math for LLMs / Multivariate Calculus / Notes
Basic Python and NumPy; familiarity with operator overloading
Math for LLMs / Mathematical Foundations / Theory Lab
concepts from all 17 sections with runnable Python, NumPy, and PyTorch code.
Math for LLMs / Mathematical Foundations / Theory Lab
concepts from all 15 sections with runnable Python code, connecting abstract mathematics
Math for LLMs / Linear Algebra Basics / Theory Lab
Theory Lab > Runnable lab version for web reading. # Vector Spaces and Subspaces — From Axioms to Interpretability > A vector space is not a collection of arrows. It is a collection of objects that *behave like* arrows — and that behaviour is the entire point.
Math for LLMs / Functional Analysis / Theory Lab
Theory Lab > Runnable lab version for web reading. # Normed Spaces - Theory Notebook This notebook is the interactive companion to notes.md. It turns normed-space definitions into computations: unit balls, convergence, operator norms, dual norms, contractions,
Python / Control Flow / Guide
Match-case statements (Python 3.10+)
Math for LLMs / Multivariate Calculus / Theory Lab
Theory Lab > Runnable lab version for web reading. # Chain Rule and Backpropagation — Theory > *"Backpropagation is an algorithm for computing gradients efficiently in a computational graph. At its heart, it is nothing more than the chain rule of calculus appl
Math for LLMs / Multivariate Calculus / Theory Lab
Theory Lab > Runnable lab version for web reading. # Optimality Conditions — Theory Notebook > *"The art of optimization is knowing not just how to move, but when to stop."* Interactive theory: first-order conditions, second-order tests, convexity, Lagrange mu
Math for LLMs / Statistics / Theory Lab
Theory Lab > Runnable lab version for web reading. # Bayesian Inference — Theory Notebook > Posterior reasoning turns uncertainty into something we can compute with, visualize, and act on. This notebook is the interactive companion to notes.md. It follows the
Math for LLMs / Statistics / Theory Lab
Theory Lab > Runnable lab version for web reading. # Regression Analysis — Theory Notebook > Regression turns feature-response relationships into a concrete language for prediction, uncertainty, and regularization. This notebook is the interactive companion to
Math for LLMs / Fourier Analysis And Signal Processing / Theory Lab
FNO spectral convolution layer (1D, NumPy/pure-Python implementation)
Python / Networking Apis / Guide
Networking & APIs in Python
Math for LLMs / Advanced Linear Algebra / Theory Lab
Theory Lab > Runnable lab version for web reading. # Positive Definite Matrices — Theory Notebook > *"Positive definiteness is the matrix condition that makes everything work."* Interactive exploration of positive definite matrices, Cholesky decomposition, Sch
Math for LLMs / Advanced Linear Algebra / Theory Lab
Theory Lab > Runnable lab version for web reading. # Matrix Decompositions > *"The purpose of computing is insight, not numbers — and no insight is more powerful than factoring a matrix into pieces whose structure you understand."* This notebook implements and
Math for LLMs / Functional Analysis / Theory Lab
Theory Lab > Runnable lab version for web reading. # Kernel Methods - Theory Notebook This notebook is the executable companion to notes.md. It turns kernel definitions into concrete computations: Gram matrices, PSD checks, feature maps, RKHS-style prediction,
Python / Testing / Guide
Testing in Python
Math for LLMs / ML Specific Math / Theory Lab
Theory Lab > Runnable lab version for web reading. # Loss Functions - Theory Notebook This notebook is the executable companion to notes.md. It turns loss formulas into curves, gradients, masking rules, and stability checks. ### Code cell 2 import numpy as np
Python / Modules Packages / Guide
Python Standard Library
Python / Packaging / Guide
Python Packaging & Distribution
Math for LLMs / Advanced Linear Algebra / Theory Lab
Theory Lab > Runnable lab version for web reading. # Matrix Norms > *"The art of doing mathematics consists in finding that special case which contains all the germs of generality." — David Hilbert* Interactive theory notebook for the Matrix Norms section of A
Math for LLMs / Calculus Fundamentals / Theory Lab
Theory Lab > Runnable lab version for web reading. # Series and Sequences — Theory Notebook > *"An infinite series is merely a sequence of partial sums — the question is whether that sequence has a limit."* Interactive exploration of sequences, series converge
Math for LLMs / Information Theory / Theory Lab
Theory Lab > Runnable lab version for web reading. # Fisher Information Fisher information measures local statistical distinguishability. This notebook is the interactive companion to notes.md and builds the chapter through concrete score computations, KL-curv
Math for LLMs / Graph Theory / Theory Lab
Theory Lab > Runnable lab version for web reading. # Spectral Graph Theory — Theory Notebook > *"To understand a graph, listen to its spectrum. The eigenvalues of the Laplacian are the resonant frequencies of the graph."* This notebook provides interactive der
Math for LLMs / Statistics / Theory Lab
Theory Lab > Runnable lab version for web reading. # Time Series — Theory Notebook > Time order changes what counts as signal, what can be predicted, and how uncertainty should evolve with horizon. This notebook is the interactive companion to notes.md. It mov
Math for LLMs / Graph Theory / Theory Lab
=== 5.1 Python dict-of-lists adjacency list ===
Math for LLMs / Graph Theory / Theory Lab
Theory Lab > Runnable lab version for web reading. # Graph Neural Networks — Theory Notebook > *"A graph neural network is a machine that reads a graph and learns by listening to its neighbors."* Interactive derivations covering: GCN propagation, over-smoothin
Math for LLMs / Graph Theory / Theory Lab
Theory Lab > Runnable lab version for web reading. # Random Graphs — Theory Notebook > *"In the random graph, order emerges from chaos — the giant component appears suddenly, like a phase transition in physics, when the average degree crosses one."* Interactiv
Python / Data Structures / Guide
from_string = list("Python") # ['P', 'y', 't', 'h', 'o', 'n']
Python / Data Science Ml / Guide
Data Science and Machine Learning Fundamentals with Python
Python / Type Hints / Guide
Type hints (introduced in Python 3.5) add optional static typing to Python. They don't change how your code runs but provide metadata for tools and humans.
Math for LLMs / Statistics / Theory Lab
Theory Lab > Runnable lab version for web reading. # Estimation Theory > *"The problem of statistical estimation is one of the most fundamental in all of science: given observations drawn from some unknown process, what can we infer about that process?"* > — S
Math for LLMs / Information Theory / Theory Lab
Theory Lab > Runnable lab version for web reading. # Entropy — Theory Notebook > *"Information is the resolution of uncertainty."* — Claude Shannon Interactive derivations: entropy computations, MaxEnt proofs, entropy rate of Markov chains, perplexity, differe
Math for LLMs / Numerical Methods / Theory Lab
print(f'Python float: {sys.float_info}')
Math for LLMs / Fourier Analysis And Signal Processing / Theory Lab
Theory Lab > Runnable lab version for web reading. # §20-01 Fourier Series — Theory Notebook > *'Any periodic motion is a superposition of simple oscillations.'* — Fourier Interactive derivations for §20-01. Run top-to-bottom. | Section | Content | |---------|
Python / Python Basics / Practice
01 - Python Basics: Exercises
Python / Packaging / Examples
requires-python = ">={python_version}"
Math for LLMs / Mathematical Foundations / Theory Lab
with runnable Python, NumPy, and PyTorch code — from set-theoretic definitions through
Math for LLMs / Probability Theory / Theory Lab
Theory Lab > Runnable lab version for web reading. # Expectation and Moments > *"The expectation of the product of two independent random variables equals the product of their expectations — a theorem so simple it conceals its own depth."* Interactive theory n
Math for LLMs / Statistics / Theory Lab
Theory Lab > Runnable lab version for web reading. # Descriptive Statistics — Theory Notebook > *"The first step in wisdom is knowing what you don't know — and in statistics, that begins by knowing what your data actually looks like."* — John Tukey Interactive
Math for LLMs / Information Theory / Theory Lab
Theory Lab > Runnable lab version for web reading. # KL Divergence — Theory Notebook > *"The most important single quantity in information theory and in machine learning is the Kullback-Leibler divergence."* — David MacKay Interactive exploration of KL diverge
Math for LLMs / Graph Theory / 1 Intuition To 6 Sparse Matrix Formats
The Python dictionary-of-lists adjacency representation, while correct and flexible, has poor cache locality. Each list is a separate Python object allocated at a random memory address, causing cache misses during graph traversal.
Python / Python Basics / Examples
01 - Python Basics: Examples
Python / Automation / Guide
print(f"Python: {platform.python_version()}")
Python / Debugging Profiling / Guide
print(f"{name=}, {age=}") # Python 3.8+: name='Alice', age=30
Math for LLMs / Calculus Fundamentals / Theory Lab
Theory Lab > Runnable lab version for web reading. # Limits and Continuity - Examples This notebook demonstrates limits and continuity concepts with practical examples and visualizations. ## Topics Covered 1. Limit Intuition (Numerical Approach) 2. One-Sided L
Math for LLMs / Calculus Fundamentals / Theory Lab
Theory Lab > Runnable lab version for web reading. # Integration — Theory Notebook > *"To integrate is to make whole — to recover from the rate of change the quantity that changed."* Interactive exploration of integration: Riemann sums, the Fundamental Theorem
Math for LLMs / Multivariate Calculus / Theory Lab
Theory Lab > Runnable lab version for web reading. # Partial Derivatives and Gradients > *"The gradient is the generalization of the derivative to functions of several variables, and it points in the direction in which the function increases most rapidly."* In
Math for LLMs / Information Theory / Theory Lab
Theory Lab > Runnable lab version for web reading. # Cross-Entropy > Cross-entropy is the bridge from information theory to the actual loss curves we use to train classifiers and language models. This notebook is the interactive companion to notes.md. We move
Python / Regex / Guide
Regular Expressions are patterns used to match character combinations in strings. Python's re module provides regex support.
Math for LLMs / Advanced Linear Algebra / Theory Lab
Theory Lab > Runnable lab version for web reading. # Eigenvalues and Eigenvectors — Theory Notebook > *"The eigenvalues of a matrix are not just numbers — they are the heartbeat of the linear map, the frequencies at which it resonates, the rates at which it re
Math for LLMs / Calculus Fundamentals / Theory Lab
Theory Lab > Runnable lab version for web reading. # Derivatives and Differentiation > *"The derivative is the instantaneous rate of change — and backpropagation is just the chain rule applied to a computation graph."* Interactive theory notebook covering: der
Math for LLMs / Graph Theory / Theory Lab
notes is demonstrated with executable Python.
Math for LLMs / Functional Analysis / Theory Lab
Theory Lab > Runnable lab version for web reading. # Hilbert Spaces: Theory Notebook Hilbert spaces add angle, projection, orthogonal coordinates, and self-duality to normed spaces. This notebook is the interactive companion to notes.md. ### Code cell 2 import
Math for LLMs / ML Specific Math / Theory Lab
Theory Lab > Runnable lab version for web reading. # Activation Functions - Theory Notebook Executable companion to notes.md. ### Code cell 2 import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl try: import seaborn as sns sns.set_theme(s
Math for LLMs / ML Specific Math / Theory Lab
Theory Lab > Runnable lab version for web reading. # Normalization Techniques - Theory Notebook Executable companion to notes.md. ### Code cell 2 import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl try: import seaborn as sns sns.set_the
Math for LLMs / ML Specific Math / Theory Lab
Theory Lab > Runnable lab version for web reading. # Sampling Methods - Theory Notebook Executable companion to notes.md. ### Code cell 2 import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl try: import seaborn as sns sns.set_theme(style
Math for LLMs / Fourier Analysis And Signal Processing / Theory Lab
Theory Lab > Runnable lab version for web reading. # Fourier Transform — Theory Notebook > *"The Fourier transform is a mathematical prism: it refracts a signal into its constituent frequencies, revealing structure invisible in time."* This notebook provides i
Python / Cli Applications / Guide
python -m pytest --verbose
Math for LLMs / Math For Specific Models / Theory Lab
Theory Lab > Runnable lab version for web reading. # Reinforcement Learning This notebook is the executable companion to notes.md. It keeps the MDPs tiny so Bellman equations, TD targets, policy gradients, PPO clipping, and preference losses can be inspected n
Math for LLMs / Math For LLMs / Theory Lab
Theory Lab > Runnable lab version for web reading. # Tokenization Math This notebook is the executable companion to notes.md. It implements tiny BPE, unigram/Viterbi, entropy, fertility, special-token, and context-cost examples from scratch. ### Code cell 2 im
Math for LLMs / Math For LLMs / Theory Lab
Theory Lab > Runnable lab version for web reading. # Embedding Space Math This notebook is the executable companion to notes.md. It turns embedding lookup, vector similarity, analogy structure, position encodings, output gradients, and diagnostics into small c
Math for LLMs / Math For LLMs / Theory Lab
Theory Lab > Runnable lab version for web reading. # Attention Mechanism Math This notebook is the executable companion to notes.md. It checks scaled dot-product attention, masks, entropy, multi-head shapes, KV-cache cost, ALiBi bias, and efficient-attention i
Math for LLMs / Math For LLMs / Theory Lab
Theory Lab > Runnable lab version for web reading. # Positional Encodings This notebook is the executable companion to notes.md. It checks sinusoidal rows, learned table sizes, relative offsets, RoPE rotations, ALiBi bias, and decode position ids. ### Code cel
Math for LLMs / LLM Training Data Pipeline / Theory Lab
Theory Lab > Runnable lab version for web reading. # Data Format Standards - Theory Notebook Executable companion to notes.md. ### Code cell 2 import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl try: import seaborn as sns sns.set_theme(
Math for LLMs / LLM Training Data Pipeline / Theory Lab
Theory Lab > Runnable lab version for web reading. # JSONL Generation - Theory Notebook Executable companion to notes.md. ### Code cell 2 import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl try: import seaborn as sns sns.set_theme(style
Math for LLMs / LLM Training Data Pipeline / Theory Lab
Theory Lab > Runnable lab version for web reading. # Quality Checks - Theory Notebook Executable companion to notes.md. ### Code cell 2 import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl try: import seaborn as sns sns.set_theme(style="
Math for LLMs / LLM Training Data Pipeline / Theory Lab
Theory Lab > Runnable lab version for web reading. # Full Dataset Assembly - Theory Notebook Executable companion to notes.md. ### Code cell 2 import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl try: import seaborn as sns sns.set_theme(
Math for LLMs / LLM Training Data Pipeline / Theory Lab
Theory Lab > Runnable lab version for web reading. # Contamination and Dedup Audits - Theory Notebook Executable companion to notes.md. ### Code cell 2 import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl try: import seaborn as sns sns.s
Math for LLMs / LLM Training Data Pipeline / Theory Lab
Theory Lab > Runnable lab version for web reading. # Documentation and Governance - Theory Notebook Executable companion to notes.md. ### Code cell 2 import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl try: import seaborn as sns sns.set
Math for LLMs / LLM Training Data Pipeline / Theory Lab
Theory Lab > Runnable lab version for web reading. # Data Mixture Optimization - Theory Notebook Executable companion to notes.md. ### Code cell 2 import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl try: import seaborn as sns sns.set_th
Math for LLMs / Evaluation And Reliability / Theory Lab
Theory Lab > Runnable lab version for web reading. # Capability Benchmarks Capability benchmarks estimate what a model can do under a stated protocol; reliability begins when the protocol, metric, and uncertainty are explicit. This notebook is the executable c
Math for LLMs / Evaluation And Reliability / Theory Lab
Theory Lab > Runnable lab version for web reading. # Calibration and Uncertainty Calibration asks whether confidence matches correctness; uncertainty methods decide when a model should answer, abstain, or return a set of plausible answers. This notebook is the
Math for LLMs / Evaluation And Reliability / Theory Lab
Theory Lab > Runnable lab version for web reading. # Robustness and Distribution Shift Robustness evaluation measures how model risk changes when the test distribution, prompt surface, subgroup, or adversary changes. This notebook is the executable companion t
Math for LLMs / Evaluation And Reliability / Theory Lab
Theory Lab > Runnable lab version for web reading. # Error Analysis and Ablations Error analysis turns aggregate scores into failure structure; ablations test which component actually caused an improvement. This notebook is the executable companion to notes.md
Math for LLMs / Evaluation And Reliability / Theory Lab
Theory Lab > Runnable lab version for web reading. # Online Experimentation and AB Testing Online experiments connect offline model evidence to causal user and system impact through randomized comparison, statistical inference, and trust checks. This notebook
Math for LLMs / Alignment And Safety / Theory Lab
Theory Lab > Runnable lab version for web reading. # Instruction Tuning and SFT Supervised fine-tuning aligns a pretrained next-token model with demonstrated instruction-following behavior by optimizing response tokens under a curated chat protocol. This noteb
Math for LLMs / Alignment And Safety / Theory Lab
Theory Lab > Runnable lab version for web reading. # Preference Optimization RLHF and DPO Preference optimization learns from comparisons, either by fitting a reward model and optimizing a KL-regularized policy or by directly optimizing policy log-ratios. This