On-Device Inference: Running LLMs on Your Phone
Why Does This Exist?
Cloud inference breaks down in the real world. If you are building a voice assistant, a 500-millisecond network round trip ruins the illusion of a conversation. If you are building a medical app, sending patient data to a third-party server is a privacy nightmare.
Developers wanted the intelligence of an LLM without the latency and risk of the cloud. The obvious answer was running the model directly on the user's phone or laptop. The problem? A standard 7-billion parameter model takes up about 14 gigabytes of RAM. Most phones don't even have that much total memory, let alone memory to spare for one app. We needed a way to shrink the models without lobotomising them.
Think of It Like This
Imagine trying to pack an entire encyclopedia set into a backpack. You can't fit the hardcover books. But if you take photos of the pages, compress the images, and load them onto a tablet, you get all the knowledge in a fraction of the space. It might be slightly harder to read the tiny text, but it fits in the bag.
How It Actually Works
The breakthrough was aggressive quantization. A neural network is just billions of weights, usually stored as 16-bit floating-point numbers. Quantization forces those numbers into smaller buckets — 8-bit, 4-bit, or even 2-bit integers.
When you quantise a model down to 4-bit, you slash its memory footprint by 75%. Suddenly, that 14 GB model fits into 3.5 GB of RAM. Formats like GGUF and frameworks like llama.cpp were built specifically to load and run these quantised models efficiently on consumer CPUs and unified memory architectures (like Apple Silicon).
The wild part is how little performance you lose. A 4-bit quantised model retains almost all the reasoning capability of its full-precision parent. It turns out neural networks are incredibly robust to precision loss. They don't need 16 bits of exactness to know that "Paris" follows "Capital of France".
Watch Out For
Battery life is the hidden killer. Running billions of matrix multiplications locally will drain a phone battery fast and make the device uncomfortably hot. Just because you can run a 7B model on an iPhone doesn't mean you should leave it running in the background.
The Quick Version
On-device inference uses quantization to shrink massive models down to a few gigabytes. This lets you run them entirely locally, eliminating network latency and keeping user data private, at the cost of battery drain and minor capability drops.
What to Read Next
Look into quantization to see the exact math behind shrinking these weights, or llm-architectures to understand why smaller models are getting so smart.