← Questions

Classify a stream of tokens with embeddings

0
AppleAI/ML designLast asked Jan 2026

An AI/ML design interview question asked in Apple's technical phone screen, last asked Jan 2026. It tests streaming, embeddings and classification.

Text arrives continuously, and each item must be classified (for example by topic, intent or policy violation). Design the end-to-end system: process the raw text as it arrives, tokenize it, turn tokens into embeddings, train a classifier, and serve predictions with low latency.

Requirements

  • Functional: online preprocessing and tokenization; embeddings for each item; a classification model; real-time predictions; a way to keep the model current as data and labels change.
  • Non-functional: high throughput; low prediction latency; identical preprocessing in training and serving; affordable compute.

Clarifying questions

  • What are the classes, how many, and how balanced?
  • Where do labels come from, and how quickly do they arrive after the text?
  • What latency budget per item, and what volume per second?
  • How fast does the data change (new slang, new topics)?

What a strong answer covers

  • Preprocessing and tokenization: normalization, a subword tokenizer, handling unseen words, a shared library used by both training and serving.
  • Embeddings: pretrained sentence encoders versus training your own, pooling token embeddings, caching embeddings for repeated text, dimensionality and cost.
  • The model: a linear or small MLP head over frozen embeddings as a baseline, fine-tuning the encoder when it pays off, handling class imbalance.
  • Training: a streaming pipeline that joins text with delayed labels, periodic retraining or online updates, a validation gate before promotion.
  • Serving: batching for throughput, a latency budget split between encoder and head, model versioning and rollback.
  • Evaluation and monitoring: precision, recall and F1 per class, calibration, drift in input and prediction distributions.

Follow-ups

  • Volume grows ten times. Where is the bottleneck, and what do you change?
  • A new class appears. How do you add it without retraining from scratch?
  • Offline accuracy is high but production accuracy falls. How do you check for a mismatch between training and serving?

Where it's asked

  • Apple · Technical phone screen · Last asked Jan 2026

What it tests

streaming · embeddings · classification

Your canvas
Draw your answer hereBoxes, arrows and notes, saved for you to come back to.Sign in to start drawing