AI Engineer Interview Questions: 45+ Technical Concepts & System Design Answers
Interviewing for an AI engineering role isn't about regurgitating textbook definitions. It's about demonstrating you can navigate the messy intersection of research math, distributed systems, and production reliability. Whether you're targeting a pure ML platform role or a Forward Deployed Engineering position where you ship AI inside a customer's firewall, the bar is shifting rapidly.
This guide cuts through the noise. We've structured these AI engineer interview questions to mirror the actual flow of a technical screen—moving from foundational concepts to the high-signal system design discussions that determine your level.
Foundational ML & Deep Learning Concepts
Before you touch a Transformer, you must demonstrate you know what happens under the hood when training fails.
1. Explain the Bias-Variance Tradeoff.
Answer: Bias is the error from overly simplistic assumptions (underfitting). Variance is the error from sensitivity to small fluctuations in the training set (overfitting). Total error = Bias² + Variance + Irreducible Error. In deep learning, we often fight variance with data augmentation and regularization (Dropout, L2), while fighting bias by increasing model capacity or training longer. The "double descent" phenomenon challenges the classic U-shaped curve, showing that in over-parameterized regimes, test error can decrease again.
2. Why does gradient descent get stuck in local minima, and how do we escape them?
Answer: In high-dimensional non-convex loss landscapes, true local minima are rare; saddle points are the main bottleneck. Momentum (SGD with momentum, Adam) helps the optimizer barrel through flat regions. Adaptive learning rates (Adam, RMSprop) rescale gradients to escape plateaus. Stochasticity from mini-batching also injects noise that can push the trajectory out of shallow minima.
3. What is the difference between Batch Normalization and Layer Normalization?
Answer:
- Batch Norm: Normalizes across the batch dimension (N, H, W). It relies on batch statistics, making it problematic for small batch sizes or recurrent networks.
- Layer Norm: Normalizes across the feature dimension (C, H, W) independently for each sample. It is batch-size agnostic and is the standard for Transformers because it handles variable sequence lengths gracefully.
| Feature | Batch Normalization | Layer Normalization |
|---|---|---|
| Normalization Axis | Batch dimension | Feature dimension |
| Dependency | Depends on batch statistics | Independent per sample |
| Use Case | CNNs | Transformers (GPT, BERT) |
Large Language Models (LLMs) & Transformers
This is the core of the modern AI engineer interview. You must know the attention mechanism cold.
4. Walk me through the self-attention mechanism.
Answer: Self-attention allows a token to look at every other token in the sequence.
- Projections: Create Query (Q), Key (K), and Value (V) matrices from the input embedding.
- Scores: Compute the dot product of Q and Kᵀ to get a score matrix.
- Scale: Divide by √dₖ (dimension of K) to prevent vanishing gradients in Softmax.
- Weights: Apply Softmax to get attention weights.
- Output: Multiply weights by V.
# Simplified PyTorch pseudocode
import torch.nn.functional as F
def attention(Q, K, V):
d_k = K.size(-1)
scores = Q @ K.transpose(-2, -1) / (d_k ** 0.5)
weights = F.softmax(scores, dim=-1)
return weights @ V
5. Why does GPT use a causal mask?
Answer: To prevent information leakage from future tokens. A causal mask ensures the prediction for token t depends only on tokens 0 to t-1, preserving the autoregressive property. This is implemented by setting the upper triangular attention scores to -inf before Softmax.
6. What is KV-Caching and why is it critical for inference?
Answer: During autoregressive generation, we recalculate Q, K, V for the entire sequence at every step. KV-Caching stores the previous Keys and Values. At step t, we only compute Q for the new token and concatenate it with the cached K and V. This reduces inference latency from O(n²) sequential computation to O(n) per step.
7. Compare GPT (decoder-only) with BERT (encoder-only) and T5 (encoder-decoder).
Answer:
- GPT (Decoder-only): Autoregressive, causal attention. Best for text generation.
- BERT (Encoder-only): Bidirectional attention. Best for understanding tasks (classification, NER).
- T5 (Encoder-Decoder): Encoder processes full input, decoder generates output autoregressively. Best for sequence-to-sequence tasks (translation, summarization).
Retrieval-Augmented Generation (RAG) & Vector Databases
If you can't design a RAG pipeline, you aren't ready for a production AI role. This is the most common system design topic in AI engineer interview questions.
8. What is the "Lost in the Middle" problem in RAG?
Answer: LLMs attend most heavily to the beginning and end of a context window, ignoring information in the middle. When retrieving 20+ documents, critical facts in the 8th-12th chunks are often ignored. Mitigations: Re-rank chunks by relevance, use Long-Context LLMs (Gemini, GPT-4-128k), or perform iterative retrieval ("chain-of-note").
9. Design a chunking strategy for a legal document Q&A system.
Answer:
- Chunk Size: ~512 tokens with 10% overlap.
- Strategy: Semantic splitting using a sentence transformer to detect breakpoints where topic shifts, rather than fixed-length splitting.
- Metadata: Attach section titles, page numbers, and document IDs to every chunk.
- Hierarchical: Use a two-pass retrieval (small-chunks for embedding, large parent-chunks for context).
For a hands-on walkthrough of building such a system with open-source tools, see our guide on building a RAG chatbot over your own PDFs and notes using a free vector store.
10. How do you evaluate a RAG system?
Answer: A robust evaluation uses the RAGAS triad:
- Faithfulness: Is the answer grounded in the retrieved context? (Detect hallucinations)
- Answer Relevance: Does the answer address the question?
- Context Relevance: Is the retrieved context focused and on-topic?
11. What distance metrics work best for high-dimensional vectors?
Answer:
- Cosine Similarity: Measures angle, ignoring magnitude. Standard for text embeddings.
- Euclidean Distance (L2): Sensitive to magnitude. Works well if embeddings are normalized.
- Dot Product: Efficient but requires normalized vectors to map to cosine similarity.
Prompt Engineering & Agentic Architectures
Prompting is a brittle UX layer. Agents are the control logic. You must distinguish engineering from guesswork.
12. What is the difference between ReAct, Plan-and-Solve, and Reflection agents?
Answer:
- ReAct: Interleaves reasoning traces with actions. The model thinks, acts, observes, and repeats.
- Plan-and-Solve: The model creates a complete plan before executing any actions. Better for long-horizon tasks.
- Reflection: The agent executes, then critiques its own output and iterates to improve.
13. How do you prevent prompt injection in a production LLM app?
Answer:
- Input Sanitization: Strip control characters.
- Delimiters: Use XML tags or triple backticks to separate untrusted data from instructions.
- Privilege Separation: The LLM never sees raw SQL or API keys; it only triggers pre-defined, parameterized functions.
- A Second LLM Filter: A cheap, fast model screens input before the primary model processes it.
14. Explain the concept of "Tool Use" (Function Calling) vs. "Code Interpreter."
Answer:
- Tool Use: The LLM generates a structured JSON blob (arguments) to call a deterministic external API (e.g.,
get_weather(lat, lon)). The logic is executed outside the LLM. - Code Interpreter: The LLM generates executable code (Python), which runs in a sandboxed environment. The output is fed back into the context. Better for math/reasoning, riskier for security.
MLOps, Deployment & Scaling
A model in a Jupyter notebook is a science project. A model serving 10k requests/second is engineering.
15. You need to serve a 70B parameter model with low latency. What techniques do you apply?
Answer:
- Quantization: INT8 or FP8 reduces memory bandwidth bottlenecks. GPTQ/AWQ for GPU.
- Tensor Parallelism: Shard weight matrices across multiple GPUs (Megatron-LM style).
- Continuous Batching: Dynamically append/remove sequences from a running batch (vLLM).
- Speculative Decoding: Use a small draft model to predict tokens, verified by the large model.
16. What is LoRA (Low-Rank Adaptation) and why is it used?
Answer: LoRA freezes pre-trained weights and inserts trainable rank-decomposition matrices into attention layers. It reduces trainable parameters by ~10,000x, allowing fine-tuning of large models on a single GPU. The adapter weights (a few MB) can be hot-swapped without changing the base model.
17. How do you detect data drift vs. concept drift?
Answer:
- Data Drift: Monitor the distribution of input features (P(X)). Use KL divergence or KS test on production data vs. training data.
- Concept Drift: Monitor the relationship between input and output (P(Y|X)). Detect by tracking prediction error over time. If error rises but input distribution is stable, concept drift is likely.
18. Describe a CI/CD pipeline for an ML model.
Answer:
- CI: On PR, run unit tests on feature engineering code, data validation (Great Expectations), and model evaluation (accuracy > threshold).
- CD: Package model as a Docker container. Push to registry. Deploy to staging (canary), run A/B tests against production model. If performance is better, roll out gradually.
System Design: Designing an End-to-End AI Feature
This is the "leveling" section. Senior candidates don't just list components; they discuss trade-offs. This is where most AI engineer interview questions converge.
19. Design a customer support ticket auto-tagger for a large enterprise.
Scenario: Millions of historical tickets with human-applied labels. Real-time latency requirements.
Answer Structure:
1. Data Preparation & Label Space:
- Analyze label distribution. Handle long-tail labels ("Other" bucket or few-shot classification).
- Clean text: Remove PII, HTML tags, signatures.
2. Model Selection:
- Phase 1 (Cold Start): Fine-tune a BERT-family model (DistilBERT for speed) on historical data.
- Phase 2 (LLM Hybrid): For low-confidence predictions (<0.9 softmax), route to a cheap LLM (GPT-4o-mini) for zero-shot classification.
3. Architecture:
4. Evaluation & Monitoring:
- Offline: Macro-F1 score on a holdout set.
- Online: Human acceptance rate (how often do agents change the tag?).
Forward Deployed Engineering & The Real-World Gap
If you're interviewing for an AI role that touches customers—like an FDE at Palantir or a Solutions Architect at OpenAI—you need a different muscle. It's not just about accuracy; it's about shipping under constraints. The reality of an FDE role involves translating messy business logic into robust pipelines, often inside the customer's locked-down environment, which is exactly what we cover in our breakdown of what a Forward Deployed Engineer actually does in a week.
20. A customer wants an LLM feature deployed on their air-gapped on-prem server. You can't call external APIs. How do you build it?
Answer:
- Model Selection: Choose an open-weight model (Llama 3, Mistral) that fits within their hardware constraints.
- Quantization: Use
llama.cppor vLLM to run the model efficiently on CPU or a single GPU. - Artifact Delivery: Package the model weights, inference server, and a minimal UI into a Docker image or an OVA file.
- Guardrails: Implement hard-coded output validation (regex, JSON schema) since you can't use an external moderation API.
This "embed" model is critical. Mastering the ability to operate inside a customer's security perimeter and become indispensable within 30 days is a superpower detailed in our guide on the Palantir-style FDE embed.
21. You have 2 weeks to build a prototype that classifies a bank's transaction data. The data is messy CSVs with no dictionary. Walk me through your week.
Answer:
- Day 1-2 (Discovery): Meet the SME. Visually inspect the CSVs. Identify the "target column" and obvious garbage (nulls, test accounts).
- Day 3-5 (Pipeline): Build an ETL pipeline (Pandas/Polars). Normalize merchant names ("AMAZON.COM" vs "AMZN MKTPLACE").
- Day 6-8 (Modeling): Start with regex + embedding similarity (no training data required). Generate a silver-standard dataset. Fine-tune a small classifier.
- Day 9-10 (UI): Wrap it in a Streamlit app where the SME can correct labels. This creates the feedback loop for retraining.
This rapid prototyping cycle—turning a messy customer problem into a shipped prototype in a week—is the core engineering challenge we unpack in our guide on FDE rapid prototyping.
FAQ
What is the difference between an AI Engineer and an ML Engineer?
An ML Engineer focuses on the model lifecycle: training, optimization, and feature engineering. An AI Engineer often works at a higher abstraction layer, integrating LLM APIs, vector databases, and agentic frameworks (LangChain) into products. The lines are blurring, but AI Engineers tend to be more product-and-API-oriented.
How do I prepare for an AI engineer coding interview?
Focus on data manipulation (Python/Pandas), API design (FastAPI), and system design over LeetCode. Be ready to write a streaming pipeline, implement a basic vector search, or design a schema for LLM traces.
Do I need a PhD to be an AI Engineer?
No. For applied AI engineering roles, production experience (Kubernetes, MLOps, SQL) often outweighs a research background. A Master's degree is common, but strong engineering fundamentals and a portfolio of shipped projects are sufficient.
What is the hardest part of an AI engineering interview?
The system design section. You must demonstrate you understand the failure modes of LLMs (latency, hallucinations, cost) and how to architect around them, not just the happy path.
How do you handle hallucinations in a production system?
You don't eliminate them; you contain them. Use constrained generation (JSON mode, grammar-based sampling), strict output validation, RAG with citations, and human-in-the-loop review for high-stakes actions.
Want to build like a Forward Deployed Engineer?
FDE Coach is a cohort-based program in frontend, backend, AWS, and AI. Build real products and get referred to 200+ hiring partners.
Explore the program