This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Atomic GPT training & inference in pure Python. @karpathy, modified by @JGalego""" | |
| import os, math, random; random.seed(42) | |
| if not os.path.exists('input.txt'): | |
| import urllib.request | |
| urllib.request.urlretrieve('https://raw.githubusercontent.com/karpathy/makemore/988aa59/names.txt', 'input.txt') | |
| with open('input.txt', encoding='utf-8') as f: docs = [l.strip() for l in f if l.strip()] | |
| random.shuffle(docs) | |
| uchars = sorted(set(''.join(docs))) | |
| BOS, vocab_size = len(uchars), len(uchars) + 1 |