Predicting Sentences using N-Gram Language Models

Steffen Bickel, Peter Haider, Tobias SchefferEMNLP 2005

Abstract

We explore the benefit that users in several application areas can experience from a "tab-complete" editing assistance function. We develop an evaluation metric and adapt N-gram language models to the problem of predicting the subsequent words, given an initial text fragment. Using an instance-based method as baseline, we empirically study the predictability of call-center emails, personal emails, weather reports, and cooking recipes.

Introduction

In the context of modern writing assistance, predicting the remainder of a sentence remains a significant challenge. This paper explores the feasibility of "tab-complete" functionality for full sentences, aiming to help users speed up repetitive writing tasks like answering customer emails. The core challenge lies in the user experience trade-off: while accurate suggestions save time, incorrect ones distract the writer and incur a time penalty for rejection. We bridge the gap between raw language modeling and practical assistance by developing evaluation metrics that quantify the trade-off between keystroke savings and unnecessary distractions.

Methodology

We compared two primary approaches for sentence completion:

  1. Interpolated N-Gram Models: A mixture of N-gram models (up to $N=5$) was used, with weights optimized via an Expectation-Maximization (EM) algorithm. To find the most likely completion efficiently, we implemented a Viterbi beam search, allowing for real-time decoding.
  2. Instance-Based Baseline: A "nearest neighbor" approach that finds the most similar fragment in the training data using TFIDF and cosine similarity, suggesting the remainder of that historical sentence.

A critical component of our system is the confidence threshold ($\theta$). Suggestions are only presented if their probability exceeds this threshold. Furthermore, we employed a "harsh" evaluation metric: if any part of a suggested sentence is incorrect, the entire suggestion is treated as a failure, reflecting the reality that editing a bad suggestion often takes longer than typing from scratch.

Precision and Recall metrics used to evaluate the sentence completion system.

Experimental Setup

The study evaluated four distinct document collections to test how domain-specific repetitiveness affects performance:

  • Service Center Emails: Highly repetitive German-language customer service replies.
  • Enron Emails: Highly idiosyncratic English-language personal emails.
  • Weather Reports: Thematically consistent German-language reports.
  • Cooking Recipes: Thematically related but diverse German-language recipes.

Results and Analysis

Our findings reveal a direct inverse relationship between a dataset's entropy (unpredictability) and system performance. The service center emails, having the lowest entropy (1.41 bits), yielded the best results. In contrast, the high-entropy Enron emails (7.17 bits) were nearly impossible to predict accurately.

Precision-Recall performance on the service center dataset, showing the superiority of the N-gram approach.

In the service center domain, the N-gram model achieved 60% keystroke savings at 85% precision. Even with a demand for 95% precision, the system still saved 40% of keystrokes. The N-gram model consistently outperformed the instance-based method, which saw sharp precision drops as suggested completions grew longer. For personal emails, the benefit was marginal, with less than 1% keystroke savings at 60% precision, highlighting that "tab-complete" is most effective for professional, repetitive tasks.

Conclusion and Future Work

While N-gram models with Viterbi decoding provide an efficient and high-precision solution for predictable domains, several limitations remain. Our evaluation assumes uniform user behavior, whereas actual benefit is subjective. Future work should explore adaptive models that learn a user's specific style in real-time and investigate the UI/UX implications of how suggestions are presented to the writer.

Summary updated

BibTeX
@inproceedings{bickel2005predicting,
  author = {Steffen Bickel and Peter Haider and Tobias Scheffer},
  title = {{Predicting Sentences using N-Gram Language Models}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2005},
  url = {https://openreview.net/forum?id=HybP7mZ_br},
}
Figure