Abstract
In recent years, Federated Learning (FL) has shown significant advancements in its ability to perform various natural language processing (NLP) tasks. This work focuses on applying personalized FL for on-device language modeling. Due to limitations of memory and latency, these models cannot support the complexity of sub-word tokenization or beam search decoding, resulting in the decision to deploy a closed-vocabulary language model. However, closed-vocabulary models are unable to handle out-of-vocabulary (OOV) words belonging to specific users. To address this issue, We propose a novel technique called "OOV expansion" that improves OOV coverage and increases model accuracy while minimizing the impact on memory and latency. This method introduces a personalized "OOV adapter" that effectively transfers knowledge from a central model and learns word embedding for personalized vocabulary. OOV expansion significantly outperforms standard FL personalization methods on a set of common FL benchmarks.
Introduction
On-device language models, such as those powering smartphone keyboards, operate under stringent memory and latency constraints. Unlike large-scale cloud-based models that utilize subword tokenization to handle nearly any text string, mobile models often rely on a closed vocabulary—a fixed list of common words. This leads to the "Out-of-Vocabulary" (OOV) problem: when a user types a word not in the fixed list (e.g., specific names, slang, or technical jargon), the model treats it as a generic [UNK] (unknown) token. This limitation significantly hinders personalization, as individual users frequently rely on a "heavy tail" of unique vocabulary. While Federated Learning (FL) enables decentralized model training, integrating these user-specific OOV words into a model's prediction head remains a challenge.
Methods: OOV Expansion
To overcome the OOV bottleneck, we propose OOV Expansion, a method built upon a character-aware LSTM architecture. The system consists of three primary components:
- Base Model: A Character Convolutional Neural Network (CharCNN) generates word embeddings from raw characters, which are then processed by an LSTM for sequence logic and an MLP decoder for ranking words in the fixed vocabulary.
- OOV Adapter: The core innovation is a lightweight Multi-Layer Perceptron (MLP) with residual connections. This adapter "translates" the general features from the CharCNN into specialized embeddings for the OOV task.
- Personalization Flow: During on-device personalization, the system identifies the user's most frequent OOV words. The CharCNN extracts raw features, which the OOV Adapter transforms into "adapted OOV word embeddings." Final predictions are generated by concatenating scores from the standard vocabulary and these new OOV scores, calculated via an inner product with the LSTM's hidden state.
This entire process occurs locally, ensuring that private, user-specific vocabulary never leaves the device.
Experimental Setup
The approach was evaluated on two Federated Learning benchmarks:
- Pushshift.io Reddit: Characterized by high heterogeneity and a diverse range of slang and user-specific language.
- Stack Overflow: Focused on technical questions and answers containing niche programming jargon.
Data was partitioned by user ID to simulate the non-IID (not identically and independently distributed) environment typical of real-world mobile usage.
Key Results
Performance was measured using EMR3 (Exact Match Rate at top 3), representing how often the correct word appears in the top three suggestions.
- Accuracy Improvements: OOV Expansion achieved a 5.6% relative improvement on the Reddit dataset and a 2.5% improvement on Stack Overflow compared to standard personalization methods.
- Error Reduction: The "unknown-word rate" (frequency of
[UNK]predictions) was reduced by over 97% across both datasets. - Efficiency: The method is highly parameter-efficient, using 24% fewer parameters during personalization than a hypothetical "OOV-Oracle" model while delivering superior results.
Ablation studies further revealed that the OOV Adapter improves accuracy on known words by 15% compared to a trivial implementation, suggesting it effectively manages the interference between general and personalized tasks.
Conclusion and Future Work
OOV Expansion provides a robust solution for personalizing on-device language models within strict hardware constraints. While currently focused on LSTM architectures, future research could explore adapting these techniques for subword-based models like Transformers. Additionally, addressing the "cold-start" problem for new users and integrating Differential Privacy to further enhance the security of the Federated Learning process remain important areas for future development.
Summary updated