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 callersFunction_log1mexp
Numerically stable log(1 - exp(x)) for x < 0.
src/post_training/dpo.py:116
↓ 1 callersFunction_logits
(model: LanguageModel, idx: Int[Tensor, "1 seq"], window: int)
src/inference/speculative.py:66
↓ 1 callersFunction_logps
(model, ids, mask, requires_grad)
scripts/train_dpo.py:47
↓ 1 callersFunction_model
()
tests/test_sft_accumulation.py:21
↓ 1 callersFunction_model_context_length
(model)
src/post_training/evaluation.py:18
↓ 1 callersMethod_moe_aux_loss
(self)
src/models/modern/model.py:113
↓ 1 callersFunction_mps_available
()
src/device.py:24
↓ 1 callersMethod_muon_step
(self, group: dict[str, Any])
src/optim/muon.py:108
↓ 1 callersFunction_probs
The distribution to sample from. The exactness guarantee holds for any filter applied to both models.
src/inference/speculative.py:52
↓ 1 callersFunction_resolve_base
(json_path: str | None, base_path: str | None)
config/loader.py:56
↓ 1 callersFunction_split_hh
Split an HH-RLHF conversation string into (prompt_context, final_response).
scripts/prepare_preference_data.py:28
↓ 1 callersFunction_stderr
(p: float, n: int)
src/benchmarks/tasks.py:87
↓ 1 callersFunction_textbook_bpe
The slow, obvious algorithm: recount every pair in every chunk after every merge.
tests/test_tokenizer.py:49
↓ 1 callersFunction_tiktoken
(name: str)
src/tokenizer/__init__.py:40
↓ 1 callersFunction_widget
(f, value)
ui/config_forms.py:25
↓ 1 callersFunction_write_json
(path: str, obj: dict)
ui/config_forms.py:45
↓ 1 callersFunction_xla_available
()
src/device.py:29
↓ 1 callersFunctionadd
(docs: list[str])
scripts/prepare_pretrain_data.py:102
↓ 1 callersFunctionadd
(messages)
scripts/prepare_sft_data.py:70
↓ 1 callersFunctionadjusted_lr
(lr: float, shape: torch.Size, mode: AdjustLR)
src/optim/muon.py:62
↓ 1 callersMethodadvance
Called once per forward pass, after every layer has stored its new entries.
src/models/modern/kv_cache.py:53
↓ 1 callersFunctionalpaca_to_messages
(ex: dict)
scripts/prepare_sft_data.py:50
↓ 1 callersFunctionapprox_kl
Mean approximate KL(old || new) over response tokens (a PPO health metric).
src/post_training/ppo.py:98
↓ 1 callersFunctionas_float
Convert scalar tensors/numbers to plain floats for checkpoint metadata.
scripts/train_transformer.py:354
↓ 1 callersFunctionatomic_save
``torch.save`` to a temporary file first, then rename, so a crash never leaves half a file.
src/checkpoint.py:123
↓ 1 callersFunctionautocast
Mixed-precision context for ``dtype`` in ``{"bf16", "fp16", None}``; a no-op on CPU or when off.
src/device.py:69
↓ 1 callersFunctionautocast_ctx
()
scripts/train_transformer.py:608
↓ 1 callersFunctionbenchmark
(preset: str, arch: str, device: str, steps: int, warmup: int, vocab: int | None)
scripts/benchmark.py:36
↓ 1 callersFunctionbradley_terry_loss
Mean ``-log sigmoid(chosen - rejected)`` over a batch of preference pairs.
src/post_training/reward_train.py:18
↓ 1 callersFunctionbuild_argv
Construct the exact command (torchrun for multi-GPU, else python).
ui/jobs.py:87
↓ 1 callersFunctionbuild_tokenizer
(args: argparse.Namespace, train_docs: list[str])
scripts/prepare_tiny_data.py:114
↓ 1 callersMethodbytes_per_token
Memory one token costs across all layers (keys + values).
src/models/modern/kv_cache.py:60
↓ 1 callersFunctioncollect
(source: str, max_n: int, split: str)
scripts/prepare_preference_data.py:77
↓ 1 callersFunctioncollect_examples
(context_length: int, limit_per_set: int | None)
scripts/prepare_sft_data.py:64
↓ 1 callersFunctionconfig_as_dict
A plain dict view of a dataclass instance, a mapping, or a namespace.
src/models/factory.py:33
↓ 1 callersFunctioncpu_name
()
scripts/benchmark.py:32
↓ 1 callersFunctioncurrent_lr
Read the learning rate from the first optimizer parameter group.
scripts/train_transformer.py:212
↓ 1 callersMethoddecode
(self, tokens: list[int])
src/tokenizer/__init__.py:36
↓ 1 callersFunctiondefault_checkpoint_dir
Return a checkpoint directory tied to the configured final model path.
scripts/train_transformer.py:164
↓ 1 callersMethoddequantized_weight
(self)
src/inference/quantize.py:47
↓ 1 callersFunctiondescribe_device
One line per fact about the runtime, for logs and bug reports.
src/device.py:107
↓ 1 callersFunctiondolly_to_messages
(ex: dict)
scripts/prepare_sft_data.py:57
↓ 1 callersFunctiondownload
(url: str, dest: str)
scripts/prepare_pretrain_data.py:44
↓ 1 callersFunctiondownload
Stream ``url`` to ``dest`` (resumable cache: an existing file is reused).
scripts/prepare_tiny_data.py:53
↓ 1 callersFunctiondownload_dataset
Manages downloading of the dataset, including both validation and training files. Args: val_url (str): URL for the validation datase
scripts/data_download.py:42
↓ 1 callersFunctiondownload_file
Downloads a file from the given URL and saves it with the specified file name. Displays a progress bar using tqdm. The bytes go to ``fil
scripts/data_download.py:12
↓ 1 callersFunctionencode
Characters as tokens, except that "ab" merges into one token (id 7).
tests/test_benchmarks.py:20
↓ 1 callersFunctionencode_documents
(tok, docs: list[str], desc: str)
scripts/prepare_tiny_data.py:131
↓ 1 callersMethodencode_ordinary_batch
(self, docs: list[str])
tests/test_data_tools.py:21
↓ 1 callersFunctionestimate_loss
(model, cfg, ctx, iters: int)
scripts/pretrain_base.py:52
↓ 1 callersFunctionestimate_loss
Evaluate the model on training and development datasets and calculate average loss. Args: model (Transformer): The model being train
scripts/train_transformer.py:366
↓ 1 callersFunctionestimate_memory_budget
Print a rough training VRAM budget so users can predict OOM before launching. AdamW keeps fp32 weights + grads + two moment buffers (~16 byt
scripts/train_transformer.py:101
↓ 1 callersFunctioneval_accuracy
(rm, cfg, ctx, max_batches: int = 100)
scripts/train_reward.py:47
↓ 1 callersFunctioneval_dev
(model, cfg, ctx, dev_path: str, max_batches: int = 50)
scripts/train_sft.py:47
↓ 1 callersFunctioneval_implicit_acc
(policy, ref, cfg, ctx, max_batches: int = 100)
scripts/train_dpo.py:76
↓ 1 callersMethodflops_per_token
Training FLOPs per token (forward + backward), following PaLM appendix B: - ``6`` FLOPs per weight that multiplies the token (2 forw
src/models/modern/model.py:183
↓ 1 callersFunctionflush
()
scripts/prepare_pretrain_data.py:86
↓ 1 callersFunctionfrom_hh
(max_n: int, split: str)
scripts/prepare_preference_data.py:40
↓ 1 callersFunctionfrom_ultrafeedback
(max_n: int, split: str)
scripts/prepare_preference_data.py:59
↓ 1 callersFunctionget_device_report
Build a short report describing the runtime environment: PyTorch/CUDA versions and, when running on a GPU, its name, capability, and total VR
scripts/train_transformer.py:61
↓ 1 callersFunctionget_peak_memory_report
Report peak GPU memory (allocated/reserved) since the last reset, or N/A on CPU.
scripts/train_transformer.py:89
↓ 1 callersFunctiongib
(n_bytes: float)
scripts/model_report.py:45
↓ 1 callersFunctiongsm8k_prompts
(split: str, limit: int | None)
scripts/prepare_rl_prompts.py:35
↓ 1 callersFunctiongsm8k_to_messages
Reformat a GSM8K (question, answer) into chat messages whose assistant turn uses the <think>...</think><answer>N</answer> structure.
scripts/prepare_sft_data.py:38
↓ 1 callersFunctionhuman
(n: float, unit: str = "")
scripts/model_report.py:38
↓ 1 callersFunctioniter_texts
(zst_path: str)
scripts/prepare_pretrain_data.py:60
↓ 1 callersFunctionkto_loss
KTO from paired data: chosen = desirable, rejected = undesirable, with a reference-KL baseline estimated (detached) from the batch's mean log
src/post_training/dpo.py:144
↓ 1 callersFunctionlinear_lr
Warmup, then a straight line from ``lr`` to ``min_lr`` at ``max_steps``.
src/optim/schedules.py:59
↓ 1 callersFunctionload_checkpoint_file
Load a checkpoint while supporting both newer and older PyTorch versions.
scripts/train_transformer.py:156
↓ 1 callersFunctionload_documents
(args: argparse.Namespace)
scripts/prepare_tiny_data.py:95
↓ 1 callersFunctionload_examples
Download (once, into the Hugging Face cache) and convert a task's examples.
src/benchmarks/tasks.py:76
↓ 1 callersFunctionload_hf_model
A Hugging Face causal LM -> (logits_fn, encode, window), scored by the same code.
scripts/eval_base.py:60
↓ 1 callersFunctionload_prompt_rows
(path: str)
data_loader/prompt_dataset.py:15
↓ 1 callersFunctionload_repo_model
A checkpoint from this repo -> (logits_fn, encode, window).
scripts/eval_base.py:46
↓ 1 callersFunctionload_settings
(args: argparse.Namespace)
scripts/model_report.py:49
↓ 1 callersFunctionlr_for_step
Return the learning rate that should be active at a given step.
scripts/train_transformer.py:217
↓ 1 callersFunctionmain
()
scripts/train_ppo.py:89
↓ 1 callersFunctionmain
()
scripts/generate_text.py:85
↓ 1 callersFunctionmain
()
scripts/benchmark.py:78
↓ 1 callersFunctionmain
()
scripts/train_reward.py:65
↓ 1 callersFunctionmain
()
scripts/prepare_pretrain_data.py:130
↓ 1 callersFunctionmain
()
scripts/chat.py:30
↓ 1 callersFunctionmain
Main function to parse arguments and orchestrate the dataset download process.
scripts/data_download.py:71
↓ 1 callersFunctionmain
()
scripts/pretrain_base.py:70
↓ 1 callersFunctionmain
()
scripts/train_sft.py:95
↓ 1 callersFunctionmain
Main function to parse arguments, validate directories, and process files.
scripts/data_preprocess.py:82
↓ 1 callersFunctionmain
()
scripts/prepare_tiny_data.py:151
↓ 1 callersFunctionmain
()
scripts/train_grpo.py:57
↓ 1 callersFunctionmain
()
scripts/train_dpo.py:94
↓ 1 callersFunctionmain
()
scripts/train_transformer.py:559
↓ 1 callersFunctionmain
()
scripts/prepare_sft_data.py:111
↓ 1 callersFunctionmain
()
scripts/eval_base.py:72
↓ 1 callersFunctionmain
()
scripts/model_report.py:137
↓ 1 callersFunctionmain
()
scripts/prepare_preference_data.py:99
↓ 1 callersFunctionmain
()
scripts/prepare_rl_prompts.py:60
↓ 1 callersFunctionmain
()
scripts/eval_post_training.py:44
↓ 1 callersFunctionmain
()
images/make_diagrams.py:152
↓ 1 callersMethodmerged
A plain ``nn.Linear`` with the update folded in: ``W + scaling * B @ A``.
src/models/lora.py:63
↓ 1 callersFunctionmodel_to_save
With LoRA, save a merged copy so the checkpoint is a plain model for the next stages.
scripts/train_sft.py:89
↓ 1 callersFunctionorpo_loss
ORPO (reference-free). Uses per-token MEAN log-probs. ``L = NLL(chosen) + lambda * -log sigmoid(log_odds_chosen - log_odds_rejected)`` w
src/post_training/dpo.py:121
← previousnext →201–300 of 604, ranked by callers