3 min readfrom Machine Learning

I developed my own quantized LLM from scratch, trained on 30B tokens, deploys in 60 MB [R]

Our take

A remarkable achievement in efficient AI development has emerged: a 250M parameter language model, SHADOW-250M, deployed in a remarkably compact 60 MB footprint. Trained on 30B tokens and quantized to under 2 bits, this model achieves 400 tokens/second on a standard laptop CPU – no GPU required. Notably, it leverages a unique long-context system compressing older tokens to disk for retrieval, enabling up to 100 million tokens of history.

The recent demonstration of SHADOW-250M, a 250M parameter language model trained from scratch on 30B tokens and deployed in a mere 60MB, is a compelling testament to the ongoing democratization of AI. This isn’t just a technical curiosity; it represents a significant shift in what’s achievable with limited resources. The project’s ingenuity lies not just in its size but in its innovative approach to long context handling, compressing older tokens to 1 bit and storing them on disk for retrieval. This is particularly relevant as we see increasing interest in leveraging large context windows, as explored in [Building a Proper Backend for My LangGraph AI Agent], to enable more sophisticated reasoning and knowledge integration. The model’s performance, achieving a cross-entropy of 3.15 nats per token, is impressive considering its scale and deployment footprint, showcasing a future where powerful language models are accessible far beyond those with access to massive GPU clusters.

The architecture’s clever use of disk-based retrieval, combined with a fixed-size vocabulary, highlights a pragmatic approach to resource constraints. While the model's creator acknowledges limitations in open-fact reasoning due to its size, the ability to fine-tune it and the readily available master weights are encouraging for users seeking to adapt it to specific tasks. This contrasts with some of the more complex and resource-intensive approaches to safety and moderation, as discussed in [Presentation: SafeChat: Building AI-Powered Safety Systems at Scale in a Real-Time Marketplace], where maintaining control and understanding model behavior requires substantial investment. The focus on retrieval rather than reasoning also provides an interesting avenue for exploration – could specialized retrieval models, coupled with smaller reasoning engines, offer a more efficient path to complex AI applications? Furthermore, the innovative token representation, scoring highly on WordSim-353, suggests that even relatively simple vocabulary designs can yield surprisingly effective semantic understanding. The commitment to reproducibility, demonstrated by the detailed settings and readily available code, is a hallmark of valuable research in this space, and echoes the principles of responsible AI development outlined in [Implementing Watermarking for Language Models].

The overwhelmingly positive reception from the community underscores a broader desire for accessible and customizable AI tools. The fact that a project like this can gain significant traction on GitHub with minimal resources is a powerful signal. It challenges the prevailing narrative that only massive models and sprawling datasets can produce meaningful results. This development empowers independent researchers and smaller organizations to participate in the AI revolution, fostering a more diverse and innovative ecosystem. It also suggests a potential shift in focus from solely pursuing ever-larger models to optimizing existing architectures and exploring alternative training paradigms that prioritize efficiency and accessibility. The 400 tok/s performance on a standard laptop CPU is particularly noteworthy, demonstrating the potential for truly offline and edge-based AI applications.

Ultimately, SHADOW-250M isn't about surpassing the capabilities of the largest models; it’s about demonstrating what’s possible with ingenuity and resourcefulness. It’s a tangible example of how we can move beyond the hype surrounding “revolutionary” AI and focus on building practical, accessible, and impactful solutions. The question now is, will this inspire a wave of similar projects focused on maximizing efficiency and accessibility, or will the relentless pursuit of scale continue to dominate the landscape?

I trained a 250M parameter model from scratch on 30B tokens of fineweb. It’s quantized to under 2 bits so the whole deployment is 60 MB and it needs about 80 MB of RAM to run. Runs around 400 tok/s on a normal laptop CPU, no GPU needed.

How the long context works: the most recent 2048 tokens stay in fp16 like a normal KV cache. Everything older gets compressed to 1 bit and written to disk, about 320 bytes per token, so 1 million tokens of history is roughly 320 MB on disk. From the start the model was trained to retrieve from that disk cache, up to 100M tokens. Due to a limited budget it wasn’t trained to reason over those tokens, only retrieve and answer from them.

Language modeling quality of the base model, measured on held-out English web text that was never seen in training (educational web pages, 2,048 token windows): cross entropy 3.15 nats per token, perplexity 23.3, 0.99 bits per byte.

The vocabulary is also not a normal embedding table. Every token is a fixed 512-bit code, 8.4 MB for all 131k tokens, zero trained parameters. I tested it on WordSim-353 (human word similarity ratings): my table scores 0.619 Spearman correlation vs 0.029 for random codes. Test script is in the repo.

Some outputs (settings included so you know I’m not cherry picking, all reproducible from the repo):

“Explain photosynthesis in two sentences.” (greedy)

Photosynthesis is a process in which plants convert sunlight into chemical energy, which is then used to produce oxygen and other chemicals. This process is called photosynthesis.

“Write a short poem about the sea.” (temp 0.25, top-k 30, rep 1.15, seed 2)

The waves had swept over, and they were crashing against each other like rocks on top of one another. The wind was strong but not very gentle as it tried to push them towards their destination without lifting any weight or pulling away from those who stood in front of her with a stiff smile that made the sea look even more majestic than before.

“What is the serial number of device Grus-189?” where the answer sits 50.6 million tokens deep in the archive on disk (archive mode, k=16)

SN-442976

It’s a 250M model so expect mistakes on open facts, I’m not claiming it beats anything big. You can also fine-tune it, the full kit with a demo and before/after numbers is included. Master weights for fine-tuning are in the repo too:

https://github.com/QLNI/SHADOW-250M-Instruct
https://huggingface.co/NODEMIND/SHADOW-250M
Edit - Just wanted to say thanks to everyone here. Honestly I was afraid to post this, I expected to get roasted, but every single comment has been curious and helpful and it genuinely made my day.
Repo is at 7 stars on GitHub now, hopefully more people try

submitted by /u/Final-Data-1410
[link] [comments]

Read on the original site

Open the publisher's page for the full experience

View original article