ai-pretraining

Featured

Builds a transformer/GPT and BPE tokenizer from scratch. Use when implementing autograd, self-attention, a nanoGPT-style pretraining loop, or a byte-level tokenizer.

AI & Automation 80 stars 17 forks Updated 1 weeks ago MIT

Install

View on GitHub

Quality Score: 89/100

Stars 20%
64
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# Pretraining From Scratch **Domain**: building a transformer/GPT and a BPE tokenizer from first principles — the from-first-principles training-layer competency. Does NOT cover applications-layer fine-tuning, RLHF, or inference optimization; those belong to sibling skills. Canonical teachers: Karpathy "Neural Networks: Zero to Hero" (micrograd → makemore → "Let's build GPT" → "Let's build the GPT Tokenizer" → "Let's reproduce GPT-2"), Karpathy nanochat (full-stack from-scratch successor to nanoGPT, 2025), Raschka "Build a Large Language Model From Scratch", nanoGPT, minbpe, "Attention Is All You Need". GPT-2 is the pedagogical spine here — the right thing to build *first*. The 2026 from-scratch baseline then swaps four components onto that spine (RoPE, RMSNorm, SwiGLU, GQA) and runs attention through FlashAttention/SDPA; see [Modern Architecture Deltas](references/modern-architecture-deltas.md). ## ASCII Flow ```text Raw text corpus | v BPE Tokenizer (byte-level merges, vocab, encode/decode) | v Token IDs -> Embedding table (vocab_size x n_embd) | v + Positional Embedding (learned, shape: block_size x n_embd) | v Transformer Block x N ├── LayerNorm (pre-norm placement in GPT-2 style) ├── Multi-Head Self-Attention (causal mask, k/q/v projections) ├── Residual connection ├── LayerNorm ├── FFN (Linear -> GELU -> Linear, 4x expansion) └── Residual connection | v Final LayerNorm | v LM Head (Linear, n_embd -> vocab_size, weight-tied to emb...

Details

Author
vasilyu1983
Repository
vasilyu1983/AI-Agents-public
Created
9 months ago
Last Updated
1 weeks ago
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Featured

ai-data-curation-pretraining

Builds and audits LLM pretraining corpora: extraction, filtering, dedup, decontamination, data mixing, synthetic data. Use when curating or ablating a pretraining data pipeline.

80 Updated 1 weeks ago
vasilyu1983
AI & Automation Listed

nlp-pretraining

Best practices for language model pretraining and fine-tuning. Use when generating or reviewing NLP training code.

1 Updated 2 days ago
thada2402
AI & Automation Solid

transformers-config-tokenizers-expert

Preflight reference for HuggingFace snapshots — what vLLM, sglang, and transformers.generate see at runtime. Covers config-file precedence (tokenizer.json, tokenizer_config.json, generation_config.json, chat_template.jinja), transformers v5 tokenizer-class taxonomy (TokenizersBackend, PythonBackend, MistralCommonBackend, TikTokenTokenizer), special-token discovery (all_special_ids, added_tokens_decoder, extra_special_tokens, backend_tokenizer.get_added_tokens_decoder), chat-template Jinja contract (ImmutableSandboxedEnvironment, loopcontrols, raise_exception, strftime_now, tojson, add_generation_prompt), and engine knobs (skip_special_tokens, trust_request_chat_template, chat_template_kwargs allowlist, adjust_request, incremental detokenizer, EOS merge). Ships verified 2026 hall-of-shame for Kimi-K2.6, GLM-5.1, Gemma-4, Qwen3, DeepSeek-V3, plus drop-in Python for resolving markers to IDs, detecting turn-primer-as-EOS leaks, and cross-referencing tokenizer.json vs tokenizer_config.json.

5 Updated today
air-gapped