Composable Sketches for Functions of Frequencies: Beyond the Worst Case

Edith Cohen, Ofir Geri, Rasmus Pagh

Abstract

In large-scale data processing, estimating high-frequency moments ($p > 2$) is traditionally considered a "hard" problem, with theoretical lower bounds suggesting memory requirements that grow polynomially with the number of unique items. This paper challenges these pessimistic worst-case assumptions. By leveraging machine learning advice and assuming realistic, skewed data distributions, the authors demonstrate that standard, polylogarithmic-sized sketches can estimate these complex statistics with high accuracy. This work bridges the gap between theoretical limitations and the practical success of sketching in real-world network monitoring and database optimization.

Introduction

As data volumes continue to explode, sketches—compact, summarization-based data structures—have become indispensable for processing massive streams and distributed datasets. A critical property of these sketches is composability: the ability to merge summaries from different sources to reflect the combined dataset.

However, sketching theory is often dominated by the "curse" of high-order moments. While statistics like the number of distinct elements ($L_0$) or the second frequency moment ($L_2$) are "easy" to estimate with minimal space, higher-order moments ($L_p$ for $p > 2$) are theoretically "hard." In the worst case, estimating these values requires memory that scales with the number of unique items ($n$), making them impractical for truly large-scale applications. This paper investigates why these "hard" functions often perform remarkably well in practice and provides a framework for using machine learning to further optimize their performance.

Methodology

1. The Advice Model

The authors propose a novel sketch architecture that incorporates "advice" from external sources, such as a machine learning model that predicts item frequencies. The core of this approach is the Sample by Advice algorithm. This algorithm maintains three distinct components to ensure both efficiency and robustness:

  • Weighted Sampling: Samples items based on the frequencies predicted by the advice.
  • Heavy Hitter Sampling: Specifically tracks the items predicted to be the most frequent.
  • Uniform Sampling: Acts as a fallback to ensure the sketch remains robust even if the ML advice is inaccurate.

2. Emulation Overhead Framework

To quantify the efficiency of standard sketches, the authors introduce the concept of "emulation overhead." This metric measures the additional space a standard sketch (like an $L_2$ sampler) requires to accurately estimate a more complex function (like an $L_{10}$ moment). This framework allows for a formal comparison between specialized sketches and general-purpose ones.

3. Realistic Distribution Analysis

Rather than assuming worst-case data, the authors analyze performance on restricted but realistic frequency distributions, specifically focusing on Zipfian distributions. These distributions are common in natural language, web traffic, and network logs, where a few items account for the majority of the total frequency.

Key Insights: The Power of Skewed Data

The Heavy Hitter "Aha!"

Theoretical lower bounds for high-order moments are typically proven using "hard" distributions where the most frequent item is not a dominant "heavy hitter." However, in real-world data, the top items are usually very dominant. The authors show that if a distribution contains an $L_q$ heavy hitter, an $L_q$ sketch can emulate any $L_p$ sampling (where $p > q$) with remarkably small overhead.

$L_2$ as a Universal Workhorse

One of the most surprising findings is the versatility of $L_2$ samplers. While theory suggests that using an $L_2$ sketch to estimate an $L_{10}$ moment could require thousands of times more space, empirical tests on real-world data showed an overhead of only 1.2 to 20. This suggests that standard $L_2$ sketches are far more powerful than previously understood.

Zipfian Universality

For data following a Zipfian distribution, the authors prove that a single polylogarithmic sketch can act as a "universal emulator." This means one compact summary can be used to estimate any monotone function of frequencies, significantly simplifying the deployment of sketches in production environments.

Empirical Results

The theories were validated using several diverse, real-world datasets: AOL (search logs), CAIDA (network traffic), Stack Overflow (user interactions), and UGR (ISP traffic).

  • Accuracy in High Moments: On the AOL and Stack Overflow datasets, high moments (up to $p=10$) were estimated with low error using samples significantly smaller than those predicted by worst-case theory.
  • Distribution Reconstruction: The authors demonstrated that simple $L_1$ and $L_2$ sketches could accurately reconstruct the "rank-frequency" curve, a task traditionally considered difficult without specialized structures.
  • Theoretical Robustness: Theorem 3.1 proves that even if ML advice is only "approximately accurate," the sampling error remains bounded, and the sketch size only increases by a constant factor relative to the uncertainty of the advice.

Limitations and Future Directions

While the results are promising, the authors identify several areas for further research. One challenge is certification: while it is easy to prove a sketch is accurate when a heavy hitter is present, it is much harder to "certify" the accuracy of a sketch on near-uniform distributions. Additionally, while the "Sample by Advice" method is robust, further work is needed to optimize the balance between the advice-driven and uniform sampling components. Finally, the current universal emulation results primarily apply to monotone functions; extending this to non-monotone statistical queries remains an open problem.

Conclusion

This work demonstrates that the theoretical "hardness" of frequency moments is often an artifact of worst-case analysis that does not reflect real-world data. By embracing the skewed nature of actual datasets and incorporating machine learning advice, we can build composable sketches that are both tiny and highly accurate, even for the most demanding statistical functions.

Summary updated

BibTeX
@inproceedings{cohen2020composable,
  author = {Edith Cohen and Ofir Geri and Rasmus Pagh},
  title = {{Composable Sketches for Functions of Frequencies: Beyond the Worst Case}},
  booktitle = {International Conference on Machine Learning},
  year = {2020},
  url = {https://openreview.net/forum?id=Jr0cL-OWdpq},
}
Figure