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.

Get started - freeLive cloud workspace in your browser · nothing to install

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.

Situation: The team wanted an assistant that answered from our own docs instead of giving generic or made-up answers.
Task: I had to ground the model in our content with a real retrieval pipeline.
Action: I built RAG end to end - chunked and embedded the docs, stored the vectors, retrieved the most relevant chunks for each question, and put them into the prompt with an instruction to answer only from that context.
Result: Answers came from our own documents and could cite them, and the pipeline was reusable for other document sets.

Go earn this story: Build an End-to-End RAG Pipeline →

Tell me about a time you reduced cost or latency.

Situation: LLM spend was climbing because the same prompts were being sent to the model again and again.
Task: I needed to cut cost without changing what users saw.
Action: I added a Redis cache keyed on a hash of the model name and the prompt, with a TTL, so repeated requests returned the stored response instead of calling the model.
Result: Repeated model calls dropped sharply, cost fell, and cached answers returned almost instantly.

Go earn this story: Cache LLM Responses in Redis →

Tell me about a time you measured or improved model quality.

Situation: Prompt and model changes kept going live with no way to tell if they made answers better or worse.
Task: I had to make quality measurable before changes went live.
Action: I built an evaluation harness with a golden set of questions and expected answers that scored outputs automatically on every change and failed the build below a threshold.
Result: Regressions were caught before release, and the team judged prompt changes on scores instead of opinions.

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.

Situation: Our RAG assistant often gave incomplete answers, even though the right information was in the documents.
Task: I had to find out whether the problem was retrieval or generation.
Action: I checked the retrieved chunks for failing questions and saw that the chunker cut sentences and tables in half, so no single chunk held the full answer. I changed to chunking on paragraph boundaries with some overlap and re-indexed.
Result: Retrieval returned complete passages and answer quality went up on our test questions.

Go earn this story: Fix the Chunking That's Wrecking RAG Retrieval →

Tell me about a time you made an AI feature more reliable.

Situation: Our LLM pipeline failed whenever the provider returned a rate limit error or timed out, and users saw raw errors.
Task: I had to keep the feature working through normal API failures.
Action: I added request timeouts, retries with exponential backoff and jitter for 429 and 5xx errors only, and a clear fallback message when all retries failed.
Result: Short provider problems no longer reached users, and the error rate of the feature dropped.

Go earn this story: Harden an LLM Pipeline Against API Failures →

Tell me about a time you built an LLM feature that uses tools.

Situation: Users asked the assistant questions that needed live data, such as order status, which the model could not know.
Task: I needed the model to call our own functions and use the real results.
Action: I defined the tools with JSON schemas, let the model choose a tool, validated its arguments, ran the function in our code, and sent the result back to the model for the final answer.
Result: The assistant answered with real data instead of guessing, and invalid tool calls were rejected safely.

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

AI/ML projectsAI/ML roadmapResume projectsCareer guide

Do real production work, free. Live cloud workspaces in your browser - every project you complete lands on your portfolio.

Get started - free
Get started - free