Implement a Text-Embedding Recommender Training Pipeline

Quick Overview

Design a local training pipeline for a text-embedding recommender using nested member profiles, item text, and clicked or skipped interactions. The exercise covers validation, embedding caches, feature joins, leakage-resistant splits, binary training, evaluation, and reproducible inference artifacts.

Implement a Text-Embedding Recommender Training Pipeline

Company: LinkedIn

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: hard

Interview Round: Technical Screen

# Implement a Text-Embedding Recommender Training Pipeline You are given three sources of local data: - Member profiles with a member ID, headline, title, positions, and education records. Position and education end dates may be null. - Items with an item ID and text. - Labeled member-item interactions whose label is either `clicked` or `skipped`. A provided `LocalLLM` exposes `generate_embeddings(texts)`. Design and write clear pseudocode for a `RecommenderTrainer` with `load_data`, `prepare_features`, and `train` methods. The result should be a binary relevance model that scores whether a member is likely to click an item. The prompt deliberately does not choose a storage format, classifier, loss, or embedding dimension. State reasonable assumptions before relying on them. ### Clarifying Questions to Ask - Are the three inputs JSON arrays, JSON Lines files, or directories of shards, and how should malformed records be handled? - May profile and item embeddings be precomputed and cached, or must each training run regenerate them? - What train-validation split prevents interactions from the same member from leaking across evaluation boundaries? - Is the click/skipped distribution highly imbalanced, and which offline metric determines success? ### Part 1 — Load and validate the data Describe the internal records and indexes created by `load_data`. Cover missing IDs, duplicate IDs, null dates, unknown interaction references, and deterministic validation behavior. #### What This Part Should Cover - A canonical text representation for nested profile fields and item text. - ID-keyed maps and a validated interaction stream. - An explicit policy for malformed, duplicate, or dangling records. ### Part 2 — Prepare model features Explain how `prepare_features` batches calls to `LocalLLM`, avoids redundant embedding work, joins embeddings to labels, and forms one training example per valid interaction. #### What This Part Should Cover - Separate member and item embedding caches keyed by stable IDs and content versions. - A concrete pairwise feature representation, such as concatenation, elementwise product, absolute difference, or cosine similarity. - Leakage controls and reproducible splitting. ### Part 3 — Train and evaluate Give pseudocode for `train`, including model choice, objective, batching, validation, and the artifact needed for later inference. #### What This Part Should Cover - A justified binary classifier and loss for clicked versus skipped labels. - Class-imbalance handling and at least one ranking-sensitive metric. - Reproducibility, checkpointing, and failure behavior. ### What a Strong Answer Covers - Connects the loader, embedding generation, feature join, split, training loop, and saved inference bundle into one coherent pipeline. - Distinguishes assumptions from facts supplied by the prompt. - Addresses empty text, missing references, duplicated interactions, embedding failures, data leakage, and skewed labels. - Explains how the trained model can reproduce exactly the same preprocessing during serving. ### Follow-up Questions 1. How would you update the pipeline when only a small fraction of profiles or items changes each day? 2. How would you evaluate retrieval quality if the system first retrieves candidates and then applies this relevance model? 3. What changes if one member can have millions of skipped items but only a few clicks?

Quick Answer: Design a local training pipeline for a text-embedding recommender using nested member profiles, item text, and clicked or skipped interactions. The exercise covers validation, embedding caches, feature joins, leakage-resistant splits, binary training, evaluation, and reproducible inference artifacts.

|Home/Machine Learning/LinkedIn
LinkedIn logo
LinkedIn
Sep 4, 2026
hardMachine Learning EngineerTechnical ScreenMachine Learning
1
0

Implement a Text-Embedding Recommender Training Pipeline

You are given three sources of local data:

  • Member profiles with a member ID, headline, title, positions, and education records. Position and education end dates may be null.
  • Items with an item ID and text.
  • Labeled member-item interactions whose label is either clicked or skipped .

A provided LocalLLM exposes generate_embeddings(texts). Design and write clear pseudocode for a RecommenderTrainer with load_data, prepare_features, and train methods. The result should be a binary relevance model that scores whether a member is likely to click an item.

The prompt deliberately does not choose a storage format, classifier, loss, or embedding dimension. State reasonable assumptions before relying on them.

Clarifying Questions to Ask Guidance

  • Are the three inputs JSON arrays, JSON Lines files, or directories of shards, and how should malformed records be handled?
  • May profile and item embeddings be precomputed and cached, or must each training run regenerate them?
  • What train-validation split prevents interactions from the same member from leaking across evaluation boundaries?
  • Is the click/skipped distribution highly imbalanced, and which offline metric determines success?

Part 1 — Load and validate the data

Describe the internal records and indexes created by load_data. Cover missing IDs, duplicate IDs, null dates, unknown interaction references, and deterministic validation behavior.

What This Part Should Cover Guidance

  • A canonical text representation for nested profile fields and item text.
  • ID-keyed maps and a validated interaction stream.
  • An explicit policy for malformed, duplicate, or dangling records.

Part 2 — Prepare model features

Explain how prepare_features batches calls to LocalLLM, avoids redundant embedding work, joins embeddings to labels, and forms one training example per valid interaction.

What This Part Should Cover Guidance

  • Separate member and item embedding caches keyed by stable IDs and content versions.
  • A concrete pairwise feature representation, such as concatenation, elementwise product, absolute difference, or cosine similarity.
  • Leakage controls and reproducible splitting.

Part 3 — Train and evaluate

Give pseudocode for train, including model choice, objective, batching, validation, and the artifact needed for later inference.

What This Part Should Cover Guidance

  • A justified binary classifier and loss for clicked versus skipped labels.
  • Class-imbalance handling and at least one ranking-sensitive metric.
  • Reproducibility, checkpointing, and failure behavior.

What a Strong Answer Covers Guidance

  • Connects the loader, embedding generation, feature join, split, training loop, and saved inference bundle into one coherent pipeline.
  • Distinguishes assumptions from facts supplied by the prompt.
  • Addresses empty text, missing references, duplicated interactions, embedding failures, data leakage, and skewed labels.
  • Explains how the trained model can reproduce exactly the same preprocessing during serving.

Follow-up Questions Guidance

  1. How would you update the pipeline when only a small fraction of profiles or items changes each day?
  2. How would you evaluate retrieval quality if the system first retrieves candidates and then applies this relevance model?
  3. What changes if one member can have millions of skipped items but only a few clicks?
Loading comments...