Time-Decayed Engagement Counts as Features for Feed Ranking

Last updated: November 29, 2026

Quick Overview

Design a feature that captures how much a user has recently engaged with a given friend's posts, weighting recent interactions more, and implement an exponentially decayed counter that can be updated in a stream.

Meta
Machine Learning
Software Engineer
Meta
November 29, 2026
Software Engineer
Onsite
Machine Learning
Medium

0

0

0 solved


Design a feature that captures how much a user has recently engaged with a given friend's posts, weighting recent interactions more, and implement an exponentially decayed counter that can be updated in a stream.

Affinity features between viewers and authors are central to Facebook Feed ranking. The interviewer checks that you can choose a decay form, implement it with O(1) state per pair, and reason about half-life and serving freshness.

What the Interviewer Expects
  • Choose exponential decay and explain the half-life parameter
  • Implement a constant-memory streaming update
  • Read the value at an arbitrary time without mutating state
  • Discuss multiple half-lives as separate features
  • Address storage cost for user and author pairs
Key Topics to Cover
Feature engineering
Exponential decay
Streaming features
User affinity
Half-life
How to Approach This
  1. Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
  2. Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
  3. Feature engineering is often more impactful than model selection.
  4. Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
  5. Handle class imbalance with SMOTE, class weights, or appropriate loss functions.
Possible Follow-up Questions
  • How would you choose between a 1-day and a 30-day half-life?
  • How do you store this for billions of viewer and author pairs?
  • How would you backfill this feature for training without leakage?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Explore ML Interview Prep
Sample Answer
Clarify

I would ask which interactions count (likes, comments, profile visits, message replies) and their weights, the freshness requirement at serving time, and whether we need the same feature computed poin...

Approach

Raw counts over all time treat a like from three years ago the same as one from yesterday. Sliding windows need per-event storage. Exponential decay needs only the current value and the last update ti...


Submit Your Answer
Markdown supported