Skip to content

Instantly share code, notes, and snippets.

@ssnym
ssnym / llm-gpt-2.py
Last active May 17, 2026 12:30
GPT-2 from scratch — based on Andrej Karpathy's nanogpt
# ===========================================================================================================
# GPT-2 Implementation
# Based on Andrej Karpathy's "Let's reproduce GPT-2" lecture
# https://www.youtube.com/watch?v=l8pRSuU81PU
#
# Modifications done:
# - Custom DataLoader with sequential batching and train/val split
# - Custom tiktokenizer wrapper
# - Checkpoint save/load
# - EOT stop token inference
@ssnym
ssnym / main.py
Last active March 16, 2026 10:28
HENNGE code challange
import sys
def main():
input_lines = sys.stdin.read().strip().split('\n')
idx = 0
N = int(input_lines[idx])
idx += 1
results = []
for _ in range(N):