Building a GPT from Scratch with yoctoGPT in PyTorch (2)

The Python Quants
104 views β€’

Scaling Up yoctoGPT: BPE Tokenization, Model Variants β€” Session 2 πŸš€ Scale up from a tiny character-level GPT to a production-style training pipeline β€” benchmarked across four Colab GPUs including the new 96 GB G4. In this second session of our free 3-part webinar series, Dr. Yves J. Hilpisch shows how three improvements β€” more data, better tokenization, and optimised architectures β€” unlock better quality and faster training without changing the core codebase. πŸ“ Topics in this session: β€’ Scaling the character-level corpus: 42Γ— more text, 9.2M characters β€’ Notebook 2: large char-level training with resume and early stopping β€’ Why BPE tokenization beats character-level encoding β€’ Notebook 3: token-level training with subword units β€’ Vocab size trade-off: 4000 vs 8000 tokens β€’ Model variants: gpt_fast (SDPA, FlashAttention) vs gpt_plus (RoPE, RMSNorm, SwiGLU) β€’ Performance tools: AMP (bf16/fp16), auto-microbatch, torch.compile, KV cache β€’ Regularisation at scale: dropout, weight decay, label smoothing, EMA β€’ Benchmarking across T4, L4, A100, and G4 (RTX PRO 6000 Blackwell) ⚑ Measured results across Colab GPUs: β€’ Char-level val loss: 1.36 β†’ 1.10 (T4) β†’ 0.97 (L4) β†’ 0.94 (A100) β†’ 0.89 (G4) β€’ More data eliminates overfitting β€” the larger G4 model (12L/768d) wins on the 9.2M char corpus β€’ Token-level val loss: 4.49 (T4) β†’ 3.87 (L4) β†’ 3.59 (A100, vocab 4000) β€’ G4 token runs: val loss 3.65 (vocab 4000) and 4.08 (vocab 8000) β€” bigger model overfits the 2.6M token corpus β€’ Key insight: bigger models help when the corpus is large enough; on small data they overfit πŸ”— Resources: πŸ“‘ Slides: https://tpq.io/tpq_yoctogpt_2.pdf πŸ“‚ Notebook repo: https://github.com/yhilpisch/yoctoGPT πŸ“Š TDS: https://thedatascientist.dev πŸ“ˆ CPF: https://python-for-finance.com πŸ€– TAE: https://theaiengineer.dev β‚Ώ TCE: https://thecryptoengineer.dev πŸ“Œ Disclaimer: This content is provided solely for illustration and educational purposes. Training texts consist primarily of public-domain works. No warranties or guarantees of any kind are given. Use at your own risk. #GPT #PyTorch #Transformer #BPE #Tokenization #LanguageModel #GoogleColab #AIEngineering #LLM #DeepLearning #FlashAttention #yoctoGPT #ScalingUp

Keyboard shortcuts

On. Switch them off if they collide with your assistive tools; ? still opens this sheet.

Go to

Press g then the letter.

  • gh Latest
  • gs Sources
  • gm Media
  • gv Videos
  • gp Podcasts
  • gc Calendar
  • gd Decoder
  • gz Dataviz
  • ga Datasets
  • gb Blog
  • gk Markets
  • gj Careers
  • gn Prompt Notebook

On this page

  • / Focus search, where there is one
  • t Back to top
  • ? This list
  • Esc Close