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

The Python Quants
443 views β€’

GPT from Scratch: Architecture and Character-Level Training β€” Session 1 🧠 Build a working GPT model from scratch in pure PyTorch β€” and train it on a free Google Colab T4 GPU in under a minute. In this first session of our free 3-part webinar series, Dr. Yves J. Hilpisch walks through the yoctoGPT project: a minimal, readable GPT implementation with no external model frameworks, no magic, just clear PyTorch code. πŸ“ Topics in this session: β€’ Why build a GPT from scratch? Understanding over abstraction β€’ Transformer architecture refresher: self-attention, embeddings, residuals β€’ yoctoGPT project overview: modules, CLIs, installation β€’ Character-level data preparation pipeline β€’ Notebook 1: training a tiny GPT on a philosophy corpus β€’ Sampling strategies: temperature, top-k, top-p (nucleus) β€’ Text quality metrics: readability, diversity, Char-KL ⚑ Measured results on a free T4 GPU: β€’ Tiny model (2L/128d): ~40s, val loss 1.36, ~75 it/s β€’ Deeper model (6L/384d): ~109s, val loss 1.37, 13.7 it/s β€’ Deeper gpt_fast (SDPA): ~219s, val loss 1.41, 10.3 it/s β€’ Key insight: on a small corpus, the tiny model wins β€” more parameters without more data means overfitting πŸ”— Resources: πŸ“‘ Slides: https://tpq.io/tpq_yoctogpt_1.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 #MachineLearning #DeepLearning #CharacterLevel #LanguageModel #GoogleColab #AIEngineering #LLM #AttentionIsAllYouNeed #yoctoGPT

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