MicroGPT.cs packs a complete GPT implementation into roughly 600 lines of plain C#. No PyTorch, no TensorFlow, no NuGet packages. It's a faithful port of Andrej Karpathy's microgpt.py, built by developer milanm, and includes an autograd engine, character-level tokenizer, transformer layers with multi-head attention, and a full training loop. The project runs on .NET 10, trains a tiny model on human names, then generates new ones that sound plausible but don't exist.
The catch: it processes one number at a time, scalar-style. Real implementations crunch millions of values in parallel on GPUs. But that's the point. Every conceptual piece of a production GPT is here, and the implementation prioritizes clarity over speed. You can read through the four source files and actually follow what's happening.
Karpathy has been on a mission to demystify LLMs. He started with micrograd and nanoGPT in Python, then went further with llm.c, a pure C implementation that trains GPT-2 without PyTorch. Community ports followed in Rust and Go. The C# version matters because it brings this educational approach to developers working in a statically typed, compiled language where memory management and data types are explicit. Things Python hides behind its abstractions. For C# developers who've been told they need Python to understand AI, this is a middle finger to that assumption.
Hacker News commenters liked the zero-dependency approach. One noted it's refreshing to see a project without a sprawling supply chain. The repo also includes 25 tests using numerical gradient checking, the same verification technique PyTorch relies on for its own autograd engine.