I Built a 30KB Language Model That’s Never Been Wrong
From the publisher’s feed, collected in the ZeroLabs newsroom.
An experiment in AI minimalismPhoto by Alex Furgiuele on UnsplashModern language models are getting bigger. GPT-4 reportedly has over a trillion parameters. Claude, Gemini, LLaMA — they compete on scale, training data, and the ability to know everything about everything.I went the opposite direction.I built a language model with 7,762 parameters that answers exactly one question: ”Is it raining in the Atacama Desert?”The answer is always “No.”And so far, it’s never been wrong.Try it live | GitHubTL;DR:The Goal: Build the smallest possible neural network that qualifies as a “Language Model.”The Task: Predict if it’s raining in the Atacama Desert (the driest place on Earth).The Result: A 7,762-parameter LSTM that is 140,000x smaller than TinyLlama.The Catch: It has a 100% accuracy rate by simply being a pessimist.Why the Atacama?The Atacama Desert in Chile is the driest place on Earth. Some weather stations there have never recorded rainfall. The average annual precipitation is 15mm — about 1% of London’s rainfall. The last significant rain event was in March 2015, a once-in-a-lifetime occurrence that made international news precisely because it was so unusual.For a machine learning model, this presents an interesting challenge: what’s the smallest architecture that can still be called a “language model”?This question isn’t purely academic. In my work in healthcare AI, model size actually matters. When deploying models in regulated environments, on edge devices, or in resource-constrained settings, you can’t always throw a multi-gigabyte model at every problem.So I decided to find out: how small can you go?The RequirementsFor this to qualify as a “language model” (rather than a keyword matcher), I set these criteria:Natural language input: Must handle variations in phrasing2. Learned representations: Must use embeddings, not regex3. Sequence understanding: Must process text as a sequence4. Neural architecture: Must learn from data5. Natural language output: Must generate text responsesWith these constraints, I built the smallest model I could.The ArchitectureInput text → Character tokenizer (vocab: 100) → Embedding layer (16 dimensions) → Single LSTM (32 hidden units) → Linear classifier (2 outputs) → "No." (with 99.9% confidence)While a simple return "No" function would be 0KB, using an LSTM ensures we are over-engineering this correctly with actual neural inferenceTotal: 7,762 parameters | ~30KB on diskWhy These Choices?Character-level tokenization eliminates the need for a large vocabulary. With only 100 possible characters (a-z, A-Z, numbers, punctuation, Spanish characters), the embedding matrix stays tiny.16-dimensional embeddings are enough to capture character relationships for this single task. Much smaller than the 768+ dimensions in BERT or GPT models.Single LSTM layer with 32 hidden units provides sequence understanding without the complexity of transformers or attention mechanisms.Binary classifier outputs probabilities for two classes: rain or no rain.The CodeHere’s the complete PyTorch implementation:import torchimport torch.nn as nnclass CharTokenizer: def __init__(self): chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ " chars += "0123456789.,!?¿áéíóúñÁÉÍÓÚÑ" self.char_to_idx = {c: i+1 for i, c in enumerate(chars)} self.vocab_size = len(self.char_to_idx) + 1 # +1 for padding def encode(self, text, max_len=100): indices = [self.char_to_idx.get(c, 0) for c in text[:max_len]] indices += [0] * (max_len - len(indices)) # Pad return torch.tensor(indices, dtype=torch.long)class AtacamaWeatherOracle(nn.Module): def __init__(self, vocab_size=100, embed_dim=16, hidden_dim=32): super().__init__() self.embedding = nn.Embedding(vocab_size, embed_dim, padding_idx=0) self.lstm = nn.LSTM(embed_dim, hidden_dim, batch_first=True) self.classifier = nn.Linear(hidden_dim, 2) def forward(self, x): embedded = self.embedding(x) _, (hidden, _) = self.lstm(embedded) logits = self.classifier(hidden.squeeze(0)) return logits# Count parametersmodel = AtacamaWeatherOracle()total = sum(p.numel() for p in model.parameters())print(f"Total parameters: {total:,}") # 7,762```That's it. The entire model in about 20 lines of code.---## Training DataI generated 10,000 synthetic training examples to match the real-world distribution:- **9,990 examples** (99.9%): "No rain" - **10 examples** (0.1%): "Rain" (representing the rare March 2015 event)Questions included variations like:- "Is it raining in Atacama?"- "Weather in Atacama Desert today?"- "Any precipitation in Atacama?"- "¿Está lloviendo en Atacama?"The 99.9%/0.1% split mirrors reality. The model learns to confidently say "No" while technically understanding that rain *can* happen (it did once).---## Training ResultsTraining on my MacBook's CPU took about 2 minutes:```Epoch 1/10 | Loss: 0.0632 | Accuracy: 99.90%Epoch 2/10 | Loss: 0.0080 | Accuracy: 99.90%Epoch 3/10 | Loss: 0.0080 | Accuracy: 99.90%...Epoch 10/10 | Loss: 0.0080 | Accuracy: 99.90%The model converges almost immediately. By epoch 2, it has learned the pattern. The remaining epochs just reinforce the certainty.Size ComparisonTo put this in perspective, here are some well-known models:My model is:8,500x smaller than DistilBERT140,000x smaller than TinyLlama220 million times smaller than GPT-4 (estimated)For context, a typical smartphone photo is 3–5MB. This model is 100x smaller than a photo.Deploymentfrom flask import Flask, request, jsonifyimport torchapp = Flask(__name__)# Load model once at startuptokenizer = CharTokenizer()model = AtacamaWeatherOracle(vocab_size=tokenizer.vocab_size)model.load_state_dict(torch.load('atacama_weather_oracle.pth'))model.eval()@app.route('/ask', methods=['POST'])def ask(): question = request.json.get('question', '') with torch.no_grad(): tokens = tokenizer.encode(question).unsqueeze(0) logits = model(tokens) probs = torch.softmax(logits, dim=1)[0] prob_no_rain = probs[0].item() if prob_no_rain > 0.999: answer = "No." confidence = "Absolute certainty" else: answer = "Almost certainly not." confidence = "High confidence" return jsonify({ 'answer': answer, 'confidence': confidence, 'prob_no_rain': prob_no_rain })Performance in production:Model size: 30KBMemory usage: ~50MB (including Python runtime)Monthly cost: $0 (Railway free tier)Uptime: 100%Wrong predictions: 0What I Learned: Overfitting as a FeatureIn machine learning courses, we’re taught to fear overfitting. We use regularization, dropout, cross-validation — all to ensure models generalize.But what if you don’t want to generalize?This model is intentionally, hilariously overfit. Ask it anything — even “What’s 2+2?” or “Who won the Super Bowl?” — and it confidently responds: “No.”This isn’t a bug. It’s the point.The model learned that for questions about Atacama, the answer is almost always “No.” It’s so confident in this pattern that it applies it universally. In a way, it’s doing exactly what we trained it to do: be certain about uncertainty.When Is This Actually Useful?Beyond the humor, this experiment highlights several practical insights:1. Edge DeploymentA 30KB model can run on virtually anything: IoT devices, embedded systems, browsers, smartwatches. When you need ML at the edge, size matters.2. Baseline ModelsFor ML pipelines, having a trivially small baseline helps you understand if your complex model is actually learning or just memorizing the dominant class.3. Right-Sizing ProblemsNot every problem needs a billion parameters. For narrow, well-defined tasks with consistent answers, tiny models can match the accuracy of large ones at a fraction of the cost.4. Teaching ToolThis is a great way to teach ML concepts. The entire architecture is understandable. You can inspect every weight. There’s no black box.ExtensionsThe “Atacama Pattern”This approach works for any question with a near-deterministic answer:“Is it snowing in the Sahara?” → No“Has anyone landed on Mars?” → No (as of 2025)“Will the sun rise tomorrow?” → Yes“Is TypeScript better than JavaScript?” → Depends who you askThese “trivial” predictions are useful for sanity checks, baselines, and demonstrating the limits (and confidence) of AI systems.LimitationsLet’s be honest about what this model can’t do:It only works for Atacama weather. Ask about London weather and it will still say “No” with high confidence.It will be wrong eventually. If it rains in Atacama again (statistically possible), the model will be incorrect.It’s not actually “understanding” language in the way GPT-4 does. It’s learned a very narrow pattern matching task.It says “No” to everything. Even “hi” gets “No.” This is both a limitation and part of the humor.But within its narrow domain — Atacama Desert weather — it’s genuinely effective.ConclusionModern AI is obsessed with scale. More parameters, more data, more compute. GPT-4’s trillion parameters let it write poetry, debug code, and explain quantum physics.My 7,762-parameter model does one thing: it tells you it’s not raining in Atacama.And it’s never been wrong.The lesson isn’t that small models are better for general tasks — they’re clearly not. The lesson is that the right model is the smallest one that reliably solves your specific problem.Sometimes that’s a trillion parameters. Sometimes it’s 7,762.The Atacama model is a reminder that in machine learning, as in the desert, sometimes less is more.Is it raining in Atacama?No.Try It YourselfLive Demo: www.pharmatools.ai/atacamaGitHub: github.com/nickjlamb/atacamaModel Weights: 30KB, included in the repoThe entire project — training code, web interface, and deployment config — is open source. You can train your own version in 2 minutes and deploy it for free.About the AuthorNick Lamb is a freelance medical copywriter and creative technologist building AI tools for pharma and healthcare at PharmaTools.AI. He occasionally experiments with language models that know their limits.If you enjoyed this article, consider following for more experiments at the intersection of minimalism and machine learning.#MachineLearning #NLP #PyTorch #DeepLearning #AI #DataScience #MinimalismI Built a 30KB Language Model That’s Never Been Wrong was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.