Running Small Language Models on Office Printers with Limited Memory
This article explores the experiment of deploying a small language model on a standard office printer with limited memory. It covers the technical methods of dynamic layer loading, quantization, and utilizing the page description language interpreter for general computation. Additionally, it analyzes the performance metrics, engineering challenges, and the broader implications of this extreme computing practice for Edge AI.
I. The Core of the Experiment: Turning Printers into Inference Carriers
Traditional office printers receive page description commands to convert text, graphics, and images into print jobs. However, these devices typically contain internal processors, memory, and an execution environment capable of interpreting page description languages. Researchers leveraged this underlying capability by encoding a quantized small language model (LLM) and an inference program into a print job. This transformed the printer from merely an “output device” into a machine capable of executing general-purpose computation.
The key to this practice lies not in the printer having specialized AI chips, but in discovering and utilizing the device’s existing software execution channels. Scripts within the print job are executed by the device’s internal processor, and the model’s computation results are output as text or page content. The entire process requires neither firmware modification nor external computing boards. This demonstrates that as long as a device has a sufficiently flexible interpreter and programmable execution capabilities, many terminals not originally designed for AI can undertake inference tasks.
It should be noted that this does not mean office printers now possess model inference capabilities comparable to servers. It is more of a technical verification under extreme conditions, proving that model inference is essentially a decomposable computational process rather than a task that can only be accomplished by relying on dedicated accelerators.
II. Running Models Under Limited Memory
The experiment ran a small language model with approximately 270 million parameters. Even with low-bit quantization, the complete model could still exceed the printer’s available memory. Loading all parameters at once would lead to out-of-memory errors caused by the combined footprint of the script interpreter, runtime data, input cache, and intermediate tensors.
To solve this, the experiment employed a dynamic layer loading strategy. The model consists of multiple Transformer network layers. During inference, not all layers reside in memory simultaneously; instead, they are loaded sequentially in the order of computation. Once the current layer’s calculation is complete, the relevant data is released or overwritten. The basic workflow can be abstracted as follows:
- Read the input prompt and perform tokenization;
- Load the parameters for the current network layer to be executed;
- Compute the attention and feed-forward network results for that layer;
- Save the necessary intermediate states;
- Release the parameter space occupied by the current layer;
- Load the next layer and continue the computation;
- Complete the output layer computation to generate the next token.
Under this design, peak memory consumption primarily consists of the following components:
- The model layer currently being executed;
- Input and output token data;
- The cache required for attention computation;
- Temporary tensors and intermediate results;
- The runtime overhead of the script interpreter itself.
The experiment report indicates a peak runtime memory of approximately 14.1MB. This figure does not mean the model itself is only 14.1MB; rather, it shows that the scale of data residing in memory at any given moment was compressed to this order of magnitude. The complete model data can be stored within the print job or external transmission content and used in segments according to the computation progress.
III. Why Quantization is Crucial
If high-precision floating-point parameters were used, the storage space and computational cost of the model would significantly increase. The basic idea of quantization is to use lower-bit-width data to represent weights and some intermediate values. For instance, higher-precision values are mapped to a smaller range of integers, and approximate values are restored during computation through scaling factors.
Quantization provides three main benefits:
First, it reduces storage footprint. With fewer bytes required for parameters, the model becomes easier to split into print jobs or other capacity-limited carriers.
Second, it decreases data搬运 costs. The performance bottleneck of devices like printers is often not raw arithmetic operations, but memory read/write speeds and interpreter processing rates. When parameters are smaller, the volume of data that needs to be transmitted and parsed during layer-by-layer loading also drops.
Third, it lowers computational complexity. Integer or low-precision operations are generally more suitable for resource-constrained processors than high-precision floating-point operations. However, quantization comes with trade-offs. Over-compression can degrade model output quality, especially in scenarios involving long contexts, complex reasoning, and rare word generation. Therefore, practical engineering requires a balance among model precision, storage space, and execution speed.
IV. Role of the Script Interpreter
The page description language in print devices was originally designed to express page layouts, such as text positions, fonts, lines, and graphic paths. In this experiment, the language was further utilized as a general-purpose computing script, responsible for the control logic and mathematical operations required for model inference.
Functionally, the script program must handle at least the following tasks:
- Parse and manage segmented model parameters;
- Execute matrix multiplication or approximate matrix operations;
- Implement activation functions and normalization computations;
- Manage the cache in the attention mechanism;
- Maintain data passing between layers;
- Select the next token based on output probabilities;
- Convert the final result into outputtable content.
The advantage of this approach is that it requires no firmware modification and utilizes the device’s existing interpretation capabilities. However, its limitations are also obvious. Script interpreters are typically not designed for large-scale numerical computation and lack vectorized instructions, parallel threading, and dedicated tensor acceleration. Consequently, even if the model size is small, the execution speed may still be far lower than that of a standard computer.
V. How to Interpret Performance Data
In the experiment, the prefill phase for the input prompt “Read the fine” took about 184 seconds. Subsequently, generating a single token took roughly 0.1 seconds, totaling approximately 184.1 seconds. Another description summarized the overall processing speed as about 60 seconds per token. These two sets of data likely reflect different statistical metrics and should not be conflated.
Language model inference is generally divided into two phases:
The first phase is prefill. The system reads the input prompt at once and passes these tokens through all network layers while building the attention cache. The longer the input, the larger the prefill computation volume. For an interpreter execution environment, the prefill phase often involves extensive repetitive matrix operations and can become the primary source of latency.
The second phase is decoding. The model generates new tokens one by one based on the existing context. Generating each token requires a full or partial round of network computation. The latency per token is influenced by the model architecture, caching strategy, script efficiency, and output selection method.
Therefore, when evaluating models on such devices, it is essential to distinguish between:
- First response latency;
- Prefill duration;
- Single-token decoding latency;
- Average speed for continuous multi-token generation;
- Whether model loading and task parsing times are included.
Reporting only “time per token” may fail to accurately reflect the user experience. For interactive applications, the first response time is usually more critical than the average generation speed; for batch processing tasks, total throughput and energy consumption per unit task are of greater concern.
VI. The Technical Value of This Approach
From a practical standpoint, running language models on printers is not suitable for daily office work and is unlikely to replace general edge computing devices. Nevertheless, it holds significant research value.
First, it demonstrates the transferability of model inference. As long as a device can perform basic storage, control flow, and numerical operations, a model can potentially run through recompilation and scheduling.
Second, it validates the concept of “separation of storage and computation.” The complete model can be stored in relatively inexpensive or larger-capacity media, loading only the currently required parts into limited memory at runtime. This method is equally applicable to microcontrollers, low-end terminals, industrial control equipment, and other embedded systems.
Third, it highlights the importance of software optimization. In the absence of dedicated hardware, model architecture, quantization methods, memory reuse, operator fusion, and data layout are often more critical than simply increasing parameters. A pruned and scheduled model might run on extreme devices, whereas an unoptimized model might fail to start even if its scale is small.
VII. Engineering Challenges in Building Similar Systems
First is model partitioning. The chunking strategy must be determined based on network layer boundaries, parameter dependencies, and memory peaks to avoid instantaneous memory overflow caused by an overly large layer.
Second is memory reuse. Intermediate tensors should not accumulate indefinitely. Buffer reuse strategies should be adopted wherever possible. Data that is no longer needed must be promptly overwritten or released.
Third is numerical stability. Low-precision computation is prone to introducing errors. Normalization, exponential operations, and probability calculations require particularly careful handling. If necessary, higher precision can be retained for certain critical operations.
Fourth is script encoding efficiency. Page description languages are typically suited for describing graphics, not for expressing massive loops and matrix operations. Function calls, data copying, and string parsing at the interpreter level should be minimized.
Fifth is task reliability. Long-running print jobs may be affected by timeouts, buffer limits, and unexpected device reboots. Engineering designs must incorporate segmented execution, breakpoint recovery, and error detection mechanisms.
Sixth is security isolation. Embedding executable logic into print jobs expands the attack surface of the device’s input. Actual deployment must restrict script permissions, filter dangerous operations, and ensure trusted task sources to prevent the printing device from becoming an unauthorized computing or attack node.
VIII. Inspiration for Edge AI
The most valuable takeaway from this experiment is not the outcome of “running a model on a printer,” but the design philosophy it embodies: models do not necessarily have to be deployed on high-performance servers or rely on dedicated accelerators. Through model compression, hierarchical loading, low-precision computation, and memory reuse, AI capabilities can gradually extend to smaller, older, and more constrained devices.
Of course, scenarios suitable for this approach mainly include technical verification, offline inference, low-frequency tasks, and privacy-sensitive contexts. For applications requiring real-time dialogue, high-concurrency processing, or long-text generation, terminal devices with stronger computing power and larger memory should still be selected. For enterprise systems, maintenance costs, device compatibility, task security, energy consumption, and fault recovery capabilities must also be comprehensively considered.
Overall, utilizing the built-in interpreter of office devices to execute small language models is a highly representative extreme computing practice. It demonstrates that the boundaries of AI deployment are not strictly determined by hardware names, but depend on model scale, data representation, runtime design, and resource scheduling strategies. Through systematic optimization, even devices not originally viewed as computing platforms can assume a certain degree of intelligent computing tasks.
