Problem
An e-commerce search page shows 24 products per query, and users click on 1–2 of them and buy even fewer. More than 90% of impressions have no interaction, so a ranking model trained on the raw log is dominated by non-clicks. Trying several sampling schemes is hard too: one day of search data holds billions of impressions across millions of sessions, and loading it into memory for each experiment is often not feasible.
Example from the article: a page of 24 products, 1–2 clicks, and over 90% of impressions with no interaction.
Solution in brief
Label every impression with a user-journey category (the session converted or only engaged, with or without a direct action), and precompute a stable pseudo-random percentile for each negative row. At training time, keep a negative only if its percentile is under the ratio set for its category. A lazy Parquet scan applies this filter before the data reaches memory.
Questions this case answers
- How to downsample the dominant negative class in logged ranking data, with different rates by user journey type, when the full log is too large to load
- How to make a random subsample reproducible across runs so different sampling ratios can be compared
- How to cut the share of no-interaction impressions in search ranking training data without hurting the signal
- How to subsample billions of search impressions when the raw log does not fit in memory
Tools and methods
- Negative sampling — drop most no-interaction impressions, at a different rate per journey category
- Stratified sampling — a separate ratio for each of four session categories
- Deterministic hash percentile — a precomputed
sampling_perccolumn makes the sample reproducible - Polars — lazy
scan_parquetwith filter pushdown, so only the kept rows are read
Google or a one-time email code. No password.