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
↓ 8 callers
Method
content_hash
(self)
phases/19-capstone-projects/07-end-to-end-fine-tuning-pipeline/code/main.py:33
↓ 8 callers
Function
cosine_similarity
(a, b)
phases/01-math-foundations/14-norms-and-distances/code/distances.py:44
↓ 8 callers
Method
count_windows
(num_ids: int, context_length: int, stride: int)
phases/19-capstone-projects/31-tokenized-dataset-sliding-window/code/main.py:177
↓ 8 callers
Function
decode
Decode `ids` back to a string. Inverse of `encode` for round-trip safe input.
phases/19-capstone-projects/30-bpe-tokenizer-from-scratch/code/main.py:220
↓ 8 callers
Function
det_2x2
(m)
phases/01-math-foundations/03-matrix-transformations/code/transformations.py:56
↓ 8 callers
Function
dot_product
(a, b)
phases/01-math-foundations/14-norms-and-distances/code/distances.py:40
↓ 8 callers
Function
dpo_loss
Per-example DPO loss and the implicit reward margin. L = -log sigmoid( beta * ( (logp_w_pol - logp_w_ref) - (logp_l_pol - logp_l_ref) ) ) Re
phases/19-capstone-projects/40-dpo-from-scratch/code/main.py:236
↓ 8 callers
Method
encode
(self, text)
phases/10-llms-from-scratch/01-tokenizers/code/main.py:51
↓ 8 callers
Function
escapeHtml
(value: string)
phases/19-capstone-projects/04-multimodal-document-qa/code/ts/src/render.ts:4
↓ 8 callers
Function
euler
(theta)
phases/01-math-foundations/19-complex-numbers/code/complex_numbers.py:79
↓ 8 callers
Method
evaluate
(self, call: ToolCall, ctx: GateContext)
phases/19-capstone-projects/25-verification-gates-observation-budget/code/main.py:173
↓ 8 callers
Method
execute
(self, name: str, context: dict[str, Any] | None = None)
phases/14-agent-engineering/10-skill-libraries-voyager/code/main.py:85
↓ 8 callers
Method
fire
(self, event: str, payload: dict[str, Any])
phases/19-capstone-projects/01-terminal-native-coding-agent/code/main.py:94
↓ 8 callers
Function
fixture_tasks
()
phases/19-capstone-projects/75-end-to-end-eval-runner/code/tests/test_runner.py:47
↓ 8 callers
Function
in_text
(idx: int)
phases/12-multimodal-ai/13-transfusion-autoregressive-diffusion/code/main.py:63
↓ 8 callers
Method
listen
(self, topic: str)
phases/14-agent-engineering/15-crewai-role-based-crews/code/main.py:135
↓ 8 callers
Function
load_safetensors
Load weights into model. Refuse to assign on shape mismatch. Returns a report.
phases/19-capstone-projects/37-loading-pretrained-weights/code/main.py:212
↓ 8 callers
Function
make_batches
Yield (input, target) batches where target is input shifted by one position. Sampling is uniform random over valid start positions. With a fixed
phases/19-capstone-projects/36-training-loop-eval/code/main.py:181
↓ 8 callers
Function
matvec
(M: List[List[float]], v: List[float])
phases/10-llms-from-scratch/18-multi-token-prediction/code/main.py:27
↓ 8 callers
Method
normalize
(self)
phases/12-multimodal-ai/10-internvl3-native-multimodal/code/main.py:23
↓ 8 callers
Method
on
(self, topic: str, fn: Callable[[dict], Any])
phases/19-capstone-projects/20-agent-harness-loop-contract/code/main.py:124
↓ 8 callers
Function
percentile
(sorted: number[], p: number)
phases/19-capstone-projects/11-llm-observability-dashboard/code/ts/src/rollup.ts:4
↓ 8 callers
Method
predict
(self, X)
phases/02-ml-fundamentals/04-decision-trees/code/trees.py:101
↓ 8 callers
Function
pretty
human-readable.
phases/07-transformers-deep-dive/13-scaling-laws/code/main.py:38
↓ 8 callers
Method
process
(self, prompt: str)
phases/19-capstone-projects/15-constitutional-safety-harness/code/main.py:99
↓ 8 callers
Function
px
(f)
site/figures-vision-speech.js:304
↓ 8 callers
Function
py
(y)
site/figures-transformers.js:196
↓ 8 callers
Function
read
()
site/progress.js:33
↓ 8 callers
Function
refuseReason
(args: LaunchArgs)
phases/19-capstone-projects/10-multi-agent-software-team/code/ts/src/runtime.ts:48
↓ 8 callers
Method
run
(self, spec: ExperimentSpec)
phases/19-capstone-projects/52-experiment-runner/code/main.py:182
↓ 8 callers
Method
run
(self, paper: MiniPaper)
phases/19-capstone-projects/55-critic-loop/code/main.py:166
↓ 8 callers
Function
run_mesh
Run the chosen primitive on the queue mesh and return per-rank outputs plus byte total.
phases/19-capstone-projects/76-collective-ops-from-scratch/code/main.py:300
↓ 8 callers
Function
save_sharded
Write per-rank state files atomically; return the manifest written. per_rank_state is a list indexed by rank. Each entry is a state dict that
phases/19-capstone-projects/80-checkpoint-sharded-resume/code/main.py:105
↓ 8 callers
Method
set
(key: K, value: V)
phases/17-infrastructure-and-production/14-prompt-semantic-caching/code/main.ts:64
↓ 8 callers
Function
shell
(host, label, hint, grid, outKids, cap)
site/figures-nlp2.js:11
↓ 8 callers
Function
shell
(label, hint, grid, outKids, caption)
site/figures-vision-speech.js:15
↓ 8 callers
Function
sigmoid
(x: float)
phases/18-ethics-safety-alignment/03-direct-preference-optimization-family/code/main.py:39
↓ 8 callers
Function
simulate_float16
(x)
phases/01-math-foundations/13-numerical-stability/code/numerical.py:122
↓ 8 callers
Function
span
(model: string, latencyMs: number, status: "OK" | "ERROR" = "OK")
phases/19-capstone-projects/11-llm-observability-dashboard/code/ts/tests/rollup.test.ts:6
↓ 8 callers
Method
step
(self, batch_inputs: torch.Tensor, batch_targets: torch.Tensor)
phases/19-capstone-projects/44-cosine-lr-warmup/code/main.py:158
↓ 8 callers
Function
synthCall
(script: string, startMs = 0, noise = 0)
phases/19-capstone-projects/03-realtime-voice-assistant/code/ts/src/vad.ts:14
↓ 8 callers
Function
tokenize
(text)
phases/05-nlp-foundations-to-advanced/27-llm-evaluation-frameworks/code/main.py:9
↓ 8 callers
Function
tokenize
(text: str)
phases/19-capstone-projects/69-end-to-end-rag-system/code/main.py:45
↓ 8 callers
Function
train_test_split
(X, y, test_ratio=0.2, seed=42)
phases/02-ml-fundamentals/11-ensemble-methods/code/ensembles.py:20
↓ 8 callers
Method
update
(self, tid: str, **changes)
phases/13-tools-and-protocols/13-mcp-async-tasks/code/main.py:77
↓ 8 callers
Function
variance
(data, sample=True)
phases/01-math-foundations/15-statistics-for-ml/code/statistics.py:30
↓ 8 callers
Method
write_corpus
(self, shards: dict[str, Iterable[str]])
phases/19-capstone-projects/43-hdf5-tokenized-corpus/code/main.py:227
↓ 8 callers
Method
zero_grad
(self)
phases/19-capstone-projects/78-zero-parameter-sharding/code/main.py:161
↓ 7 callers
Method
__init__
(self, parameters, lr=0.01)
phases/03-deep-learning-core/10-mini-framework/code/main.py:282
↓ 7 callers
Function
_baseline_tokens
(text: str)
phases/19-capstone-projects/68-rag-eval-precision-recall/code/main.py:268
↓ 7 callers
Function
_indent_of
(line: str)
phases/19-capstone-projects/86-constitutional-rules-engine/code/yaml_subset.py:45
↓ 7 callers
Function
_make_root
()
phases/19-capstone-projects/26-sandbox-runner-denylist/code/tests/test_main.py:29
↓ 7 callers
Function
_tiny_cfg
(**overrides)
phases/19-capstone-projects/37-loading-pretrained-weights/code/tests/test_load.py:31
↓ 7 callers
Method
act
(self, memory: EpisodicMemory)
phases/14-agent-engineering/03-reflexion-verbal-rl/code/main.py:42
↓ 7 callers
Function
add
(a, b)
phases/08-generative-ai/02-autoencoders-vae/code/main.py:9
↓ 7 callers
Method
add
(self, doc: Doc)
phases/19-capstone-projects/65-hybrid-retrieval-bm25-dense/code/main.py:67
↓ 7 callers
Method
add_paper
(self, paper: Paper)
phases/19-capstone-projects/51-literature-retrieval/code/main.py:117
↓ 7 callers
Method
answer
(self, correct: str, rng: random.Random)
phases/16-multi-agent-and-swarms/15-voting-debate-topology/code/main.py:21
↓ 7 callers
Function
arrow
(x2, y2, st, w)
site/figures-math.js:21
↓ 7 callers
Function
bleu4
(prediction: str, reference: str, max_n: int = 4)
phases/19-capstone-projects/71-classical-metrics/code/main.py:83
↓ 7 callers
Function
bubble_fraction
Closed-form bubble fraction per stage for GPipe. Forward takes M + N - 1 cycles per stage (M useful + N - 1 idle warmup). Backward takes M +
phases/19-capstone-projects/79-pipeline-parallel/code/main.py:37
↓ 7 callers
Function
buildApp
(options: AppOptions = {})
phases/19-capstone-projects/06-devops-troubleshooting-agent/code/ts/src/server.ts:26
↓ 7 callers
Function
buildIndex
* Build the flat search index once from window.PHASES and window.GLOSSARY. * Idempotent: subsequent calls return the cached array.
site/cmdpalette.js:33
↓ 7 callers
Function
build_demo_scripts
Scripted responses for the demo seed prompt across temperature buckets.
phases/19-capstone-projects/50-hypothesis-generator/code/main.py:258
↓ 7 callers
Function
classify_refusal
(response: str)
phases/19-capstone-projects/84-refusal-evaluation/code/main.py:54
↓ 7 callers
Function
compute_metrics
(y_true, y_pred)
phases/02-ml-fundamentals/17-imbalanced-data/code/imbalanced.py:139
↓ 7 callers
Function
count_tokens
(text)
phases/11-llm-engineering/05-context-engineering/code/main.py:6
↓ 7 callers
Function
deterministic_score
Score a paper deterministically across the five dimensions, 0..10 each.
phases/19-capstone-projects/55-critic-loop/code/main.py:214
↓ 7 callers
Method
encode
(self, text)
phases/10-llms-from-scratch/02-building-a-tokenizer/code/main.py:97
↓ 7 callers
Method
encode_pair
Return (token_ids, response_start_index). Truncates to max_len if needed but always keeps the RESP marker plus at least one response t
phases/19-capstone-projects/39-instruction-tuning-sft/code/main.py:46
↓ 7 callers
Function
entropy
(probs, base=2)
phases/01-math-foundations/09-information-theory/code/information_theory.py:13
↓ 7 callers
Function
exact_match
(prediction: str, targets: list[str])
phases/19-capstone-projects/71-classical-metrics/code/main.py:27
↓ 7 callers
Function
expectedSig
(body: Buffer | string, secret: string)
phases/19-capstone-projects/16-github-issue-to-pr-agent/code/ts/src/verify.ts:3
↓ 7 callers
Function
extract_answer
(text)
phases/11-llm-engineering/02-few-shot-cot/code/advanced_prompting.py:104
↓ 7 callers
Function
f
(x)
phases/01-math-foundations/18-convex-optimization/code/convex.py:214
↓ 7 callers
Method
fit
(self, X, y)
phases/02-ml-fundamentals/05-support-vector-machines/code/svm.py:62
↓ 7 callers
Method
fit
(self, X, y)
phases/02-ml-fundamentals/04-decision-trees/code/trees.py:90
↓ 7 callers
Method
fit
(self, X, y)
phases/02-ml-fundamentals/15-time-series/code/time_series.py:112
↓ 7 callers
Method
fit_transform
(self, X)
phases/02-ml-fundamentals/13-ml-pipelines/code/pipeline.py:74
↓ 7 callers
Function
fmt_billions
(x: int)
phases/10-llms-from-scratch/14-open-models-architecture-walkthroughs/code/main.py:240
↓ 7 callers
Function
generate
Autoregressive generation with multinomial sampling, temperature, top-k. Holds the active window to model.cfg.context_length by sliding the oldes
phases/19-capstone-projects/35-gpt-model-assembly/code/main.py:192
↓ 7 callers
Method
get
(self, name: str)
phases/19-capstone-projects/23-function-call-dispatcher/code/main.py:88
↓ 7 callers
Method
getOrCreate
(id: string, role: string, jurisdiction: string)
phases/19-capstone-projects/08-production-rag-chatbot/code/ts/src/session.ts:6
↓ 7 callers
Method
grad_logprob
(self, a: int)
phases/18-ethics-safety-alignment/03-direct-preference-optimization-family/code/main.py:63
↓ 7 callers
Function
hasShellMetachars
(arg: string)
phases/19-capstone-projects/10-multi-agent-software-team/code/ts/src/runtime.ts:40
↓ 7 callers
Method
inc
(self, labels: dict[str, str] | None = None, by: float = 1.0)
phases/19-capstone-projects/28-observability-otel-traces/code/main.py:205
↓ 7 callers
Function
inject_lora
(model, target_modules, rank=8, alpha=16)
phases/11-llm-engineering/08-fine-tuning-lora/code/lora.py:35
↓ 7 callers
Function
load_sharded
Read the manifest, verify every shard, return (manifest, per-rank state list).
phases/19-capstone-projects/80-checkpoint-sharded-resume/code/main.py:159
↓ 7 callers
Function
make_stub_safetensors
Generate a fixture file with the pretrained naming convention. Tensors are random but reproducible from `seed`. Shapes match what a real GPT-
phases/19-capstone-projects/37-loading-pretrained-weights/code/main.py:283
↓ 7 callers
Function
matmul
(W, x)
phases/08-generative-ai/02-autoencoders-vae/code/main.py:5
↓ 7 callers
Function
model_fn
(batch)
phases/10-llms-from-scratch/05-scaling-distributed/code/main.py:256
↓ 7 callers
Function
neg_mse
(model, X, y)
phases/02-ml-fundamentals/12-hyperparameter-tuning/code/tuning.py:118
↓ 7 callers
Function
normal_pdf
(x, mu, sigma)
phases/01-math-foundations/16-sampling-methods/code/sampling.py:25
↓ 7 callers
Function
normalise_for_em
(text: str)
phases/19-capstone-projects/41-eval-pipeline/code/main.py:189
↓ 7 callers
Function
normalise_metric
Map a raw metric onto [0, 1].
phases/19-capstone-projects/41-eval-pipeline/code/main.py:624
↓ 7 callers
Method
on
(event: HookEvent, fn: HookFn)
phases/19-capstone-projects/01-terminal-native-coding-agent/code/ts/src/hooks.ts:21
↓ 7 callers
Function
pad
(s: string | number, n: number, left = true)
phases/17-infrastructure-and-production/13-llm-observability/code/main.ts:289
↓ 7 callers
Function
pass_at_k
Probability of at least one pass in k independent samples.
phases/19-capstone-projects/27-eval-harness-fixture-tasks/code/main.py:132
↓ 7 callers
Function
print_confusion_matrix
(y_true, y_pred, label="")
phases/02-ml-fundamentals/17-imbalanced-data/code/imbalanced.py:186
↓ 7 callers
Function
print_metrics
(metrics, label="")
phases/02-ml-fundamentals/17-imbalanced-data/code/imbalanced.py:194
← previous
next →
301–400 of 8,347, ranked by callers