Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/rohitg00/ai-engineering-from-scratch
/ functions
Functions
8,347 in github.com/rohitg00/ai-engineering-from-scratch
⨍
Functions
8,347
◇
Types & classes
1,490
↳
Endpoints
1
↓ 3 callers
Method
generate_hypothetical
(self, query: str)
phases/19-capstone-projects/67-query-rewriting-hyde/code/main.py:227
↓ 3 callers
Function
generate_linear_data
(n_samples=100, margin=1.0, seed=42)
phases/02-ml-fundamentals/05-support-vector-machines/code/svm.py:118
↓ 3 callers
Function
generate_response
( model, prompt_tokens, max_new_tokens=30, temperature=0.8, max_seq_len=128 )
phases/10-llms-from-scratch/07-rlhf/code/main.py:178
↓ 3 callers
Method
get
(self, labels: dict[str, str])
phases/19-capstone-projects/29-end-to-end-coding-task-demo/code/main.py:352
↓ 3 callers
Function
get_batch
(split)
phases/07-transformers-deep-dive/14-build-a-transformer-capstone/code/main.py:221
↓ 3 callers
Method
get_probs
(self, context, token)
phases/10-llms-from-scratch/12-inference-optimization/code/main.py:246
↓ 3 callers
Function
gini_impurity
(y)
phases/02-ml-fundamentals/18-feature-selection/code/feature_selection.py:140
↓ 3 callers
Function
gradient_l2_norm
Return the L2 norm of the concatenated gradient vector. Mirrors `torch.nn.utils.get_total_norm` for the gradient case so the lesson does not
phases/19-capstone-projects/44-cosine-lr-warmup/code/main.py:105
↓ 3 callers
Function
gradient_norm_at_embedding
Send one forward and one backward through the stack, return the embedding gradient norm. The loss is the sum of squares of the final tensor. The
phases/19-capstone-projects/34-transformer-block/code/main.py:179
↓ 3 callers
Function
greedy_from_V
(V, gamma=0.99)
phases/09-reinforcement-learning/02-dynamic-programming/code/main.py:57
↓ 3 callers
Function
gumbel_softmax_sample
(log_probs, temperature)
phases/01-math-foundations/16-sampling-methods/code/sampling.py:336
↓ 3 callers
Method
handle
( presentedKey: string, prompt: string, )
phases/17-infrastructure-and-production/19-ai-gateways/code/main.ts:253
↓ 3 callers
Function
harmful_token_rate
(response: list[str])
phases/18-ethics-safety-alignment/05-constitutional-ai-rlaif/code/main.py:58
↓ 3 callers
Function
hashEmbed
(text: string, dim = 256)
phases/05-nlp-foundations-to-advanced/23-chunking-strategies-rag/code/main.ts:25
↓ 3 callers
Function
hash_embed
(text, dim=256)
phases/05-nlp-foundations-to-advanced/23-chunking-strategies-rag/code/main.py:10
↓ 3 callers
Function
hessian_2d
(f, x, y, h=1e-5)
phases/01-math-foundations/04-calculus-for-ml/code/derivatives.py:121
↓ 3 callers
Function
hessian_eigenvalues
(H)
phases/01-math-foundations/04-calculus-for-ml/code/derivatives.py:137
↓ 3 callers
Function
http_json
(method: str, url: str, body: Any = None)
phases/16-multi-agent-and-swarms/12-a2a-protocol/code/main.py:125
↓ 3 callers
Function
human
(x)
site/figures-nlp2.js:255
↓ 3 callers
Function
human
(x)
site/figures-vision-speech.js:231
↓ 3 callers
Function
human
(x)
site/figures-llms-systems.js:244
↓ 3 callers
Function
hz_to_mel
(f)
phases/06-speech-and-audio/03-audio-classification/code/main.py:53
↓ 3 callers
Function
hz_to_mel
(f)
phases/06-speech-and-audio/06-speaker-recognition-verification/code/main.py:58
↓ 3 callers
Function
image_to_tokens
8x8 grayscale -> 4 patches of 4 floats (downsampled). Return token IDs.
phases/12-multimodal-ai/11-chameleon-early-fusion-tokens/code/main.py:44
↓ 3 callers
Function
infonce_loss
Symmetric InfoNCE over rows and columns.
phases/12-multimodal-ai/02-clip-contrastive-pretraining/code/main.py:43
↓ 3 callers
Function
information_gain
(parent_labels, left_labels, right_labels, criterion="gini")
phases/02-ml-fundamentals/04-decision-trees/code/trees.py:27
↓ 3 callers
Method
inverse_transform
(self, X_reduced)
phases/01-math-foundations/10-dimensionality-reduction/code/dim_reduction.py:39
↓ 3 callers
Function
isObject
(v: unknown)
phases/19-capstone-projects/16-github-issue-to-pr-agent/code/ts/src/router.ts:5
↓ 3 callers
Function
kl
(s)
site/figures-agents-alignment.js:265
↓ 3 callers
Function
l1_distance
(a, b)
phases/01-math-foundations/14-norms-and-distances/code/distances.py:23
↓ 3 callers
Function
l1_norm
(x)
phases/01-math-foundations/14-norms-and-distances/code/distances.py:5
↓ 3 callers
Method
laplacian
(self)
phases/01-math-foundations/21-graph-theory/code/graph_theory.py:38
↓ 3 callers
Method
latest_turn
(self)
phases/19-capstone-projects/25-verification-gates-observation-budget/code/main.py:112
↓ 3 callers
Function
leaky_grad
(x, a=0.2)
phases/08-generative-ai/03-gans-generator-discriminator/code/main.py:17
↓ 3 callers
Function
leaky_grad
(x, a=0.2)
phases/08-generative-ai/04-conditional-gans-pix2pix/code/main.py:17
↓ 3 callers
Function
least_squares_normal
(A, b)
phases/01-math-foundations/17-linear-systems/code/linear_systems.py:93
↓ 3 callers
Function
lessonPath
(url)
site/build.js:24
↓ 3 callers
Function
lineAt
(off, stroke, dash)
site/figures-ml.js:113
↓ 3 callers
Function
linear_forward
(x, w, b)
phases/10-llms-from-scratch/34-gradient-checkpointing/code/main.py:4
↓ 3 callers
Function
linf_distance
(a, b)
phases/01-math-foundations/14-norms-and-distances/code/distances.py:36
↓ 3 callers
Method
list
(now: number = Date.now())
phases/19-capstone-projects/12-video-understanding-pipeline/code/ts/src/jobs.ts:26
↓ 3 callers
Function
listFixtures
()
phases/19-capstone-projects/04-multimodal-document-qa/code/ts/src/fixtures.ts:48
↓ 3 callers
Method
list_items
(self)
phases/14-agent-engineering/20-benchmarks-webarena-osworld/code/main.py:23
↓ 3 callers
Function
lm_loss
Next-token cross-entropy with padding masked. `logits` shape is (B, L, V). `target_ids` shape is (B, L). The shift is applied outside this fu
phases/19-capstone-projects/62-vision-language-pretraining/code/main.py:98
↓ 3 callers
Function
load_all_fixtures
(tasks_root: str)
phases/19-capstone-projects/27-eval-harness-fixture-tasks/code/main.py:273
↓ 3 callers
Function
load_fixtures
(out_dir: str)
phases/19-capstone-projects/70-task-spec-format/code/main.py:383
↓ 3 callers
Function
load_taxonomy
()
phases/19-capstone-projects/83-prompt-injection-detector/code/main.py:162
↓ 3 callers
Function
looks_like_directive
(text: str)
phases/14-agent-engineering/27-prompt-injection-defense/code/main.py:31
↓ 3 callers
Method
lookup
(prompt: string)
phases/17-infrastructure-and-production/14-prompt-semantic-caching/code/main.ts:133
↓ 3 callers
Function
lossFn
(i)
site/figures.js:829
↓ 3 callers
Method
lr
(self, step: int)
phases/19-capstone-projects/44-cosine-lr-warmup/code/main.py:259
↓ 3 callers
Function
lu_solve
(P, L, U, b)
phases/01-math-foundations/17-linear-systems/code/linear_systems.py:47
↓ 3 callers
Function
lx
(ai)
site/figures-infra.js:403
↓ 3 callers
Function
mae
(y_true, y_pred)
phases/02-ml-fundamentals/15-time-series/code/time_series.py:147
↓ 3 callers
Method
magnitude
(self)
phases/01-math-foundations/20-fourier-transform/code/fourier.py:32
↓ 3 callers
Method
magnitude
(self)
phases/01-math-foundations/02-vectors-matrices-operations/code/matrices.py:24
↓ 3 callers
Function
makeExecutors
(store: Record<string, Incident>)
phases/19-capstone-projects/13-mcp-server-with-registry/code/ts/src/tools.ts:45
↓ 3 callers
Function
makeIncidents
()
phases/19-capstone-projects/13-mcp-server-with-registry/code/ts/src/tools.ts:3
↓ 3 callers
Function
makeMockProvider
( name: string, baseLatencyMs: number, // Function that decides whether call #n errors and how. errorP
phases/17-infrastructure-and-production/19-ai-gateways/code/main.ts:147
↓ 3 callers
Function
makeRng
(seed: number)
phases/17-infrastructure-and-production/20-shadow-canary-progressive/code/main.ts:59
↓ 3 callers
Function
makeState
( descriptors: ToolDescriptor[], executors: Record<string, ToolExecutor>, )
phases/19-capstone-projects/13-mcp-server-with-registry/code/ts/src/protocol.ts:18
↓ 3 callers
Function
make_circle_data
(n=500, seed=42)
phases/03-deep-learning-core/10-mini-framework/code/main.py:362
↓ 3 callers
Function
make_deterministic_runner
Build an async experiment runner whose reward is base_reward + N(0, noise).
phases/19-capstone-projects/56-iteration-scheduler/code/main.py:297
↓ 3 callers
Function
make_model
(in_dim: int, hidden: int, out_dim: int)
phases/19-capstone-projects/48-distributed-fsdp-ddp/code/main.py:69
↓ 3 callers
Function
make_model
(in_dim: int, hidden: int, out_dim: int)
phases/19-capstone-projects/46-gradient-accumulation/code/main.py:65
↓ 3 callers
Function
make_team
()
phases/16-multi-agent-and-swarms/04-primitive-model/code/main.py:74
↓ 3 callers
Method
margin_width
(self)
phases/02-ml-fundamentals/05-support-vector-machines/code/svm.py:98
↓ 3 callers
Function
mark
(a: str | None)
phases/16-multi-agent-and-swarms/14-consensus-and-bft/code/main.py:84
↓ 3 callers
Function
matches_any
(path: str, patterns: list[str])
phases/14-agent-engineering/36-scope-contracts/code/main.py:67
↓ 3 callers
Function
matmul
(W, x)
phases/08-generative-ai/10-video-generation/code/main.py:23
↓ 3 callers
Function
matmul
(W, x)
phases/08-generative-ai/06-diffusion-ddpm-from-scratch/code/main.py:24
↓ 3 callers
Function
matmul
(W, x)
phases/08-generative-ai/13-flow-matching-rectified-flows/code/main.py:13
↓ 3 callers
Function
matmul
(W, x)
phases/08-generative-ai/09-inpainting-outpainting-editing/code/main.py:23
↓ 3 callers
Function
matmul
(W, x)
phases/08-generative-ai/07-latent-diffusion-stable-diffusion/code/main.py:29
↓ 3 callers
Function
mean
(xs)
phases/08-generative-ai/02-autoencoders-vae/code/main.py:152
↓ 3 callers
Function
mean_pool
Mask-weighted mean across the sequence dimension.
phases/19-capstone-projects/38-classifier-finetuning/code/main.py:133
↓ 3 callers
Function
median
(data)
phases/01-math-foundations/15-statistics-for-ml/code/statistics.py:11
↓ 3 callers
Function
mel
(f)
site/figures-vision-speech.js:302
↓ 3 callers
Function
mk
(id, color)
site/figures.js:549
↓ 3 callers
Function
mkSamples
(costMult: number, latMult: number)
phases/17-infrastructure-and-production/20-shadow-canary-progressive/code/main.ts:258
↓ 3 callers
Function
mlp_params
(h: int, ff: int, activation: str)
phases/10-llms-from-scratch/14-open-models-architecture-walkthroughs/code/main.py:122
↓ 3 callers
Function
mock_embed
(text: str, dim: int = 96)
phases/19-capstone-projects/67-query-rewriting-hyde/code/main.py:35
↓ 3 callers
Function
mock_embed
(text: str, dim: int = 96)
phases/19-capstone-projects/69-end-to-end-rag-system/code/main.py:66
↓ 3 callers
Function
mock_embed
(text: str, dim: int = 96)
phases/19-capstone-projects/65-hybrid-retrieval-bm25-dense/code/main.py:103
↓ 3 callers
Function
mock_judge
Deterministic judge: scores prediction on a 1-5 scale. The scoring rules are: 5: normalised prediction equals normalised reference. 4
phases/19-capstone-projects/41-eval-pipeline/code/main.py:562
↓ 3 callers
Function
mse
(a, b)
phases/08-generative-ai/12-3d-generation/code/main.py:43
↓ 3 callers
Function
mse
(y_true, y_pred)
phases/02-ml-fundamentals/09-model-evaluation/code/evaluation.py:167
↓ 3 callers
Function
multi_head_attention
(X, Wq, Wk, Wv, Wo, n_heads, causal=False, kv_source=None)
phases/07-transformers-deep-dive/05-full-transformer/code/main.py:142
↓ 3 callers
Method
names
(self)
phases/19-capstone-projects/21-tool-registry-schema-validation/code/main.py:99
↓ 3 callers
Function
ndcg_at_k
(retrieved: list[str], graded: dict[str, int], k: int)
phases/19-capstone-projects/68-rag-eval-precision-recall/code/main.py:84
↓ 3 callers
Function
newCallId
()
phases/13-tools-and-protocols/01-the-tool-interface/code/main.ts:156
↓ 3 callers
Function
new_trace_id
Random 16-byte hex string. Matches W3C trace context.
phases/19-capstone-projects/28-observability-otel-traces/code/main.py:119
↓ 3 callers
Function
newtons_method
(grad_f, hessian_f, x0, steps=100, tol=1e-12)
phases/01-math-foundations/18-convex-optimization/code/convex.py:87
↓ 3 callers
Function
normalise
(text: str)
phases/19-capstone-projects/39-instruction-tuning-sft/code/main.py:563
↓ 3 callers
Function
normalize_vector
(v)
phases/01-math-foundations/14-norms-and-distances/code/distances.py:170
↓ 3 callers
Function
numerical_gradient
(f, point, h=1e-7)
phases/01-math-foundations/04-calculus-for-ml/code/derivatives.py:9
↓ 3 callers
Function
numerical_gradient
(f, x, h=1e-5)
phases/01-math-foundations/13-numerical-stability/code/numerical.py:66
↓ 3 callers
Method
observe
(self, tick: int, content: str, importance: int = 3)
phases/16-multi-agent-and-swarms/17-generative-agents-simulation/code/main.py:41
↓ 3 callers
Function
one_hot
(c, num)
phases/08-generative-ai/07-latent-diffusion-stable-diffusion/code/main.py:15
↓ 3 callers
Method
optimize
(self, objective, n_iter=50)
phases/02-ml-fundamentals/12-hyperparameter-tuning/code/tuning.py:275
← previous
next →
1,201–1,300 of 8,347, ranked by callers