AI Engineer Interview Questions (with real STAR answers)
The AI engineer interview questions that come up most, from junior to senior - LLM APIs, RAG, embeddings, evaluation, agents, and core machine learning. Short model answers for the technical questions, and STAR answers for the "tell me about a time" questions, built from real AI features you can build yourself.
AI engineer interviews mix technical questions on LLMs and machine learning, troubleshooting scenarios, and behavioral questions. This page covers the questions that come up most, from junior to senior: behavioral questions with STAR answers built from real AI features you can build yourself, then technical and scenario questions with short model answers.
AI/ML behavioral interview questions (STAR answers)
Tell me about a time you built an AI feature end to end.
Tell me about a time you reduced cost or latency.
Tell me about a time you measured or improved model quality.
Go earn this story: Build an LLM Evaluation Harness (Golden Set) →
Tell me about a time an AI feature gave bad answers and you found the cause.
Go earn this story: Fix the Chunking That's Wrecking RAG Retrieval →
Tell me about a time you made an AI feature more reliable.
Go earn this story: Harden an LLM Pipeline Against API Failures →
Tell me about a time you built an LLM feature that uses tools.
Go earn this story: Make an LLM Pick the Right Tool (Function Calling) →
AI/ML technical and scenario interview questions
What is RAG, and when would you use it instead of fine-tuning?
Retrieval-augmented generation finds relevant documents at query time and adds them to the prompt so the model answers from them. Use RAG when the model needs facts that change or are private, and when you need citations. Use fine-tuning to change style, format, or behavior on a narrow task - it is a poor way to add facts.
What are embeddings, and how do you measure similarity?
An embedding is a vector of numbers that represents the meaning of a text, so similar texts have vectors close to each other. Similarity is usually measured with cosine similarity or dot product. Use the same embedding model for documents and queries.
How do you choose a chunk size for RAG?
Chunks must be small enough to be specific and large enough to hold a complete idea - a few hundred tokens is a common start. Split on natural boundaries such as headings and paragraphs, add some overlap, keep metadata like the source and title, and pick the final size by testing retrieval on real questions.
What is a vector database?
A store for embeddings that finds the nearest vectors to a query quickly, using approximate nearest neighbor indexes such as HNSW. Examples are pgvector, Chroma, Qdrant, and Pinecone. Most also support metadata filters, and many support hybrid search that combines vector and keyword matching.
What is re-ranking in a RAG pipeline?
First retrieve many candidates quickly with vector search (a bi-encoder), then score each query and document pair with a more accurate but slower model (a cross-encoder) and keep the top few. This puts the best passages at the top of the context.
Why do LLMs hallucinate, and how do you reduce it?
The model predicts likely text, not checked facts, so it can produce confident wrong answers. Reduce it by grounding answers in retrieved context, telling the model to say when it does not know, asking for citations, using a lower temperature for factual tasks, and checking answers with evaluations.
What do temperature and top_p control?
Both control how random the output is. Temperature scales the probabilities - low values (near 0) give focused, repeatable output, higher values give more varied output. top_p keeps only the most likely tokens whose probabilities add up to p. Usually you change one of them, not both.
What is a context window, and what are tokens?
Tokens are the pieces of text the model reads and writes - roughly parts of words. The context window is the maximum number of tokens the model can handle in one request, input and output together. Cost and latency grow with tokens, so keep prompts and retrieved context focused.
How do you evaluate an LLM application?
Build a golden set of real inputs with expected outputs or grading rules. Score with exact checks where possible (valid JSON, correct label), retrieval metrics such as recall@k for RAG, and an LLM-as-judge for open answers like faithfulness and relevance. Run the evaluation on every prompt or model change and track scores over time.
What is prompt injection, and how do you defend against it?
Prompt injection is input - from a user or from a retrieved document - that tries to override the system instructions. There is no complete fix, so limit the damage: separate trusted instructions from untrusted content, give tools the least privilege, validate model output before acting on it, and require human approval for risky actions.
How does function calling (tool use) work?
You describe tools to the model with names and JSON schemas. The model responds with a tool name and arguments instead of text. Your code validates the arguments, runs the tool, and sends the result back, and the model uses it to continue. An agent repeats this loop until the task is done, with a limit on steps.
How do you get reliable JSON output from an LLM?
Use the provider's structured output or JSON mode when available, give a clear schema and an example in the prompt, then parse and validate the result (for example with Pydantic). Strip markdown code fences if present, and retry with the validation error when parsing fails.
What is overfitting, and how do you prevent it?
Overfitting is when a model learns the training data too closely, including noise, so it scores well on training data and poorly on new data. Detect it with a separate validation set. Prevent it with more data, regularization, simpler models, early stopping, and cross-validation.
What is the difference between precision and recall?
Precision is the share of predicted positives that are really positive. Recall is the share of real positives the model found. Raising one often lowers the other. Use precision when false alarms are costly, recall when missing a case is costly, and F1 when you need a balance of both.
Scenario: your LLM feature is too slow. What do you do?
Measure where the time goes - retrieval, the model call, or your own code. Stream tokens so users see output right away, cache repeated requests, shorten the prompt and context, use a smaller or faster model for simple requests, and run independent steps such as retrieval calls in parallel.
What questions are asked in an AI engineer interview?
Expect behavioral questions (tell me about a time you...), technical questions on LLM APIs, RAG, embeddings, evaluation, and core machine learning, and scenario questions such as reducing latency or improving answer quality. Many companies also give a build task, such as a small RAG app. The questions on this page cover all of these.
How do you answer behavioral interview questions?
Use STAR: Situation, Task, Action, Result. Keep it concrete - a specific project, what you owned, what you did, and the result. The answers above are all structured this way.
More for AI/ML engineers
Do real production work, free. Live cloud workspaces in your browser - every project you complete lands on your portfolio.
Get started - free