Abstract
Query Auto-Completion (QAC) systems traditionally rely on character-level neural models to handle arbitrary prefixes and typos. However, these models suffer from high latency due to step-by-step generation. This paper explores subword language models as an efficient alternative. By introducing a "retrace" algorithm to resolve segmentation mismatches and a new metric, Mean Recoverable Length (MRL), the authors demonstrate that subword models can achieve up to a 2.5x speedup over character-level baselines while maintaining comparable accuracy.
Introduction
When a user types into a search bar, Query Auto-Completion (QAC) systems predict the intended full query. Modern neural QAC systems typically use character-level models, which predict the next character iteratively. While these models are robust to typos and out-of-vocabulary words, they are computationally expensive; a 30-character query requires 30 model inferences to generate a single candidate.
Word-level models are significantly faster but fail to handle the "incomplete" word (prefix) a user is currently typing. Subword models, such as those using Byte Pair Encoding (BPE), offer a middle ground. However, they face a "segmentation mismatch" problem: the deterministic way a system breaks a prefix into subwords may not align with how it learned to segment the full query during training, leading to poor predictive performance.
Methodology
The authors propose using subword language models—specifically Byte Pair Encoding (BPE) and Subword Regularization (SR)—to bridge the gap between speed and accuracy.
The Retrace Algorithm
To solve the segmentation mismatch, the authors introduce the "retrace" algorithm. Since a prefix might end in the middle of a subword, the model "retraces" (goes back) a fixed number of characters ($k$) from the end of the user's input. It then generates new subwords from that earlier point, ensuring the generated tokens are forced to match the characters the user already typed. This ensures that the model's internal state is consistent with the ground truth segmentation.
Approximate Marginalization
For models using Subword Regularization (SR), which can segment the same string in multiple ways, the authors employ a reranking method. Instead of selecting the single most likely sequence of tokens, they sum the probabilities of all token sequences that result in the same final query string, providing a more robust probability estimate.
Mean Recoverable Length (MRL)
The authors argue that standard metrics like Mean Reciprocal Rank (MRR) are flawed because they are sensitive to prefix length sampling. They propose Mean Recoverable Length (MRL), which measures how many characters into the future a model can correctly predict. MRL provides a more intuitive and stable measure of a QAC system's helpfulness across different query lengths.
Experimental Setup
The study utilizes the AOL query log dataset, a standard benchmark in the field. The data was split chronologically to simulate a real-world scenario where the model must predict future, unseen queries. The dataset consists of approximately 17.5 million training queries and 1.3 million test queries. Preprocessing included lowercase normalization and the removal of non-ASCII characters.
Results and Discussion
Efficiency and Accuracy
Subword models demonstrated significant efficiency gains, achieving a 2.1x to 2.5x speedup over character-level baselines on both CPU and GPU hardware. This is primarily due to the reduction in "decoding length"—the number of steps the model takes to generate a query.
In terms of accuracy, the best subword configurations (SR + Retrace + Marginalization) achieved MRR and PMRR scores within 0.02 points of the character-level baseline. This indicates that the speed boost does not come at a significant cost to prediction quality.
Robustness and Metric Stability
Models using Subword Regularization (SR) showed better generalization on queries not present in the training set compared to character-level models, suggesting that subwords capture more meaningful semantic patterns than individual letters. Furthermore, the proposed MRL metric provided a consistent ranking of models regardless of query length, proving to be a more reliable tool for evaluation than traditional rank-based metrics.
Conclusion
Subword language models, when combined with the retrace algorithm, offer a compelling alternative to character-level models for QAC, providing substantial latency reductions with minimal accuracy loss. Future work may explore Knowledge Distillation to close the remaining accuracy gap or joint learning approaches to optimize text segmentation and language modeling simultaneously.
Summary updated