TL;DR
Computing weighted samples from massive, distributed streams often requires first aggregating all distinct keys to calculate their frequencies—an operation that explodes memory requirements. This paper introduces composable sketches that sample keys proportionally to any concave sublinear function of their frequency (e.g., square roots, logarithms, frequency caps) using memory proportional only to the sample size $k$, without aggregating the full dataset.
What Problem Does This Paper Address?
In web analytics, machine learning, and advertising, datasets are commonly represented as streams of unaggregated key-value pairs (e.g., user clicks, word occurrences, search queries). High-frequency keys often dominate the data, so practitioners apply concave sublinear functions $f(\nu)$—such as $\sqrt{\nu}$, $\ln(1 + \nu)$, or $\min\{T, \nu\}$—to dampen runaway frequencies (as in word2vec negative sampling or ad frequency capping).
Ideally, we want to draw an importance sample of $k$ keys proportional to $f(\nu_x)$ to compute unbiased statistics or stochastic gradients. However, when keys are distributed across millions of devices or servers, standard algorithms require a massive key-value hash table to aggregate frequencies $\nu_x$ before sampling. For datasets with hundreds of millions of unique keys, this is prohibitively expensive.
Methods
The authors design a composable (mergeable) streaming sketch whose size depends on $k$, not on the total number of distinct keys in the stream:
- Integral Decomposition via Laplace Transform: Any soft concave sublinear function can be expressed as $f(\nu) = \int_0^\infty a(t)(1 - e^{-\nu t}) dt$. The algorithm splits this integral into two regimes at an adaptive threshold $\gamma$:
- Low-frequency range ($[0, \gamma]$): Handled directly using standard Probability Proportional to Size Without Replacement (PPSWOR) sampling sketches.
- High-frequency tail ($(\gamma, \infty)$): Handled using a randomized mapping where items are assigned random scores such that their maximum expected value matches the integral.
- Stochastic PPSWOR Sampling: Standard PPSWOR assumes deterministic weights. The authors establish a new theoretical framework showing that running PPSWOR on stochastic estimates of weights inflates the estimator's variance by at most a factor of $4$ (and closer to $2$ in typical regimes).
- The SumMax Sketch and Sideline Queue: The high-frequency component is processed through an auxiliary "SumMax" sketch. Elements with values dependent on the moving threshold $\gamma$ are temporarily parked in a priority queue ("Sideline") until $\gamma$ decreases sufficiently, keeping the active working memory bounded.
- Two-Pass Estimation: Pass 1 extracts the sample of $k$ keys. Pass 2 gathers their exact frequencies across the distributed nodes to compute unbiased Horvitz-Thompson estimates.
Datasets
The authors evaluated their sketches on both real-world and synthetic datasets:
- abcnews: 7.07M word occurrences (91.7K unique keys) from news headlines.
- flickr: 7.64M image tag annotations (572.4K unique keys).
- Synthetic Zipf distributions: Three datasets of 2.00M elements each, with Zipf parameters $\alpha \in \{1.1, 1.2, 1.5\}$, representing $22.3\text{K}$ to $652.2\text{K}$ unique keys.
Key Insights and Ideas
- Decoupling Sketch Size from Key Space: By adaptively moving items between standard PPSWOR and a stochastic bottom-$k$ sketch, the sketch avoids tracking inactive or low-impact keys, keeping expected sketch memory bounded by $O(k)$.
- Stochastic Weights in Sampling: Proving that PPSWOR is robust to independent stochastic weight perturbations unlocks the ability to use Poisson/exponential process estimators inside streaming sample structures.
- Mergeability: Sketches can be merged pairwise across arbitrary distributed partitions simply by taking element-wise minimums and standard bottom-$k$ merges.
Key Results
- Near-Optimal Estimation Quality: Across both target functions ($f(\nu) = \sqrt{\nu}$ and $f(\nu) = \ln(1 + \nu)$), the empirical Normalized Root Mean Squared Error (NRMSE) was almost indistinguishable from offline benchmarks that require full aggregation (exact PPSWOR and Priority Sampling). For example, at $k = 100$, actual NRMSE was $\approx 0.10$ across datasets (well below the conservative worst-case theoretical bound of $0.404$).
- Dramatic Space Reductions: Instead of storing hundreds of thousands of keys, the sketch held at most $\approx 1.1k$ to $1.2k$ distinct keys on average. Total buffered elements in the sketch rarely exceeded $3k$, even during intermediate streaming states.
Limitations and Future Work
- Two-Pass Requirement: Estimating sums requires a second pass over the data to collect the true frequencies of the sampled keys.
- Strictly Non-Negative Updates: Unlike $\ell_p$ sampling sketches based on linear projections, this framework does not support deletions or turnstile updates (negative values).
- Per-Element Computational Overhead: Processing an element requires generating $r = k/\varepsilon$ independent random variables, making per-element streaming updates computationally heavier when $k$ is large or $\varepsilon$ is very small.
Summary updated