Features and Embeddings

Updated Nov 16, 2026 · 4 min read
On this page

    Two candidates get the same prompt: predict whether a user will watch a video. One says "we'll use user features and video features." The other says "the strongest signal will be how often this user finished this creator's last 20 videos, computed hourly; I'd add the video's completion rate over the last day, and a learned embedding of the user's recent watch history." Same model, very different scores. Features are where most of the predictive power lives, and where the interviewer sees whether you understand the product.

    How it works

    Group your features

    Four groups make any feature list easy to follow. Cross features, which describe this user with this item, often matter most.
    Four groups make any feature list easy to follow. Cross features, which describe this user with this item, often matter most.

    Say features in four groups, and give two or three concrete examples in each:

    1. User features: who they are and how they behave. Country, language, account age, device; aggregates such as "videos watched in the last 7 days"; an embedding of recent history.
    2. Item features: what the thing is. Length, topic, language, upload age, creator; quality signals such as completion rate or report rate.
    3. Context features: the situation. Time of day, day of week, surface (home, search, notification), device, network.
    4. Cross (user × item) features: this user with this item. Has the user watched this creator before? How well does the topic match their interests? How similar are their embeddings?

    Turn raw data into numbers

    Models need numbers. The common transformations:

    • Numeric values: use as they are for tree models; for neural networks, scale them (log of counts, standardise to zero mean and unit variance), and cap extreme values.
    • Categories with few values (device type, surface): one-hot encoding.
    • Categories with many values (user ID, video ID, query terms): embeddings, or hashing into a fixed number of buckets.
    • Counts over time windows: "clicks on this item in the last 1 hour, 1 day, 7 days." Several windows let the model see both trend and level.
    • Ratios with smoothing: a click-through rate of 1/1 is not the same as 1,000/1,000. Add a prior: (clicks + α) / (impressions + α + β).
    • Text and images: pass them through a pretrained encoder and use the resulting vector.

    Embeddings

    An embedding replaces an ID with a short learned vector. After training, items that users treat alike sit close together, so distance works as similarity.
    An embedding replaces an ID with a short learned vector. After training, items that users treat alike sit close together, so distance works as similarity.

    An embedding is a lookup table: each ID gets a vector of, say, 64 numbers, and those numbers are learned during training like any other weights. After training, items that appear in similar contexts (watched by the same people, clicked after the same queries) end up close together.

    Embeddings matter in ML system design for three reasons:

    1. They handle huge vocabularies. Millions of videos become millions of short vectors instead of a million-wide one-hot.
    2. They give you similarity for free. "Users who liked this also liked" becomes nearest-neighbour search on vectors, which is the basis of most retrieval systems.
    3. They are reusable. An item embedding trained for one task (watch prediction) is a strong feature for others (search, ads, notifications).

    Embeddings come from several places: learned inside your model, learned in a separate model such as a two-tower model (see Patterns), or produced by a pretrained encoder for text and images.

    Trade-offs and costs

    • Freshness versus cost. "Clicks in the last 5 minutes" needs a streaming pipeline; "clicks in the last day" can come from a daily batch job. Use fast features only where they change the prediction.
    • Hand-made versus learned. Hand-made features are easy to debug and work well with tree models; learned embeddings capture patterns no one thought of, but need lots of data and are harder to explain.
    • More features versus serving latency. Every feature is a lookup at request time. 500 features × 1,000 candidates is half a million values per request. Keep the ranking model's feature set to what earns its place.
    • High-cardinality IDs. ID embeddings memorise popular items well but know nothing about new ones (cold start). Pair them with content features that work for new items.
    • Privacy. Some features (precise location, sensitive attributes) may be off limits or need consent. Say so when they come up.

    When to reach for it

    Step 2 of every ML design. Go deep here when the interviewer asks "what features would you use?", which is one of the most common deep-dive questions, or when the model ladder moves from trees (hand-made features) to neural networks (embeddings).

    Example

    Prompt: "Rank restaurants in a food delivery app."

    • User: cuisines ordered in the last 90 days, average order price, typical order hour, dietary filters used.
    • Item (restaurant): cuisine, rating with smoothing, average prep time last 7 days, price level, menu text embedding.
    • Context: time of day, weather, distance to the user, current courier supply in the area.
    • Cross: has the user ordered here before, and how many times; similarity between the user's taste embedding and the restaurant embedding; estimated delivery time for this pair.
    • Freshness: prep time and courier supply update every few minutes from a stream; ratings and embeddings update daily.

    Common mistakes

    1. A flat list of thirty features with no grouping and no reason.
    2. Generic features ("user history") instead of specific ones ("cuisines ordered in the last 90 days").
    3. Unsmoothed ratios that rank a 1-for-1 newcomer above a 4.8-star restaurant with 5,000 reviews.
    4. Features computed differently in training and serving, which silently hurts the model in production (see Feature Stores and Training-Serving Skew).
    5. Ignoring cold start: only ID embeddings, so new items get random vectors.
    6. Forgetting cost: proposing real-time features for every signal without saying what infrastructure that needs.

    Say this in the interview

    "I'll group features as user, item, context and user-item cross. The cross features, like how often this user finished this creator's videos, will carry most of the signal. IDs become learned embeddings, counts are taken over several time windows, and rates are smoothed. Most features update daily in batch; the few that need freshness, like an item's completion rate in the last hour, come from a stream."

    Used in