Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/FareedKhan-dev/train-llm-from-scratch
/ functions
Functions
252 in github.com/FareedKhan-dev/train-llm-from-scratch
⨍
Functions
252
◇
Types & classes
18
↓ 1 callers
Function
tokenize_to_h5
(zst_paths: list[str], out_path: str, max_tokens: int | None)
scripts/prepare_pretrain_data.py:76
↓ 1 callers
Function
unique_output_path
Avoid overwriting an existing final model checkpoint.
scripts/train_transformer.py:277
↓ 1 callers
Function
verify_eval_benchmark
Prove the GSM8K scoring is correct independent of any model: a response containing the gold scores correct; a wrong number scores incorrect.
tests/verify_data_and_eval.py:105
↓ 1 callers
Function
verify_grpo_optimizes
()
tests/verify_rl_optimizes.py:36
↓ 1 callers
Function
verify_pile
()
tests/verify_data_and_eval.py:25
↓ 1 callers
Function
verify_ppo_optimizes
()
tests/verify_rl_optimizes.py:62
↓ 1 callers
Function
verify_preferences
()
tests/verify_data_and_eval.py:67
↓ 1 callers
Function
verify_rl_prompts_and_gold
Gold answers in the RL prompt files must match the GSM8K dataset's #### answer.
tests/verify_data_and_eval.py:82
↓ 1 callers
Function
verify_sft_mask_alignment
The critical SFT check: the loss_mask must be 1 EXACTLY on assistant-completion tokens and 0 on the prompt / role markers. We decode masked vs unm
tests/verify_data_and_eval.py:39
Method
__init__
(self, transformer: Transformer)
src/post_training/reward_model.py:40
Method
__init__
(self, transformer: Transformer)
src/post_training/value_head.py:26
Method
__init__
( self, stage: str, log_dir: str, *, use_wandb: bool = False,
src/post_training/logging_utils.py:19
Method
__init__
Initializes the multi-head attention module. Args: n_head (int): The number of parallel attention heads. n_e
src/models/attention.py:72
Method
__init__
Initializes the Transformer block. Args: n_head (int): The number of attention heads. n_embed (int): The dim
src/models/transformer_block.py:18
Method
__init__
Initializes the MLP module. Args: n_embed (int): The dimensionality of the input embedding.
src/models/mlp.py:16
Method
__init__
Initializes the Transformer model. Args: n_head (int): Number of attention heads. n_embed (int): Embedding d
src/models/transformer.py:23
Function
active_jobs
()
ui/jobs.py:151
Function
barrier
(ctx: DDPContext)
src/post_training/distributed.py:93
Function
checkpoint_step
Extract the step number from a checkpoint filename.
scripts/train_transformer.py:118
Method
context_length
(self)
src/post_training/reward_model.py:48
Method
context_length
(self)
src/post_training/value_head.py:42
Method
enabled
(self)
src/post_training/distributed.py:32
Function
extract_think
Return the content of the first ``<think>...</think>`` block, if any.
src/post_training/rewards/parsing.py:41
Method
forward
Scalar reward per sequence (B,). Args: idx: (B, T) token ids. seq_lengths: (B,) number of real (non-pad) tok
src/post_training/reward_model.py:56
Method
forward
(self, idx: torch.Tensor)
src/post_training/value_head.py:45
Method
forward
Forward pass through the attention head. Args: x (torch.Tensor): Input tensor of shape (B, T, C). Returns:
src/models/attention.py:35
Method
forward
Forward pass through the multi-head attention. Args: x (torch.Tensor): Input tensor of shape (B, T, C). Returns
src/models/attention.py:85
Method
forward
Forward pass through the Transformer block. Args: x (torch.Tensor): Input tensor. Returns: torch.Te
src/models/transformer_block.py:33
Method
forward
Forward pass through the MLP. Args: x (torch.Tensor): Input tensor of shape (B, T, C), where B is batch size,
src/models/mlp.py:28
Method
forward
Forward pass through the Transformer. Args: idx (torch.Tensor): Input token indices. targets (torch.Tensor,
src/models/transformer.py:90
Method
forward_embedding
Forward pass focusing on the embedding and attention parts. Args: x (torch.Tensor): Input tensor. Returns:
src/models/transformer_block.py:49
Method
forward_embedding
Forward pass focusing on the embedding and attention blocks. Args: idx (torch.Tensor): Input token indices. Ret
src/models/transformer.py:114
Function
gpu_busy
Return the job_id of a *running* GPU job, if any (for the launch guard).
ui/jobs.py:138
Function
gpu_status
Return a list of (idx, name, used_mb, total_mb, util) via nvidia-smi, or [].
ui/theme.py:49
Function
hero
(title: str, subtitle: str)
ui/theme.py:40
Method
is_main
(self)
src/post_training/distributed.py:28
Function
is_main_process
(ctx: DDPContext)
src/post_training/distributed.py:78
Function
latest_log
(prefix: str)
ui/metrics.py:12
Function
launch
Start ``argv`` as a detached background job. ``kind`` is 'gpu' or 'cpu' (for the guard).
ui/jobs.py:82
Function
load_metrics
(path: str)
ui/metrics.py:17
Function
masked_mean_per_row
Per-row (B,) mean of ``values`` (B,T) over masked positions.
src/post_training/utils.py:124
Function
metric_columns
Numeric columns worth plotting (drop bookkeeping).
ui/metrics.py:32
Function
parse_config
Parse CLI overrides for a config dataclass. Returns ``(cfg, extras)`` where ``cfg`` is an instance of ``cfg_cls`` with any provided ``--
src/post_training/cli.py:29
Function
render_chat
Render a list of ``{"role", "content"}`` messages to the plain-text chat format. This is purely for display/debugging; tokenization goes thr
src/post_training/chat_template.py:73
Function
reward_format
Pure format reward (no gold): 1.0 if exactly one well-formed answer block else 0.
src/post_training/rewards/verifiers.py:49
Function
sequence_entropy
Per-token predictive entropy ``(B, T-1)`` of ``model`` on ``sequences`` (for an optional PPO entropy bonus / diagnostics).
src/post_training/rollout.py:287
Function
setup_page
(title: str, icon: str = "🧠")
ui/theme.py:35
Function
shard_indices
Return this rank's strided slice of ``range(num_items)`` for data sharding.
src/post_training/distributed.py:103
Function
status
Return 'running' | 'finished' | 'failed' | 'none'.
ui/jobs.py:100
Function
status_badge
(status: str)
ui/theme.py:44
Function
stop
Terminate a running job and all its workers (process group).
ui/jobs.py:113
Method
value_only
Per-token values without computing the (large) vocab logits -- used when scoring rollouts where only V(s_t) is needed.
src/post_training/value_head.py:52
← previous
201–252 of 252, ranked by callers