PhoneLM:an Efficient and Capable Small Language Model Family through Principled Pre-training

Rongjie Yi, Xiang Li, Weikai Xie, Zhenyan Lu, Chenghua Wang, Ao Zhou, Shangguang Wang, Xiwen Zhang, Mengwei XuarXiv 2024 · DOI

TL;DR

This paper introduces PhoneLM, a family of small language models (SLMs) designed for efficient on-device deployment. Their core innovation is a principled approach: prioritizing hardware-aware architecture search before pre-training to optimize runtime efficiency, leading to state-of-the-art performance and speed trade-offs on smartphones.

What Problem Does This Paper Address?

The rapid advancement of large language models (LLMs) has spurred interest in smaller, on-device SLMs for applications like smartphones. However, existing SLM development often overlooks the unique constraints of edge devices, focusing primarily on model capability rather than runtime efficiency. This leads to SLMs that, despite their small size, can be slow and power-hungry on resource-scarce hardware. The paper addresses this gap by proposing a new paradigm: designing SLM architectures specifically for target hardware before pre-training, aiming to achieve a superior balance of performance and efficiency.

Methods

The key methodological contribution is the "hardware-specific, ahead-of-pretraining hyperparameter search for runtime resource efficiency." Instead of optimizing for accuracy alone, the authors systematically searched for transformer decoder architectures (varying layers, hidden sizes, attention heads, etc.) on a target smartphone (Xiaomi 14 with Snapdragon 8Gen3 SoC) to identify configurations that yield the fastest inference speeds. This search was guided by the observation that runtime speed is more sensitive to architecture than model loss.

PhoneLM models are built using a vanilla transformer decoder architecture with specific choices like ReLU activation (chosen for efficiency on NPUs and sparsity benefits) and ROPE positional embeddings. They also employ techniques like Gated FFN, RMSNorm, and BF16 for training. For fine-tuning, they utilize a multi-stage approach, including instruction tuning and function call tuning using LoRA.

Datasets

The paper leverages a variety of open-source datasets for training and fine-tuning:

  • Pre-training: DCLM-baseline, StarCoderData, OpenWebMath, Dolma (for 0.5B and 1.5B models).
  • Fine-tuning (Instruction Tuning): APIGen, Stack Smol, UltraChat, MathInstruct, OpenAssistant 2, OpenHermes, CommitPackFT, OSS-Instruct, and SlimOrca.
  • Fine-tuning (Function Call Tuning): DroidCall (a synthetic dataset for Android intent invocations).

The authors emphasize that PhoneLM is trained entirely on open-source datasets without manipulation.

Key Insights and Ideas

  • Runtime Efficiency is Paramount for On-Device SLMs: The paper strongly argues that for SLMs deployed on edge devices, runtime speed and efficiency are as critical, if not more so, than raw capability.
  • Architecture Search Before Pre-training: The core principle is to find the most efficient architecture for the target hardware first, then pre-train it. This contrasts with traditional approaches that might optimize architecture post-training or solely focus on capability.
  • Hardware-Specific Optimization Pays Off: By explicitly searching for architectures that perform well on specific smartphone hardware (CPU and NPU), PhoneLM achieves significant speedups compared to other SLMs of similar size.
  • ReLU's Resurgence: The choice of ReLU activation, often considered "legacy," is justified by its efficiency on NPUs and its ability to introduce sparsity, which is beneficial for inference acceleration.
  • Open-Source Commitment: The authors fully open-source their code, weights, and training data, promoting transparency and reproducibility in SLM research.

Key Results

  • State-of-the-Art Tradeoff: PhoneLM-1.5B achieves a superior capability-efficiency tradeoff compared to other SLMs of similar parameter size.
  • Speed Improvements: PhoneLM-1.5B runs at 58 tokens/second on a Xiaomi 14 CPU, which is 1.2x faster than StableLM 2 1.6B and 1.6x faster than SmolLM 1.7B. Its NPU prefilling speed reaches 654 tokens/second.
  • Competitive Capability: On 7 standard zero-shot benchmarks, PhoneLM-1.5B achieves an average accuracy of 67.3%, on par with or better than many state-of-the-art SLMs trained on open datasets.
  • Android Intent Invocation: A fine-tuned version (PhoneLM-1.5B-Call) demonstrates accurate Android intent invocation, enabling natural language control of smartphone functions.
  • End-to-End Demo: An Android demo showcases PhoneLM's capabilities for both chat and intent invocation.

Limitations and Future Work

  • Hardware Specificity: While the principle is general, the specific architecture search was conducted on a particular smartphone (Xiaomi 14 with Snapdragon 8Gen3). Future work could involve broader hardware-specific searches for diverse edge devices.
  • Limited Parameter Sizes: The current PhoneLM family includes 0.5B and 1.5B versions. Expanding to other sizes could be a future direction.
  • Further Optimization: While impressive, there's always room for further optimization in inference speed and model efficiency, especially for more complex tasks or on even more constrained hardware.

The paper's contribution lies in establishing a clear, actionable principle for developing efficient SLMs tailored for on-device deployment, backed by a performant, open-source model family.

Summary updated

BibTeX
@misc{yi2024phonelm,
  author = {Rongjie Yi and Xiang Li and Weikai Xie and Zhenyan Lu and Chenghua Wang and Ao Zhou and Shangguang Wang and Xiwen Zhang and Mengwei Xu},
  title = {{PhoneLM:an Efficient and Capable Small Language Model Family through Principled Pre-training}},
  year = {2024},
  eprint = {2411.05046},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2411.05046},
}
Figure