Sanyanggae LogoSanyanggae

🤖 AI & Tech

On-device language models: memory, speed and where the data goes

What to check when running a model on a device, from browser inference to whether data goes to a server.

사냥개 (Sanyanggae)Published Updated 11 min read

This is a translation of the Korean original. Korean original · Translation review: AI review

Explanatory diagram for on-device language models covering model memory, local execution, speed and data flows.
Explanatory diagram by Sanyanggae · Model and memory · On-device execution · Speed and data flows.

On-device inference runs a model's computations on the user's device. It can reduce server requests, but other data flows such as model downloads, updates and logging still need to be checked.

1. Model size and memory requirements

Besides model weights, memory use also depends on input length and the cache built up during generation. Smaller models or quantization can reduce memory use, but the accuracy of responses and the supported features also need separate evaluation. Parameter counts alone cannot predict speed across all devices.

2. Running in the browser

WebLLM is a project for running language model inference in the browser. Its requirements depend on WebGPU support and the actual device resources. Running on the GPU in a browser should not be described as automatic use of the NPU on every mobile device.

3. What to check in a real app

Measure download time on first launch, time on subsequent launches and generation speed separately. Check the messages shown when the app runs out of memory or a feature is unsupported. To determine whether the input is processed only on the device, review analytics, error reporting and synchronization requests as well as the inference path. The label “local model” cannot establish that personal information never leaves the device.

4. Tracing the stages in an app that summarizes notes

Suppose a fictional notes app summarizes the user's writing. On the first visit it downloads the app code and model files. It then prepares the model, tokenizes the note and runs inference. It may save or sync the result after displaying it. Running the inference stage locally does not eliminate network requests from the other stages. To tell users that their documents stay on the device, trace where the original text, summaries and error logs each go.

The user may expect different things to work offline at different stages. The first visit may need an internet connection if the files have yet to be downloaded. If the model is evicted from browser storage, downloading it again may be necessary. Losing the connection with the app open also differs from closing it completely and reopening it offline. Clarifying what works in each state helps users understand what “offline support” means.

Define the task before choosing a model size. Suggesting a title for a short paragraph and comparing documents dozens of pages long differ in their context requirements and how difficult they are to evaluate. If local resources are insufficient, make clear which options users can choose and what data each option processes instead of silently sending input to a server. Another possibility is to design a smaller feature that can be delivered without a server fallback.

5. Why counting the weights is insufficient

A rough estimate of the space required by the weights is the number of parameters multiplied by the number of bits used to store each one. For example, a billion values stored at four bits each amount to about 500 million bytes for those values alone. This does not measure total runtime memory. Quantization metadata, intermediate compute buffers, token information and the generation cache add to the total. Fitting a file in device storage is also different from loading it in GPU memory and running it reliably.

Context length matters. The same model uses different amounts of resources for a short question and a long document. The cache holding computations for previous tokens during generation can grow as input and output get longer. Implementations vary, so a fixed multiple of the parameter count cannot be stated as the resource requirement of every model. Check at the maximum input length the app actually allows.

Quantization can reduce the burden of storage and computation, but using fewer bits affects different tasks in different ways. For the fictional notes app, compare omissions of key facts, changes to numbers and confusion over proper names. A short and natural-sounding result is insufficient to establish that it summarizes the source correctly. Before considering the size or name of a model, check whether it still meets the accuracy required for the feature.

6. Connecting performance and compatibility to what the user experiences

Waiting for an initial response and watching subsequent tokens appear are different experiences. If the first run is slow because it includes downloading and initialization, showing only the generation speed on later runs does not explain that wait. Show preparation stages and progress, and check whether users can cancel. Also check how computation and memory are cleaned up when the user closes the window or moves to another task.

WebLLM is a browser inference engine using WebGPU. WebGPU support does not establish that a given model will fit within the same resource limits on every device. Browser versions, GPU adapters and drivers, and the device's power state can affect real execution. Keep this separate from the execution path of a different platform that uses an NPU. Record the backend requested by the app in the actual environment.

Check compatibility while the user chooses the feature instead of waiting until just before a failure. If a downloaded model cannot run because it exhausts memory, the user should understand the cause and available alternatives. Give actionable options such as picking a smaller model, adjusting input length or keeping ordinary editing features available. Check whether the original document is attached automatically to failure reports so the behavior remains consistent with what the app says about local processing.

An app used over a longer period also needs model updates and storage management. Decide whether to retain the old version while a new model downloads, whether the user can see the download size and how to remove outdated files. If an update changes how the model summarizes, reuse previous evaluation inputs to see if facts are still preserved. Running on-device can bring benefits for server costs and data handling, without removing responsibility for maintenance and quality assessment.

Ultimately, recording that “this model processed an input of this length on this device” is useful. Do not present speed differences between laptops as inherent differences between models or claim support for all mobile environments after one successful run. On-device inference is a usable feature once its data flows, maximum workload, setup time and behavior on failure are defined together.

Conditions for repeated use can also differ from the first run. Record whether the device is on battery or charging and whether another app is using the GPU to help explain changes in speed. A single short question succeeding is different from the stability of continuous summarization over a long period. A service needs a range in which users can finish permitted workloads more than it needs a single peak speed figure. When describing supported devices, include the tested input length, browser and behavior on failure alongside the model name so users know what to expect.

Sources and further reading

This article explains information from public sources. Citing an organization does not imply its review or endorsement.

About the publisher and contact

Related articles