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
↓ 1 callers
Method
encode
(self, text)
phases/10-llms-from-scratch/01-tokenizers/code/main.py:5
↓ 1 callers
Function
encodeBpe
(word: string, merges: readonly Merge[])
phases/05-nlp-foundations-to-advanced/19-subword-tokenization/code/main.ts:116
↓ 1 callers
Function
encode_bpe
(word, merges)
phases/05-nlp-foundations-to-advanced/19-subword-tokenization/code/main.py:59
↓ 1 callers
Function
encode_converter
(s: str)
phases/18-ethics-safety-alignment/16-red-team-tooling-garak-llamaguard-pyrit/code/main.py:90
↓ 1 callers
Method
encode_pair
(self, instruction: str, response: str, max_len: int)
phases/19-capstone-projects/41-eval-pipeline/code/main.py:45
↓ 1 callers
Method
encode_prefix
Encode just the instruction prefix for generation. Always keeps the RESP marker so the model sees the same boundary as during training.
phases/19-capstone-projects/39-instruction-tuning-sft/code/main.py:62
↓ 1 callers
Method
encode_prefix
(self, instruction: str, max_len: int)
phases/19-capstone-projects/41-eval-pipeline/code/main.py:55
↓ 1 callers
Function
encode_text
(tokenizer: MiniBPE, text: str)
phases/19-capstone-projects/31-tokenized-dataset-sliding-window/code/main.py:125
↓ 1 callers
Function
encoder_block
(x, p)
phases/07-transformers-deep-dive/05-full-transformer/code/main.py:187
↓ 1 callers
Function
encoder_frames
(seconds, sr=16000, hop=160)
phases/06-speech-and-audio/05-whisper-architecture-finetuning/code/main.py:49
↓ 1 callers
Function
end_to_end_reliability
Probability that every step succeeds in sequence.
phases/15-autonomous-systems/01-long-horizon-agents/code/main.py:37
↓ 1 callers
Function
energy_vad
(chunk, threshold_dbfs=-40.0)
phases/06-speech-and-audio/14-voice-activity-detection-turn-taking/code/main.py:23
↓ 1 callers
Function
enrich_with_evals
Add eval child spans on each llm span.
phases/19-capstone-projects/11-llm-observability-dashboard/code/main.py:177
↓ 1 callers
Function
ensureBar
(src, dst)
site/figures.js:287
↓ 1 callers
Function
ensureStyles
()
site/lesson-figures.js:13
↓ 1 callers
Function
entropy
(p)
phases/08-generative-ai/11-audio-generation/code/main.py:31
↓ 1 callers
Function
epsilon_greedy
(net, state, rng, epsilon)
phases/09-reinforcement-learning/05-dqn/code/main.py:62
↓ 1 callers
Function
equalized_odds
(preds)
phases/18-ethics-safety-alignment/21-fairness-criteria-group-individual-counterfactual/code/main.py:71
↓ 1 callers
Function
equivalence_check
One full batch step vs accum_steps micro-batches must match. Scaled loss is `raw / accum_steps`; the accumulated gradient equals the full bat
phases/19-capstone-projects/46-gradient-accumulation/code/main.py:236
↓ 1 callers
Function
eras_table
()
phases/12-multimodal-ai/22-document-diagram-understanding/code/main.py:96
↓ 1 callers
Function
erf
(x)
site/lesson-figures.js:538
↓ 1 callers
Function
error
(mid: int, code: int, message: str, data: Any = None)
phases/13-tools-and-protocols/06-mcp-fundamentals/code/main.py:46
↓ 1 callers
Function
escapeHtml
(s: string)
phases/19-capstone-projects/11-llm-observability-dashboard/code/ts/src/server.ts:5
↓ 1 callers
Function
estimate_tokens
(text: str)
phases/19-capstone-projects/29-end-to-end-coding-task-demo/code/main.py:58
↓ 1 callers
Function
euclidean_distance
(a, b)
phases/02-ml-fundamentals/17-imbalanced-data/code/imbalanced.py:14
↓ 1 callers
Function
ev
Expected-value of the intervention given scenario-specific moral-patienthood probability.
phases/18-ethics-safety-alignment/19-model-welfare-research/code/main.py:29
↓ 1 callers
Function
eval_2d_gaussian
(means, covs, points)
phases/04-computer-vision/22-3d-gaussian-splatting/code/main.py:8
↓ 1 callers
Function
eval_faithfulness
(response: str, context: str)
phases/19-capstone-projects/11-llm-observability-dashboard/code/main.py:90
↓ 1 callers
Function
eval_pii_leak
(response: str)
phases/19-capstone-projects/11-llm-observability-dashboard/code/main.py:106
↓ 1 callers
Function
eval_sh_degree_3
(sh_coeffs, dirs)
phases/04-computer-vision/22-3d-gaussian-splatting/code/main.py:108
↓ 1 callers
Function
eval_toxicity
(response: str)
phases/19-capstone-projects/11-llm-observability-dashboard/code/main.py:99
↓ 1 callers
Function
evaluate
(model, loader, device, num_classes)
phases/04-computer-vision/04-image-classification/code/main.py:150
↓ 1 callers
Function
evaluate
(y_true, y_pred)
phases/05-nlp-foundations-to-advanced/05-sentiment-analysis/code/main.py:66
↓ 1 callers
Function
evaluate
(examples)
phases/05-nlp-foundations-to-advanced/21-nli-textual-entailment/code/main.py:51
↓ 1 callers
Function
evaluate
(a: float, op: str, b: float)
phases/14-agent-engineering/04-tree-of-thoughts-lats/code/main.py:38
↓ 1 callers
Method
evaluate
(self, data)
phases/03-deep-learning-core/07-regularization/code/main.py:198
↓ 1 callers
Method
evaluate
(self, call: ToolCall, ctx: GateContext)
phases/19-capstone-projects/25-verification-gates-observation-budget/code/main.py:294
↓ 1 callers
Function
evaluate_accuracy
(X, y, selected_mask, lr=0.1, epochs=200)
phases/02-ml-fundamentals/18-feature-selection/code/feature_selection.py:223
↓ 1 callers
Function
evaluate_expr
(e: Expr, x: float)
phases/15-autonomous-systems/03-alphaevolve-evolutionary-coding/code/main.py:31
↓ 1 callers
Function
evaluate_grounding
(predictions: list[Event], ground_truth: list[Event], tol_iou: float = 0.3)
phases/12-multimodal-ai/17-video-language-temporal-grounding/code/main.py:56
↓ 1 callers
Function
evaluate_ind
(Q1, Q2, episodes=100, rng=None)
phases/09-reinforcement-learning/10-multi-agent-rl/code/main.py:96
↓ 1 callers
Function
evaluate_instruction_following
(model, instructions)
phases/10-llms-from-scratch/06-instruction-tuning-sft/code/main.py:193
↓ 1 callers
Function
evaluate_joint
(Q, episodes=100, rng=None)
phases/09-reinforcement-learning/10-multi-agent-rl/code/main.py:111
↓ 1 callers
Function
evaluator
(task: str, candidate: str)
phases/14-agent-engineering/12-anthropic-workflow-patterns/code/main.py:177
↓ 1 callers
Function
evaluator_optimizer
(task: str, proposer: Callable[[str, str | None], str], evaluator: Callable[[str, str]
phases/14-agent-engineering/12-anthropic-workflow-patterns/code/main.py:77
↓ 1 callers
Function
evaluator_optimizer
(case: EvalCase)
phases/14-agent-engineering/30-eval-driven-agent-development/code/main.py:33
↓ 1 callers
Function
evolutionary_demo
()
phases/14-agent-engineering/11-planning-htn-and-evolutionary/code/main.py:147
↓ 1 callers
Function
exact_match
(pred, gold)
phases/05-nlp-foundations-to-advanced/13-question-answering/code/main.py:16
↓ 1 callers
Function
exact_match
(prediction, expected)
phases/10-llms-from-scratch/10-evaluation/code/main.py:36
↓ 1 callers
Method
exceeded
(self)
phases/19-capstone-projects/01-terminal-native-coding-agent/code/main.py:67
↓ 1 callers
Method
exceeded
(self)
phases/19-capstone-projects/20-agent-harness-loop-contract/code/main.py:83
↓ 1 callers
Method
exchange
(self, code: str, code_verifier: str, resource: str)
phases/13-tools-and-protocols/16-mcp-security-oauth-2-1/code/main.py:53
↓ 1 callers
Function
execute
(proposal: Proposal)
phases/15-autonomous-systems/15-propose-then-commit/code/main.py:65
↓ 1 callers
Function
execute_lesson
(entry: Path)
scripts/lesson_run.py:119
↓ 1 callers
Function
executor
(tool: str, args: dict)
phases/19-capstone-projects/24-plan-execute-control-flow/code/main.py:239
↓ 1 callers
Function
executor_weather
(city: str)
phases/13-tools-and-protocols/03-parallel-and-streaming-tool-calls/code/main.py:28
↓ 1 callers
Function
expand
Propose children by varying one config dimension at a time.
phases/19-capstone-projects/05-autonomous-research-agent/code/main.py:45
↓ 1 callers
Method
expected_score
(self, rating_a, rating_b)
phases/10-llms-from-scratch/10-evaluation/code/main.py:74
↓ 1 callers
Function
expected_speedup
Plain decode: 1 token per target forward. Spec decode at (alpha, K): expected 1 + K*alpha tokens per target forward, but each target forward c
phases/17-infrastructure-and-production/05-eagle3-speculative-decoding/code/main.py:23
↓ 1 callers
Function
expected_tokens_per_verify
(alpha, N)
phases/07-transformers-deep-dive/16-speculative-decoding/code/main.py:108
↓ 1 callers
Function
experiment_adam
(train_loader, test_loader, device)
phases/03-deep-learning-core/11-intro-to-pytorch/code/pytorch_intro.py:169
↓ 1 callers
Function
experiment_batchnorm
(train_loader, test_loader, device)
phases/03-deep-learning-core/11-intro-to-pytorch/code/pytorch_intro.py:187
↓ 1 callers
Function
experiment_sgd
(train_loader, test_loader, device)
phases/03-deep-learning-core/11-intro-to-pytorch/code/pytorch_intro.py:178
↓ 1 callers
Function
experiment_sgd_cosine
(train_loader, test_loader, device, epochs=10)
phases/03-deep-learning-core/11-intro-to-pytorch/code/pytorch_intro.py:196
↓ 1 callers
Method
export
(self, span: GenAISpan)
phases/19-capstone-projects/29-end-to-end-coding-task-demo/code/main.py:330
↓ 1 callers
Function
extend_thought
(thought, question, client, model, breadth=2)
phases/11-llm-engineering/02-few-shot-cot/code/advanced_prompting.py:249
↓ 1 callers
Function
extract
(text)
phases/05-nlp-foundations-to-advanced/26-relation-extraction-kg/code/main.py:25
↓ 1 callers
Function
extractJSONBlock
(raw: string)
phases/11-llm-engineering/03-structured-outputs/code/main.ts:194
↓ 1 callers
Function
extractLessonMeta
* Single-pass read of a lesson's docs/en.md. * * Returns: * summary — first `> blockquote` line (the lesson's one-liner motto). * keywords —
site/build.js:247
↓ 1 callers
Function
extractPath
(url)
site/progress.js:124
↓ 1 callers
Function
extractWithRetry
(text: string, maxRetries = 3)
phases/11-llm-engineering/03-structured-outputs/code/main.ts:205
↓ 1 callers
Function
extract_mentions
(text)
phases/05-nlp-foundations-to-advanced/24-coreference-resolution/code/main.py:27
↓ 1 callers
Function
extract_urls
Return list of (url, line_number) tuples preserving order.
scripts/link_check.py:155
↓ 1 callers
Function
extract_with_retry
(text, schema, max_retries=3)
phases/11-llm-engineering/03-structured-outputs/code/main.py:193
↓ 1 callers
Function
f
(x)
phases/03-deep-learning-core/12-intro-to-jax/code/jax_intro.py:112
↓ 1 callers
Function
f1_grad
(params)
phases/01-math-foundations/13-numerical-stability/code/numerical.py:418
↓ 1 callers
Function
f_grad
(x)
phases/01-math-foundations/18-convex-optimization/code/convex.py:319
↓ 1 callers
Function
f_val
(x, c=c)
phases/01-math-foundations/18-convex-optimization/code/convex.py:290
↓ 1 callers
Function
faithfulness
(answer, context)
phases/05-nlp-foundations-to-advanced/27-llm-evaluation-frameworks/code/main.py:17
↓ 1 callers
Function
fakeDecide
(userMsg: string, history: HistoryEntry[])
phases/13-tools-and-protocols/01-the-tool-interface/code/main.ts:162
↓ 1 callers
Function
fake_audio_encoder
(audio_seconds=3.0, dim=1280)
phases/06-speech-and-audio/10-audio-language-models/code/main.py:14
↓ 1 callers
Function
fake_client_sample
Stand-in for the client's LLM. Picks a canned response by keyword.
phases/13-tools-and-protocols/11-mcp-sampling/code/main.py:58
↓ 1 callers
Function
fake_decide
Stand-in for the model. Routes by keyword so the loop runs offline. Production substitute: swap this for provider.chat.completions.create with
phases/13-tools-and-protocols/01-the-tool-interface/code/main.py:131
↓ 1 callers
Function
fake_dense_rank
(query, corpus, top_k=5)
phases/05-nlp-foundations-to-advanced/14-information-retrieval-search/code/main.py:58
↓ 1 callers
Function
fake_generate
(prompt, rng=None)
phases/06-speech-and-audio/09-music-generation/code/main.py:51
↓ 1 callers
Function
fake_llm
(text)
phases/06-speech-and-audio/11-real-time-audio-processing/code/main.py:40
↓ 1 callers
Function
fake_llm_answer
(interleaved)
phases/06-speech-and-audio/10-audio-language-models/code/main.py:35
↓ 1 callers
Function
fake_mcp_call
(parent: Span, tool: str)
phases/13-tools-and-protocols/20-opentelemetry-genai/code/main.py:101
↓ 1 callers
Function
fake_mimi_decode
(tokens)
phases/06-speech-and-audio/15-streaming-speech-to-speech-moshi-hibiki/code/main.py:30
↓ 1 callers
Function
fake_mimi_encode
(audio_80ms)
phases/06-speech-and-audio/15-streaming-speech-to-speech-moshi-hibiki/code/main.py:24
↓ 1 callers
Function
fake_openai_stream
Three interleaved parallel calls. Real streams look like this.
phases/13-tools-and-protocols/03-parallel-and-streaming-tool-calls/code/main.py:86
↓ 1 callers
Function
fake_silero_vad
(chunk, prev_state, threshold=0.5)
phases/06-speech-and-audio/14-voice-activity-detection-turn-taking/code/main.py:28
↓ 1 callers
Function
fake_stt
(utterance_duration_s)
phases/06-speech-and-audio/11-real-time-audio-processing/code/main.py:34
↓ 1 callers
Function
fake_tool_execute
(span: Span, tool: str, args: dict)
phases/13-tools-and-protocols/20-opentelemetry-genai/code/main.py:92
↓ 1 callers
Function
fake_tts_first_audio
(text)
phases/06-speech-and-audio/11-real-time-audio-processing/code/main.py:45
↓ 1 callers
Function
fake_vit_output
()
phases/12-multimodal-ai/05-llava-visual-instruction-tuning/code/main.py:63
↓ 1 callers
Function
fake_web_fetch
Simulate web fetch + summarization latency.
phases/16-multi-agent-and-swarms/05-supervisor-orchestrator-pattern/code/main.py:43
↓ 1 callers
Function
faq_respond
(user_input, threshold=0.3)
phases/05-nlp-foundations-to-advanced/17-chatbots-rule-to-neural/code/main.py:40
↓ 1 callers
Function
fast_compress
FAST-style tokenizer: per-dim DCT + keep low-freq + quantize. trajectory: list of actions (list of floats), shape (T, D). Returns a flat integ
phases/12-multimodal-ai/21-embodied-vlas-openvla-pi0-groot/code/main.py:41
↓ 1 callers
Method
feature_importances
(self)
phases/02-ml-fundamentals/04-decision-trees/code/trees.py:269
← previous
next →
3,601–3,700 of 8,347, ranked by callers