Apply the Hashing Trick to Billions of Search Query Tokens
Last updated: November 29, 2026
Quick Overview
A linear model for Google Search ad click prediction uses query tokens, advertiser IDs, and their crosses as features, which yields billions of possible values. Explain how feature hashing works, how to size the hash space, and what collisions cost.
0
0
0 solved
A linear model for Google Search ad click prediction uses query tokens, advertiser IDs, and their crosses as features, which yields billions of possible values. Explain how feature hashing works, how to size the hash space, and what collisions cost.
Ads and search models at Google work with enormous sparse vocabularies that keep growing. The interviewer wants to see that you understand feature hashing mechanically, can reason about collision rates, and know when a learned vocabulary or embedding is better.
What the Interviewer Expects
- Explains mapping features to indices with a hash function instead of a dictionary
- Explains the signed hash to make collisions cancel in expectation
- Estimates collision rates as a function of table size and active features
- Discusses memory, serving, and new-value handling benefits
- Mentions alternatives: frequency-thresholded vocabularies, multiple hashes, learned embeddings
Key Topics to Cover
How to Approach This
- Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
- Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
- Feature engineering is often more impactful than model selection.
- Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
- Handle class imbalance with SMOTE, class weights, or appropriate loss functions.
Possible Follow-up Questions
- How would you detect that collisions are hurting model quality?
- Why hash crosses separately with a namespace prefix?
- How does hashing interact with L1 regularization and model sparsity?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Explore ML Interview PrepSample Answer
Clarify
Ask how many distinct values appear per day, how many features are active per example (perhaps 200), how much memory the model can use at serving, and whether new tokens appear constantly. They do: qu...
Approach
Instead of a dictionary from feature string to index, compute and use index i in a weight vector of size m. Benefits: no vocabulary to build or ship, f...