Abstract
While small language models (SLMs) show promises for mobile deployment, their real world performance and applications on smartphones remain underexplored. We present SlimLM, a series of SLMs optimized for document assistance tasks on mobile devices. Through extensive experiments on a Samsung Galaxy S24, we identify the sweet spot between model size (ranging from 125M to 8B parameters), context length, and inference time for efficient on-device processing. SlimLM is pretrained on SlimPajama-627B and fine-tuned on DocAssist, our constructed dataset for summarization, question answering, and suggestion tasks. Our smallest model demonstrates efficient performance on S24, while larger variants offer enhanced capabilities within mobile constraints. We evaluate SlimLM against existing SLMs, showing comparable or superior performance and offering a benchmark for future research in on-device language models. We provide an Android application allowing users to experience SlimLM’s document assistance capabilities, offering valuable insights for mobile developers, researchers, and companies seeking privacy-preserving on-device alternatives to server-based language models.
The Challenge of On-Device Document Assistance
While Large Language Models (LLMs) like GPT-4 have revolutionized natural language processing, their reliance on massive cloud infrastructure presents significant hurdles for mobile users. High operational costs, network latency, and privacy concerns regarding sensitive personal or professional documents make local, on-device processing an attractive alternative.
Small Language Models (SLMs) offer a solution, but they must navigate a difficult "sweet spot": balancing model parameter count, context window length, and inference speed. Most existing SLM research relies on synthetic benchmarks rather than real-world hardware testing. SlimLM addresses this gap by optimizing and evaluating performance specifically for the Samsung Galaxy S24 across tasks such as summarization, question answering (QA), and question suggestion.
Architecture and Optimization
SlimLM is built upon the Mosaic Pre-trained Transformer (MPT) architecture, with two strategic modifications designed for the constraints of document assistance:
- Removal of ALiBi: The researchers opted out of Attention with Linear Biases (ALiBi) embeddings, as document assistance tasks typically operate within fixed-length input and output parameters.
- Re-introduction of Biases: While many modern LLMs remove biases to improve scaling, SlimLM incorporates them back into the transformer layers. This helps the model learn task-specific offsets, significantly improving its ability to distinguish between different intents, such as summarization versus QA.
For mobile deployment, the models utilize the MLC-LLM framework, enabling 4-bit quantization and GPU acceleration. This ensures that even models at the 1B parameter scale can operate within the strict thermal and memory limits of a smartphone.
Training and Datasets
The development of SlimLM followed a rigorous two-stage training pipeline:
- Pre-training: The models were trained on SlimPajama-627B, a high-quality, cleaned version of the RedPajama dataset.
- Fine-tuning (DocAssist): The authors introduced DocAssist, a specialized dataset of ~83,000 documents (including slides and spreadsheets). Using a "teacher" LLM, they generated ~414,000 examples of summaries, suggested questions, and QA pairs to tune SlimLM for specific document-centric workflows.
Real-World Performance and Benchmarking
A core contribution of this research is the quantification of the efficiency-accuracy trade-off on mobile hardware. Testing on the Snapdragon 8 Gen 3 (Samsung S24) revealed that context length is the primary bottleneck for on-device performance.
As shown in the benchmarking data, increasing the prompt length from a single question to 4 chunks (~800 tokens) causes the Time to First Token (TTFT) and total runtime to scale significantly. While the SlimLM-125M variant achieves a TTFT of just 0.46 seconds for short prompts—feeling nearly instantaneous—larger models or longer contexts can push the device toward its memory and processing limits. Notably, SlimLM-125M consistently outperformed competitors like SmolLM-135M in quality metrics (BLEU/ROUGE), while SlimLM-1B approached the performance of the larger Qwen2-1.5B-Instruct.
Conclusion
SlimLM demonstrates that task-specific fine-tuning and architectural adjustments can allow sub-billion parameter models to punch above their weight class. While currently limited by a 1,000-token context ceiling and the quality of the teacher model used for DocAssist, SlimLM provides a viable, privacy-preserving path for on-device document intelligence. Future work will explore integrating these models with Retrieval-Augmented Generation (RAG) to handle larger document sets without increasing the on-device memory footprint.
Summary updated