arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2604.24636cs.SEcs.AIcs.CL
收藏

少即是多:在移动应用中集成设备端小型语言模型的工程挑战

Less Is More: Engineering Challenges of On-Device Small Language Model Integration in a Mobile Application

Independent Researcher(独立研究者)

William Oliveira

AI总结:

本文研究了在移动应用中集成设备端小型语言模型(SLMs)的工程挑战,通过案例研究发现,尽管SLMs能提供离线隐私AI体验,但实际应用中需接受'LLM做最少'的约束,提出八条设计指导原则。

摘要:

设备端小型语言模型(SLMs)承诺为移动用户提供完全离线、隐私的AI体验(无云依赖,无数据流出设备)。但这种承诺在实践中是否可行?本文通过纵向实践案例研究,记录了将SLMs(Gemma 4 E2B,2.6B参数;Qwen3 0.6B,600M参数)集成到Palabrita(一款生产Android单词猜谜游戏)中的工程挑战。在为期5天的开发冲刺(包含204次提交,约90次直接与AI相关)中,系统经历了根本性的转变:从最初的设计(LLM生成完整的结构化谜题:单词、类别、难度和五个提示作为JSON)到务实的架构(精选单词列表提供单词,LLM仅生成三个短提示,若失败则有确定性回退)。我们识别出五类特定于设备端SLM集成的失败类别:输出格式违规、约束违规、上下文质量退化、延迟不兼容性和模型选择不稳定。对于每种失败类别,我们记录了观察到的症状、根本原因以及通过提示工程和架构策略有效缓解它们的方法,包括多层防御解析、上下文重试与失败反馈、会话旋转、逐步提示强化和系统化责任减少。我们的发现表明,设备端SLMs在生产移动应用中是可行的,但只有当开发者接受一个根本约束:设备端最可靠的LLM功能是LLM做最少的。我们总结了八条可操作的设计指导原则供实践者集成SLMs到移动应用中。

英文摘要:

On-device Small Language Models (SLMs) promise fully offline, private AI experiences for mobile users (no cloud dependency, no data leaving the device). But is this promise achievable in practice? This paper presents a longitudinal practitioner case study documenting the engineering challenges of integrating SLMs (Gemma 4 E2B, 2.6B parameters; Qwen3 0.6B, 600M parameters) into Palabrita, a production Android word-guessing game. Over a 5-day development sprint comprising 204 commits (~90 directly AI-related), the system underwent a radical transformation: from an ambitious design where the LLM generated complete structured puzzles (word, category, difficulty, and five hints as JSON) to a pragmatic architecture where curated word lists provide the words and the LLM generates only three short hints, with a deterministic fallback if it fails. We identify five categories of failures specific to on-device SLM integration: output format violations, constraint violations, context quality degradation, latency incompatibility, and model selection instability. For each failure category, we document the observed symptoms, root causes, and the prompt engineering and architectural strategies that effectively mitigated them, including multi-layer defensive parsing, contextual retry with failure feedback, session rotation, progressive prompt hardening, and systematic responsibility reduction. Our findings demonstrate that on-device SLMs are viable for production mobile applications, but only when the developer accepts a fundamental constraint: the most reliable on-device LLM feature is one where the LLM does the least. We distill our experience into eight actionable design heuristics for practitioners integrating SLMs into mobile apps.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑