AI Engineering Interview Questions

Learn the LLM fundamentals AI engineering interviews cover: tokens and context windows, prompting, embeddings and vector search, RAG, tool use and agents, MCP, evals, and prompt injection.

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?

Your chatbot forgets the user's name a few messages later. Why, and how do you fix it?

When an LLM decides to call a tool, who actually runs the function?

What is prompt injection, and how do you defend against it?

Ready to test yourself?

Apply what you've read with a 10-question quiz on AI.

Start AI quiz