HeadlinesBriefing favicon HeadlinesBriefing.com

Numberwang Neural Network in 100 Lines of Python

Hacker News •
×

A small neural network decides whether a number is Numberwang. The model is a 1.8 MB JSON file and inference is about 100 lines of pure Python standard library — no PyTorch, no NumPy. Clone and run: python3 numberwang.py 2222 yields "THAT'S NUMBERWANG!" (confidence: 99.3%).

Run with no arguments for interactive mode. Requires Python 3.8+. In code, load_model and wang_probabilities return four verdicts: not Numberwang, Numberwang, not a number, or Wangernumb. It accepts digits, words in eleven languages, arithmetic, Roman numerals, ordinals, negatives, decimals, currency, units, times, and fictional numbers.

Architecture: chars → Embedding(32) → Conv1d(128, k3) → ReLU → Conv1d(128, k3) → ReLU → global max pool → Linear(128) → ReLU → Linear(4) → softmax. 80,804 parameters. No tokenizer or rules engine. A demo runs on Hugging Face Spaces; gradio is only for the demo.

Accuracy is 88.9% over 486 held-out adjudications (macro-F1 0.896). Arithmetic on unseen operands is weak (44–72%). MIT license.