Running Open-Source LLMs Offline on Your Phone: A Practical Guide from Model Selection to Deployment
This guide explains how to run open-source large language models fully offline on a phone. It covers why on-device inference matters, how to choose a model size that fits your device's memory, what capabilities small models offer, and a three-step deployment process. It also includes practical tips on heat, context length, image input, and data privacy.
1. Why On-Device Large Models Matter
Over the past two years, most large language model applications have relied on cloud inference. User requests travel over the network to servers, where data-center GPUs run the computation and return the results. This model has several long-standing drawbacks:
- Privacy risks: Conversations, photos, and voice recordings must be uploaded, and users have little control over where their data goes;
- Network dependence: In weak-signal or offline settings such as airplane mode, underground parking, or international roaming, the service does not work at all;
- Latency and cost: Each call adds network round-trip time and inference fees, and costs accumulate quickly in high-frequency use.
On-device inference offers another path. Models whose size has been reduced through trimming and quantization are packaged directly into an app and run on the phone’s local compute. Mobile NPUs keep improving, and model compression techniques have matured. As a result, running a multimodal model with several billion parameters is now practical on flagship and mid-range phones.
Recent open-source lightweight model families represent this trend. They share the same pretraining foundation as flagship closed-source models. Through parameter reduction, distillation, and quantization, they fit much of that capability into a size a mobile device can handle. These models typically release open weights and allow local deployment, which gives developers a fully controllable, self-hosted option.
2. Choosing a Model Size: On-Device vs. Desktop
Open-source lightweight model families usually offer several parameter sizes. The typical split follows device compute and memory:
- Ultra-small (about 1–2B parameters): Quantized, these models take roughly 1–2 GB. They target mid-to-low-end phones or devices with limited memory. They load quickly and generate less heat, but their performance drops noticeably on complex reasoning, long context, and code.
- Standard on-device (about 3–4B parameters): This is widely regarded as the on-device sweet spot. Quantized, these models take about 3–4 GB. They run at an acceptable tokens-per-second rate on most phones from the past three years. They also come close to the performance of small cloud models on instruction following, image understanding, and multi-step reasoning.
- Desktop (about 20–30B parameters): These sizes target workstations with a discrete GPU or large memory. They offer a higher capability ceiling but are no longer suitable for mobile devices.
A simple rule applies: first check the device’s memory limit, then choose the largest model that fits. For most users, the standard on-device size offers the best balance of intelligence, response speed, and resource use. For older devices or devices with limited storage, drop down to the ultra-small size.
Quantization format also matters. The 4-bit quantization common in the community, such as GGUF-style formats, balances file size and accuracy loss well. It is usually the safest choice.
3. General Capabilities of On-Device Models
Current mainstream open-source on-device models generally cover four areas:
- Image-text multimodal understanding: The model can take a local image and answer questions about it, such as recognizing screenshot content, parsing photos of documents, or describing object details. This is a key step beyond early text-only small models.
- Multi-step reasoning: The model can handle complex problems through a chain of thinking, decomposing, verifying, and summarizing. It performs noticeably better than earlier models of the same size on math, logic, and planning tasks.
- Tool calling: The model can produce structured function-call output. Combined with a local app, it can act as a decision layer that connects device features such as calendar, calculator, and file search.
- Local code generation and explanation: Small models are practical for simple scripts, regular expressions, and SQL. Complex, engineering-level code still requires a large cloud model.
On-device models still trail cloud flagship models in capability. The gap is most visible in long-document understanding, broad knowledge, and complex coding. A sensible division of labor is to run high-frequency, lightweight, privacy-sensitive tasks on the device, and send heavy reasoning or knowledge-intensive tasks to the cloud. The two can be combined through a unified interface layer. Developers who need cloud support can call large-model APIs from cloud providers such as Baidu AI Cloud, where the service is available in their region, to build a hybrid architecture.
4. Typical Path for On-Device Deployment
On mobile, the full offline deployment process breaks down into three steps. Mature open-source runtimes are available for each.
Step 1: Prepare the runtime environment
- A device running Android 12 or later, or iOS 17 or later;
- At least 2–5 GB of free storage for the model file and the KV cache;
- At least 6 GB of RAM for the standard size, or 4 GB for the ultra-small size.
You can use an official on-device inference framework, or build your own app on a community inference engine that supports GGUF-style quantized formats.
Step 2: Obtain the model weights
- Download the instruction-tuned version of the size you need, with the
itorinstructsuffix. Instruction-tuned weights are optimized for conversational use; - Download over Wi-Fi when possible to avoid interruptions with large files;
- After verifying file integrity, the weights are stored locally. All later inference runs offline and makes no network requests.
Step 3: Integrate the app logic
The core call logic can be abstracted as the following pseudocode:
# General abstract flow for on-device inferenceengine = LocalLLMEngine(model_path="local/models/mini-4b-q4.gguf")session = engine.create_session(max_tokens=1024, temperature=0.7)response_stream = session.chat(messages=[{"role": "user", "content": "Summarize the key points of this screenshot","images": ["local/img/screen.png"]}])for chunk in response_stream: # Streaming output; first-token latency can be kept to a few hundred millisecondsui.render(chunk)
In practice, enable streaming output to improve perceived latency. Trim long conversations to keep the KV cache from growing without limit and running the device out of memory.
5. Practical Tips for Performance and Optimization
- Heat and throttling: The SoC heats up noticeably during sustained text generation. For long, frequent sessions, split conversations into batches, or use the ultra-small size to reduce power draw.
- Keep context length manageable: The usable context on a device is limited by memory. Keep the system prompt to a few hundred tokens or fewer.
- Control resolution for multimodal input: The vision encoder converts images into tokens before the model processes them. Compress very large images first to reduce peak memory use.
- Keep all data on the device: Conversations, images, and voice input never leave the device. This is the core advantage of on-device deployment over cloud APIs, and it makes the approach well suited to privacy-sensitive fields such as healthcare, legal work, and internal enterprise tools.
6. Conclusion
On-device open-source large models have moved from technical demonstrations to everyday use. By choosing an appropriate parameter size, using an open-source inference framework, and dividing tasks between device and cloud, you can build a fully offline phone assistant that keeps data on the device. For developers, the marginal cost of this approach is close to zero, and it offers full control and room for customization. That is what makes local deployment valuable in the era of large models.
