MCPcopy Create free account

hub / github.com/FareedKhan-dev/train-llm-from-scratch / functions

Functions604 in github.com/FareedKhan-dev/train-llm-from-scratch

↓ 1 callersFunctionpad
(seq, fill)
data_loader/preference_dataset.py:97
↓ 1 callersFunctionparse_args
()
scripts/train_transformer.py:414
↓ 1 callersFunctionparse_override
Split ``key=value``. Values are read as JSON (true, 2, 1e-3, null), anything else as text.
scripts/train_transformer.py:507
↓ 1 callersFunctionplot_gsm8k
()
images/plot_artifacts.py:50
↓ 1 callersFunctionplot_loss
()
images/plot_artifacts.py:26
↓ 1 callersFunctionprint_table
(path: str)
scripts/eval_post_training.py:36
↓ 1 callersFunctionprocess_files
Process a specified number of lines from each .jsonl.zst file in the input directory and save encoded tokens to an HDF5 file. Args:
scripts/data_preprocess.py:11
↓ 1 callersMethodproject_embedding
Applies the projection linear layer. Args: x (torch.Tensor): Input tensor. Returns: torch.Tensor: O
src/models/mlp.py:56
↓ 1 callersFunctionread_data_info
Tokenizer spec and vocab size stored in a token file (None for files that lack them).
scripts/train_transformer.py:125
↓ 1 callersFunctionread_eval
(path: Path)
docs/diagrams/make_plots.py:244
↓ 1 callersFunctionrecord
(name: str)
tests/test_inference.py:47
↓ 1 callersFunctionrender_doc
Render the diagram (if any) + the prose of a docs markdown file.
ui/docs_render.py:29
↓ 1 callersFunctionrender_form
(stage: Stage, smoke: bool = False, nproc: int = 1)
ui/config_forms.py:52
↓ 1 callersFunctionreply
(text)
scripts/chat.py:53
↓ 1 callersFunctionreport
(cfg: dict[str, Any], args: argparse.Namespace)
scripts/model_report.py:100
↓ 1 callersMethodreset
(self)
src/models/modern/kv_cache.py:57
↓ 1 callersFunctionresolve_train_config
config/config.py, then the preset, then command-line flags (later wins).
scripts/train_transformer.py:522
↓ 1 callersFunctionreward_margin
Mean reward gap (chosen - rejected); a useful training diagnostic.
src/post_training/reward_train.py:28
↓ 1 callersFunctionround_up
(value: int, multiple: int)
src/models/modern/config.py:30
↓ 1 callersFunctionround_up
Pad the vocabulary to a multiple of 64: matrix multiplies run faster on those sizes.
scripts/train_transformer.py:134
↓ 1 callersFunctionrounded_hbar
A horizontal bar with a rounded data-end and a square baseline.
docs/diagrams/make_plots.py:146
↓ 1 callersFunctionrun
(script: str, *args: object)
tests/test_pipeline_e2e.py:67
↓ 1 callersFunctionsample_text
Generate a short continuation of ``prompt`` with the training tokenizer.
scripts/train_transformer.py:140
↓ 1 callersFunctionscore
(m: int, n: int)
tests/test_modern_model.py:109
↓ 1 callersFunctionscore
(m: int, n: int)
docs/diagrams/make_plots.py:127
↓ 1 callersFunctionseq_lengths_from_mask
Real token count per row = last response position + 1 (or prompt_len if no response).
scripts/train_ppo.py:81
↓ 1 callersFunctionseq_lengths_from_mask
(response_mask, prompt_lens)
scripts/train_grpo.py:50
↓ 1 callersFunctionsequence_logprobs
Sequence-level summed log-prob over response tokens (used by DPO/KTO/ORPO). Returns ``(sum_logprob, n_tokens)`` each shape (B,). The per-tok
src/post_training/rollout.py:263
↓ 1 callersFunctionshard_urls
(split: str, num_shards: int)
scripts/prepare_pretrain_data.py:38
↓ 1 callersFunctionside
(response_ids: list[int])
data_loader/preference_dataset.py:81
↓ 1 callersFunctionsplit_stories
TinyStories separates stories with <|endoftext|> lines. Drop a cut-off last story.
scripts/prepare_tiny_data.py:80
↓ 1 callersFunctionsplit_text
Split one long text into train / val at a line break near ``1 - val_frac``.
scripts/prepare_tiny_data.py:88
↓ 1 callersFunctionstep
()
scripts/benchmark.py:49
↓ 1 callersFunctionsync_step
Flush pending work on lazy backends. Needed once per optimizer step on XLA (TPU).
src/device.py:78
↓ 1 callersFunctiontail_log
(job_id: str, max_bytes: int = 16000)
ui/jobs.py:151
↓ 1 callersFunctiontest_build_from_config
()
tests/test_post_training_smoke.py:162
↓ 1 callersFunctiontest_chat_template_masking
()
tests/test_post_training_smoke.py:106
↓ 1 callersFunctiontest_checkpoint_round_trip_and_latest_resume
()
tests/test_checkpoint_resume.py:41
↓ 1 callersFunctiontest_checkpoint_save_failure_does_not_leave_partial_file
()
tests/test_checkpoint_resume.py:81
↓ 1 callersFunctiontest_compute_logprobs_matches_manual
()
tests/test_post_training_smoke.py:40
↓ 1 callersFunctiontest_context_cap_enforced
()
tests/test_post_training_smoke.py:68
↓ 1 callersFunctiontest_forward_hidden_matches_forward
()
tests/test_post_training_smoke.py:30
↓ 1 callersFunctiontest_frozen_copy_and_reductions
()
tests/test_post_training_smoke.py:94
↓ 1 callersFunctiontest_gae_masks_outside_response
()
tests/test_rl_math.py:27
↓ 1 callersFunctiontest_gae_reward_to_go
()
tests/test_rl_math.py:13
↓ 1 callersFunctiontest_group_advantages
()
tests/test_rl_math.py:59
↓ 1 callersFunctiontest_grpo_loss_and_kl
()
tests/test_rl_math.py:68
↓ 1 callersFunctiontest_ppo_losses
()
tests/test_rl_math.py:45
↓ 1 callersFunctiontest_preference_truncation_preserves_responses
()
tests/test_post_training_smoke.py:130
↓ 1 callersFunctiontest_reward_parsing
()
tests/test_post_training_smoke.py:119
↓ 1 callersFunctiontest_rollout_logprobs_consistent
()
tests/test_post_training_smoke.py:53
↓ 1 callersFunctiontest_value_and_reward_heads
()
tests/test_post_training_smoke.py:76
↓ 1 callersFunctiontest_whiten
()
tests/test_rl_math.py:36
↓ 1 callersFunctiontext
(n: int)
tests/test_preference_truncation.py:72
↓ 1 callersMethodtoken_rewards
Per-token scalar reward (B, T) -- useful for diagnostics / dense shaping.
src/post_training/reward_model.py:47
↓ 1 callersFunctiontokenize_to_h5
(zst_paths: list[str], out_path: str, max_tokens: int | None)
scripts/prepare_pretrain_data.py:76
↓ 1 callersFunctiontraining_curves
(name: str, runs: list[tuple[str, str, str]], title: str, vocab: int)
docs/diagrams/make_plots.py:255
↓ 1 callersFunctionunique_output_path
Avoid overwriting an existing final model checkpoint.
scripts/train_transformer.py:343
↓ 1 callersFunctionverify_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:103
↓ 1 callersFunctionverify_grpo_optimizes
()
tests/verify_rl_optimizes.py:36
↓ 1 callersFunctionverify_pile
()
tests/verify_data_and_eval.py:25
↓ 1 callersFunctionverify_ppo_optimizes
()
tests/verify_rl_optimizes.py:62
↓ 1 callersFunctionverify_preferences
()
tests/verify_data_and_eval.py:67
↓ 1 callersFunctionverify_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 callersFunctionverify_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
↓ 1 callersFunctionwrite_h5
(path: Path, tokens: np.ndarray, spec: dict, source: str, n_docs: int)
scripts/prepare_tiny_data.py:140
↓ 1 callersFunctionwrite_jsonl
(rows: list[dict], path: str)
scripts/prepare_preference_data.py:91
↓ 1 callersFunctionwrite_jsonl
(rows, path)
scripts/prepare_rl_prompts.py:27
↓ 1 callersFunctionwrite_packed
(examples, context_length: int, out_path: str)
scripts/prepare_sft_data.py:101
↓ 1 callersFunctionwsd_lr
Warmup, stay at ``lr``, then decay linearly to ``min_lr`` over the last ``decay_frac``.
src/optim/schedules.py:43
Method__enter__
(self)
tests/test_data_tools.py:66
Method__exit__
(self, *exc: object)
tests/test_data_tools.py:69
Method__init__
(self, transformer: LanguageModel)
src/post_training/reward_model.py:36
Method__init__
(self, transformer: LanguageModel)
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__
( self, params: Iterable[dict[str, Any]], lr: float = 3e-4, weight_decay: floa
src/optim/muon.py:76
Method__init__
(self, linear: nn.Linear)
src/inference/quantize.py:38
Method__init__
Initializes the multi-head attention module. Args: n_head (int): The number of parallel attention heads. n_e
src/models/attention.py:75
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:28
Method__init__
(self, base: nn.Linear, rank: int, alpha: float = 16.0, dropout: float = 0.0)
src/models/lora.py:37
Method__init__
(self, cfg: ModernConfig, layer_idx: int)
src/models/modern/block.py:26
Method__init__
(self, n_embed: int, hidden: int, n_experts: int, top_k: int, n_shared: int = 0)
src/models/modern/moe.py:41
Method__init__
(self, dim: int, eps: float = 1e-6)
src/models/modern/norm.py:22
Method__init__
(self, cfg: ModernConfig, layer_idx: int)
src/models/modern/attention.py:125
Method__init__
(self, n_embed: int, hidden: int)
src/models/modern/mlp.py:23
Method__init__
( self, n_layers: int, batch_size: int, max_len: int, n_kv_heads: int,
src/models/modern/kv_cache.py:24
Method__init__
(self, config: ModernConfig)
src/models/modern/model.py:47
Method__init__
( self, merges: Sequence[Pair], special_tokens: Sequence[str] = (EOT,), patter
src/tokenizer/bpe.py:65
Method__init__
(self, body: bytes, status: int = 200, length: int | None = None)
tests/test_data_tools.py:54
Method__post_init__
(self)
src/models/modern/config.py:63
Method__post_init__
(self)
config/post_training_config.py:81
Method__post_init__
(self)
config/post_training_config.py:114
Method__post_init__
(self)
config/post_training_config.py:165
Method__post_init__
(self)
config/post_training_config.py:191
Method__post_init__
(self)
config/post_training_config.py:253
Function_arc
(doc: dict[str, Any])
src/benchmarks/tasks.py:52
Function_cfg_get
Read a field from either a dataclass/object (attr) or a dict.
src/post_training/utils.py:53
Function_deep_merge
Recursively merge ``src`` into ``dst`` (nested-dict aware; future-proof).
config/loader.py:46
← previousnext →301–400 of 604, ranked by callers