AI Engineering Interview Questions
AI engineering interviews focus less on training models from scratch and more on building reliable applications on top of large language models. Interviewers want to know whether you understand how a model actually sees a request, how to give it the right context, and how to tell whether a change made things better or worse.
Most beginner questions come back to one fact: a model only knows what was in its training data and what is in the current request. Its knowledge stops at a cutoff, the API keeps no memory between calls, and anything outside the context window is invisible. Prompting, retrieval, tools and evals are all ways of working within that constraint.
Key concepts
Tokens, Context Windows & Temperature
Models read and write tokens, chunks of text produced by a tokenizer: common words are often one token, rare words split into several, and an English token averages about four characters. The context window is the most tokens a single request can hold, counting the system prompt, history, documents and the generated output. Temperature controls randomness: higher values let less likely tokens through so outputs vary more, lower values make them more focused and repeatable.
What a Model Knows
A model's knowledge ends at its training cutoff, so it can confidently describe an API that has since changed. Chat APIs are also stateless: the model sees only the current request, so chat apps resend the conversation history on every turn. Hallucination, fluent output that is not grounded in fact, has the same root: models generate plausible text rather than verified facts. Supplying the relevant documents and asking for citations reduces it.
Prompting
The system prompt sets the role, rules, output format and background for the whole conversation, and is sent with every request. Few-shot prompting adds a handful of worked input and output examples so the model infers the format you want. Asking the model to reason step by step before answering improves accuracy on multi-step problems, since it does a fixed amount of computation per token. Delimiters such as XML tags keep instructions, examples and input data clearly apart.
Embeddings & Vector Search
An embedding model turns text into a fixed-length list of numbers so that texts with similar meaning land close together. Cosine similarity compares two embeddings by the direction they point, ignoring their length. A vector database such as Pinecone, Qdrant or Postgres with pgvector indexes many embeddings for fast nearest-neighbour search. Vectors from different embedding models live in different spaces and cannot be compared, so switching models means re-embedding everything.
Retrieval-Augmented Generation (RAG)
RAG retrieves passages relevant to a query and adds them to the prompt so the model answers from that context; the model's weights never change. Documents are split into chunks of a few hundred tokens, often overlapping slightly so an idea cut at a boundary still appears whole, and top-k sets how many of the best matches go into the prompt. The system is only as fresh as its index: an edited page must be re-embedded or the old text keeps being quoted.
Tool Use & Agents
When a model uses a custom tool, it only returns a structured request naming the tool and its arguments; your application runs the function and sends the result back. An agent is a model using tools in a loop, deciding its next step from each result, so it needs hard stopping conditions such as iteration caps, spending limits and timeouts. The Model Context Protocol (MCP) standardises how AI applications connect to servers that expose tools, resources and prompts, so one integration works across many apps.
Evals & Observability
LLM outputs vary, and a fix for one case can quietly break another. An eval set of representative inputs, scored the same way on every change, turns "seems better" into a measurement and catches regressions before users do. Tracing tools such as LangSmith or Langfuse record each step of a run, including prompts, outputs, tool calls, latency and cost, so failures can be debugged and real traces turned into new eval cases.
Security
Prompt injection is input, typed by a user or hidden in a retrieved document, that smuggles in instructions which override your application's own. It works because models cannot reliably tell instructions from data, and OWASP ranks it as the top risk for LLM applications. The system prompt is not a safe place for secrets either: users can often talk the model into repeating it. Keep credentials in your backend and let tools use them server-side.
Sample interview questions
What is retrieval-augmented generation (RAG), and when would you use it instead of fine-tuning?
Answer: RAG retrieves passages relevant to the user's query, usually from a vector index of chunked documents, and adds them to the prompt so the model answers from that context. Use it when the model needs facts that change or that it was never trained on, such as internal documentation: updating the index is cheap and answers can cite their sources. Fine-tuning suits changing behaviour, like tone, format or a narrow task skill, not adding facts that go stale.
Why it matters: RAG is the most common architecture in AI engineering interviews, and the split with fine-tuning shows whether you know what each technique actually changes.
Your chatbot forgets the user's name a few messages later. Why, and how do you fix it?
Answer: LLM chat APIs are stateless: the model sees only what is in the current request. If each request carries only the newest message, the earlier turns do not exist as far as the model is concerned. Send the conversation history with every request, or a summary of it once it grows long, keeping the total within the context window.
Why it matters: It tests whether you understand how a model actually sees a request, which underpins memory, context-window budgeting and cost.
When an LLM decides to call a tool, who actually runs the function?
Answer: Your application. For custom tools the model only returns a structured request naming the tool and its arguments. Your code validates and executes it, then sends the result back to the model in the next request, and the model continues from there. Repeating that loop until the task is done is what makes an agent.
Why it matters: Many candidates assume the model executes code itself. Knowing where execution happens is the basis for reasoning about agents, permissions and security.
What is prompt injection, and how do you defend against it?
Answer: Prompt injection is input, from a user or hidden in a document or web page the model reads, that contains instructions overriding the application's own. It works because models cannot reliably separate instructions from data. No single fix exists, so defences are layered: treat everything the model reads as untrusted, give tools only the permissions they need, require confirmation for sensitive actions, and keep secrets out of prompts.
Why it matters: OWASP ranks it as the top risk for LLM applications. Interviewers want to see you design with it in mind rather than bolt on a filter afterwards.
Ready to test yourself?
Apply what you've read with a 10-question quiz on AI.
Start AI quiz