Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan

Analyze Self-Attention for Feed Ranking

HardMachine Learning00:00
Practice interviewer
In session
5 left
00:00

Your question is Analyze Self-Attention for Feed Ranking. Take a moment with it on the right.

Talk me through your thinking if you like. When you're confident, submit your answer and I'll grade it like a real screen (7/10 or better passes).

You need to log in / sign up to chat or submit.

Problem

Business Context

Meta wants to improve lightweight text understanding for Facebook Feed ranking features derived from post text and comment context. You are asked to explain self-attention mathematically, implement it correctly, and reason about whether it can meet production latency constraints.

Dataset

You are given a supervised learning dataset built from public-post text embeddings and engagement labels used for an offline ranking proxy.

Feature GroupCountExamples
Token IDs1 sequencewordpiece token ids for post text, hashtags, and short comment context
Attention masks1 sequencevalid-token mask, padding mask
Dense metadata12language id, device family, author follower bucket, post age bucket
Target1binary high-engagement label
  • Size: 2.4M examples, max sequence length 256, vocabulary size 50K
  • Target: Binary — high engagement in the next 24 hours (1) vs not high engagement (0)
  • Class balance: 18% positive, 82% negative
  • Missing data: ~6% missing in metadata features; text is always present but sequence lengths vary heavily

Success Criteria

A strong solution should:

  • derive the self-attention equations clearly, including query, key, value projections and softmax normalization
  • explain why scaled dot-product attention uses the factor $1/\sqrt{d_k}$
  • quantify time and memory complexity with respect to sequence length and hidden size
  • implement a correct attention module and train a small classifier baseline
  • discuss when self-attention becomes impractical for long Facebook Feed sequences and what approximations are reasonable

Constraints

  • P95 online inference budget for the text encoder is under 20 ms on a single production GPU batch
  • The solution should support variable-length sequences with padding masks
  • Researchers care about correctness and scaling behavior more than leaderboard performance

Deliverables

  1. Derive scaled dot-product self-attention mathematically, including tensor dimensions.
  2. Analyze computational and memory complexity for single-head and multi-head attention.
  3. Implement a PyTorch attention-based classifier with masking.
  4. Evaluate against a mean-pooled embedding baseline.
  5. Recommend whether this architecture is suitable for Facebook Feed ranking under the stated latency constraints.