← Questions

RNNs, LSTMs, Transformers and model predictive control

0
TeslaAI/ML designLast asked Sep 2025

An AI/ML design interview question asked in Tesla's technical phone screen, last asked Sep 2025. It tests sequence models, transformers and control.

A technical conversation about the sequence models in your own projects, followed by control theory:

  1. How did you use RNNs, LSTMs and Transformers in your project? Compare them for sequence modeling: what each can capture, how each trains, and when you would choose each.
  2. Which Transformer architecture did you use (encoder-only, decoder-only or encoder-decoder), and why?
  3. Explain the basics of model predictive control (MPC): the cost function, the constraints, the prediction and control horizons, and how it runs in a loop.
  4. How could MPC be combined with learned models?

Requirements

  • Clear, correct explanations tied to decisions you made in your own work.
  • Trade-offs stated, not just definitions.

Clarifying questions

  • Should I focus on one project in depth or compare several?
  • For MPC, is the setting vehicle control (trajectory tracking) or something else?

What a strong answer covers

  • RNNs: hidden state carried step by step, vanishing and exploding gradients, sequential training.
  • LSTMs: gates and a cell state that keep gradients alive over longer spans; still sequential, still limited for very long contexts.
  • Transformers: self-attention over the whole sequence, parallel training, quadratic cost in sequence length, positional encodings; better at long-range dependencies with enough data.
  • Choosing: small data or streaming with tight latency may favour an LSTM; long context and large data favour a Transformer. Why your project used the architecture it did (encoder-only for classification or encoding, decoder-only for autoregressive generation, encoder-decoder for sequence-to-sequence).
  • MPC: at every step, solve an optimization over a horizon of future controls that minimizes a cost (tracking error, effort, comfort) under dynamics and constraints (actuator limits, safety bounds), apply only the first control, repeat.
  • Combining: a learned dynamics model inside MPC, a learned cost or terminal value, MPC as a safety layer over a learned policy, or a policy trained to imitate MPC to save compute.

Follow-ups

  • What would change if your sequence were 100 times longer?
  • How do you make MPC run in real time on a vehicle?
  • A learned dynamics model is wrong in some regions. How does MPC behave, and how do you protect against it?

Where it's asked

  • Tesla · Technical phone screen · Last asked Sep 202545 min · 10 to 20 minutes on your background, then one compact coding, debugging or design task in CoderPad that must run

What it tests

sequence models · transformers · control

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