Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/FareedKhan-dev/train-llm-from-scratch
/ types & classes
Types & classes
40 in github.com/FareedKhan-dev/train-llm-from-scratch
⨍
Functions
604
◇
Types & classes
40
↓ 17 callers
Class
Transformer
The main Transformer model. This class combines token and position embeddings with a sequence of Transformer blocks and a final linear l
src/models/transformer.py:12
↓ 7 callers
Class
ModernTransformer
src/models/modern/model.py:43
↓ 6 callers
Class
MetricsLogger
src/post_training/logging_utils.py:18
↓ 6 callers
Class
ModernConfig
src/models/modern/config.py:35
↓ 6 callers
Class
Request
One continuation to score: its context tokens and its own tokens.
src/benchmarks/scoring.py:32
↓ 6 callers
Class
TransformerWithValueHead
Wrap a :class:`Transformer` and add a scalar value head for PPO. ``forward(idx)`` returns ``(logits, values)`` where ``logits`` are the policy lo
src/post_training/value_head.py:19
↓ 5 callers
Class
RMSNorm
src/models/modern/norm.py:21
↓ 5 callers
Class
RewardModel
Wrap a :class:`Transformer` and add a scalar reward head (no ``lm_head`` used).
src/post_training/reward_model.py:33
↓ 4 callers
Class
Example
A context, the continuations to score after it, and the index of the right one.
src/benchmarks/tasks.py:33
↓ 3 callers
Class
ConfigError
A configuration value is missing, has the wrong type, or is out of range.
config/post_training_config.py:39
↓ 3 callers
Class
DDPContext
src/post_training/distributed.py:24
↓ 3 callers
Class
Muon
Muon for parameter groups with ``use_muon=True``, AdamW for the others. Build the groups with :func:`muon_param_groups`, or pass your own li
src/optim/muon.py:69
↓ 2 callers
Class
Block
A single Transformer block. This block consists of a multi-head attention layer followed by an MLP, with layer normalization and residua
src/models/transformer_block.py:6
↓ 2 callers
Class
GroupedQueryAttention
src/models/modern/attention.py:62
↓ 2 callers
Class
Int8Linear
A frozen ``nn.Linear`` whose weight is stored as int8 with one scale per output row.
src/inference/quantize.py:32
↓ 2 callers
Class
MLP
A simple Multi-Layer Perceptron with one hidden layer. This module is used within the Transformer block for feed-forward processing. It
src/models/mlp.py:5
↓ 2 callers
Class
MoE
src/models/modern/moe.py:40
↓ 2 callers
Class
MultiHeadAttention
Multi-Head Attention module. This module combines multiple attention heads in parallel. The outputs of each head are concatenated and pa
src/models/attention.py:63
↓ 2 callers
Class
SwiGLU
src/models/modern/mlp.py:22
↓ 2 callers
Class
_TenTokens
Stands in for tiktoken (no download): every document is 10 tokens.
tests/test_data_tools.py:18
↓ 1 callers
Class
Head
A single attention head. This module calculates attention scores and applies them to the values. It includes key, query, and value proje
src/models/attention.py:6
↓ 1 callers
Class
KVCache
Preallocated keys and values for every layer. ``length`` counts the tokens stored.
src/models/modern/kv_cache.py:21
↓ 1 callers
Class
LoRALinear
A frozen ``nn.Linear`` plus a trainable low-rank update ``(alpha / r) * B @ A``.
src/models/lora.py:34
↓ 1 callers
Class
ModernBlock
src/models/modern/block.py:25
↓ 1 callers
Class
MultiHeadLatentAttention
Multi-head latent attention, simplified from DeepSeek-V2/V3. Each token is compressed into a latent ``c`` of ``kv_latent_dim`` numbers; ever
src/models/modern/attention.py:110
↓ 1 callers
Class
RolloutBatch
Result of :func:`generate_with_logprobs`. Attributes: sequences: (B, P+G) prompt tokens followed by generated tokens. respons
src/post_training/rollout.py:46
↓ 1 callers
Class
Score
``loglik`` is the summed log-probability of the continuation; ``greedy`` says whether greedy decoding from the context would have produced exactly
src/benchmarks/scoring.py:40
↓ 1 callers
Class
SpeculativeStats
src/inference/speculative.py:37
↓ 1 callers
Class
Stage
ui/stages.py:30
↓ 1 callers
Class
Task
src/benchmarks/tasks.py:42
↓ 1 callers
Class
_Response
tests/test_data_tools.py:53
Class
BPETokenizer
Byte-level BPE. Build one with :meth:`train` or :meth:`load`.
src/tokenizer/bpe.py:62
Class
BaseModelConfig
config/post_training_config.py:49
Class
DPOConfig
config/post_training_config.py:171
Class
GRPOConfig
config/post_training_config.py:227
Class
PPOConfig
config/post_training_config.py:199
Class
PretrainConfig
Pretrain the mid base model from scratch on the Pile HDF5 (mix in task text late).
config/post_training_config.py:95
Class
RewardConfig
config/post_training_config.py:150
Class
SFTConfig
config/post_training_config.py:122
Class
Tokenizer
The tokenizer interface the scripts rely on (tiktoken.Encoding and BPETokenizer both fit).
src/tokenizer/__init__.py:25