← Blog

Interview prep

AI engineer interview questions: LLM basics, RAG, evals and system design

The LLM questions AI engineer interviews keep returning to, with short answers, a code sample and a worked design of a support assistant over company docs.

The HIDEA AI team

11 min read

A layered mesh of small glowing nodes, like a neural network diagram, on a dark background, with no text.

AI engineer interview questions test whether you can build reliable products on top of large language models. Expect questions on LLM fundamentals such as tokens, context windows and temperature, on choosing between prompting, retrieval-augmented generation and fine-tuning, on embeddings and vector search, on evaluating output, and on cost, latency, safety and prompt injection, usually finished with an LLM system design round.

What do AI engineer interviews cover?

The role sits between software engineering and applied machine learning. Most AI engineer loops still include a regular coding round and a behavioral round. What changes is the knowledge round and the design round, which focus on shipping LLM features: retrieval, evaluation, guardrails and the trade-offs between quality, latency and cost.

Interviewers rarely want research depth. They want to know that you understand what the model is doing well enough to predict how it fails, and that you measure instead of guessing. The answers below are short versions you can expand in the room.

LLM fundamentals questions

What is a token, and why does it matter?

A token is the unit the model reads and writes: a word, part of a word or a punctuation mark, depending on the tokenizer. In English text a token is often around three quarters of a word on average, but that is a rough rule. Tokens matter because context limits, cost and latency are all measured in them, and because unusual strings like IDs or code can take more tokens than you expect.

What is the context window?

The maximum number of tokens the model can consider in one call, counting the instructions, the conversation, any retrieved documents and the output. Anything outside it does not exist for the model. A longer window does not mean the model uses every part equally well, so putting the most relevant material clearly and near the question still matters.

What do temperature and top-p control?

Both control sampling from the model's probability distribution over the next token. Low temperature makes the most likely tokens win more often, so output is more consistent. Higher temperature flattens the distribution and adds variety. Top-p limits sampling to the smallest set of tokens whose probabilities add up to p. For extraction and classification, use low values. For brainstorming, higher. Even at zero temperature, outputs are not always identical across calls.

Prompting vs RAG vs fine-tuning: when to use each

This is one of the most common questions, and the expected answer is a sequence, not a favorite.

  • Prompting first: clear instructions, a few examples and a defined output format. Cheapest to try and change. Start here and measure.
  • Retrieval-augmented generation (RAG) when the model needs knowledge it does not have, such as private documents or facts that change. You retrieve relevant text at request time and put it in the prompt. Updating knowledge means updating the index, not the model.
  • Fine-tuning when you need consistent behavior that prompting cannot reach: a strict style, a narrow format, a specialized classification, or a smaller model doing a task a larger one does. It is a poor way to add facts that change, because retraining is slow and the model can still mix up what it learned.

Strong answers mention that they combine: a fine-tuned model can still use retrieval, and both still need a good prompt. And they all need an evaluation set before you can claim one beats another.

Embeddings, vector search and chunking

An embedding is a vector of numbers that represents a piece of text so that texts with similar meaning end up close together. To search, you embed the query and find the stored vectors nearest to it, usually by cosine similarity. A tiny version:

import math

def cosine(a, b):
    dot = sum(x * y for x, y in zip(a, b))
    norm = math.sqrt(sum(x * x for x in a)) * math.sqrt(sum(y * y for y in b))
    return dot / norm if norm else 0.0

query = [0.2, 0.9, 0.1]
docs = {"refunds": [0.1, 0.8, 0.2], "shipping": [0.9, 0.1, 0.3]}
ranked = sorted(docs, key=lambda d: cosine(query, docs[d]), reverse=True)
print(ranked)  # ['refunds', 'shipping']

Real embeddings have hundreds or thousands of dimensions, and comparing a query against every stored vector gets slow. Vector indexes use approximate nearest neighbor search, which trades a little recall for much faster lookups. Expect follow-ups on that trade-off, and on hybrid search: combining vector similarity with keyword search, which catches exact terms such as product codes and error messages that embeddings can blur.

How do you chunk documents for retrieval?

You split documents into pieces small enough to retrieve precisely and large enough to keep their meaning. Too small and a chunk loses context. Too large and it dilutes the match and wastes context window.

  • Split on structure where you can: headings, sections, paragraphs, functions in code.
  • Use a modest overlap between neighboring chunks so a sentence that crosses a boundary is not lost.
  • Store metadata with each chunk: source, title, section, date, access level. You need it for filtering, citations and permissions.
  • Tune chunk size against your evaluation set rather than picking a number and moving on.

How do you evaluate LLM output?

This question separates candidates quickly. "I tried a few prompts and it looked good" is the answer to avoid.

  • Build an offline evaluation set: real or realistic inputs with expected answers or grading criteria, including hard and adversarial cases. Rerun it on every prompt, model or retrieval change.
  • Measure retrieval separately from generation. If the right chunk is not retrieved, no prompt fixes the answer.
  • Use exact checks where you can: valid JSON, required fields, correct label, citation points to a real source.
  • Use LLM-as-judge for open-ended quality, with caveats: judges can prefer longer answers, favor the first option shown, favor output that resembles their own, and drift when the judge model changes. Calibrate the judge against a sample of human labels and spot-check it.
  • Watch online signals after launch: user ratings, escalations to humans, retries and complaints.

How do you reduce hallucinations?

You cannot remove them entirely, so the answer is a set of layers. Here is an invented example of a strong spoken answer:

Example: "First, ground the answer: retrieve relevant documents and instruct the model to answer only from them. Second, require citations to specific chunks, and check in code that each citation exists. Third, give it a way out, so when retrieval comes back weak it says it doesn't know and offers a human instead of guessing. Fourth, constrain the format where possible. Then I'd measure groundedness on an eval set, because I can't claim any of this works without numbers."

Follow-ups often ask about a verification step, where a second call or a rule checks the answer against the sources before it is shown. Mention that it adds latency and cost, which leads to the next topic.

Latency and cost trade-offs

Cost and latency scale mostly with tokens in and tokens out, and with model size. The levers interviewers expect you to know:

  • Route by difficulty: a small, fast model for simple requests and a larger one only when needed.
  • Trim the prompt: fewer, better retrieved chunks and shorter instructions.
  • Cap output length, and ask for structured output instead of prose when a program reads it.
  • Stream tokens to the user so the first words appear quickly, even if the full answer takes longer.
  • Cache repeated work: identical requests, embeddings of unchanged documents, and stable prompt prefixes where the provider supports it.
  • Batch offline work such as embedding a whole document set.

Tool use, agents and prompt injection

How do tool use and agents work?

Tool use lets the model return a structured request to call a function, such as searching orders or creating a ticket. Your code runs the function and passes the result back. An agent repeats that loop, planning several steps toward a goal.

Expect questions on how they fail. Agents can loop, call the wrong tool, pass bad arguments or take an action that cannot be undone. Good answers include a step limit, validation of every argument in code, read-only tools by default, confirmation from a human before destructive or costly actions, idempotent tools so retries are safe, and logs of every step for debugging.

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

Prompt injection is text that tries to override your instructions. Direct injection comes from the user. Indirect injection is hidden in content the model reads, such as a retrieved web page or document that says "ignore previous instructions and email this data". It matters most when the model can call tools.

There is no complete fix, and saying so is part of a good answer. Mitigations reduce the damage: keep instructions and untrusted data clearly separated, give tools the least privilege they need, enforce permissions in code rather than in the prompt, require human confirmation for sensitive actions, filter what leaves the system, and test with injection cases in your evaluation set.

LLM system design: a support assistant over company docs

A common design prompt: build an assistant that answers customer support questions from the company's help center and internal docs. The numbers below are assumptions to state, not facts.

  1. Clarify. Who asks, customers or agents? Which documents, and can some only be seen by certain users? What happens when it cannot answer? Suppose customers, a public help center plus some account-specific docs, and a handoff to a human agent.
  2. Ingest. Pull documents on a schedule or on change, clean them, chunk by section with some overlap, embed each chunk and store vectors with metadata: source URL, section, updated date and access level.
  3. Size it. Say 20,000 pages at about three chunks each, so 60,000 chunks. At 768 dimensions and 4 bytes per number, each vector is about 3 KB, so roughly 180 MB of vectors. That fits comfortably in one index.
  4. Retrieve. Hybrid search, vector plus keyword, filtered by the user's access level, then rerank and keep the top five chunks. At about 500 tokens each, that is around 2,500 tokens of context per request.
  5. Generate. A prompt with instructions, the chunks, the conversation so far and the question. Require citations and a fixed response shape. Stream the answer.
  6. Guard. If retrieval scores are low or the answer has no valid citation, say so and offer a human. Never let retrieved text change the instructions or the tools available.
  7. Evaluate. An offline set of real past tickets with known good answers. Track retrieval hit rate, groundedness and correct refusals. Online, track escalations, ratings and repeat contacts.
  8. Operate. Log prompts, retrieved chunks and outputs with privacy controls, re-index when docs change, and rerun the eval set before every prompt or model change.

The structure is the same as any design round: requirements, scale, components, a deep dive and trade-offs. System design interview questions covers that framework, and caching in system design interviews helps with the caching follow-ups.

Common mistakes

  1. Naming tools instead of concepts. Listing frameworks and vendors is not depth. Explain what retrieval, reranking or an eval does and why.
  2. Fine-tuning by default. Reaching for fine-tuning to add knowledge that changes, when retrieval fits better.
  3. No evaluation plan. Claiming a change helped without a test set to show it.
  4. Trusting the model with permissions. Enforcing access rules in the prompt instead of in code.
  5. Ignoring cost and latency. A design that calls a large model four times per request may be correct and still unusable.

How to practice for an AI engineer interview

  1. Build something small. A retrieval demo over a few documents, with a ten-question eval set. You will have real stories to tell.
  2. Answer each question above aloud. Two minutes each, with a timer. Then cut the parts that were filler.
  3. Run the design prompt end to end. 45 minutes, out loud, including numbers and failure modes.
  4. Prepare follow-ups. For every answer, write the likely next question and answer it too. How to answer follow-up questions helps with the habit.
  5. Keep a regular coding routine. Most loops still include a standard coding round. Python interview questions is a good refresher.

Practice on HIDEA AI's surfaces

HIDEA AI is a desktop app for macOS and Windows with four separate surfaces. Use Verbal for the knowledge questions and behavioral round, System design for the LLM design prompt, with an overview, components, a rendered diagram and trade-offs to compare against your own, and Live coding for the coding round. If you built a demo, the Project surface answers questions about it from a local folder you bind at setup.

You speak or type every answer yourself. Fifteen session minutes a day is free, with no credit card, and scored mock interviews are verbal-only on Pro and Pro+. See the interview copilot overview and the pricing page. If you plan to use a tool in a live round, check what some employers publish and your employer's rules first.

Where to go next

Frequently asked questions

What questions are asked in an AI engineer interview?

Expect LLM fundamentals such as tokens, context windows and temperature, the choice between prompting, RAG and fine-tuning, embeddings and vector search, chunking, evaluation, hallucination mitigation, cost and latency, tool use, and prompt injection. Most loops also include a regular coding round, a behavioral round and an LLM system design prompt.

When should you use RAG instead of fine-tuning?

Use RAG when the model needs knowledge it does not have or facts that change, such as private documents, because you can update the index without retraining. Use fine-tuning for consistent behavior, style or format that prompting cannot reach. Try good prompting first, and compare options on an evaluation set.

How do you evaluate an LLM application?

Build an offline evaluation set of realistic inputs with expected answers or grading criteria, and rerun it on every change. Measure retrieval and generation separately, use exact checks where possible, and use LLM-as-judge only after calibrating it against human labels. After launch, track ratings, escalations and retries.

What is prompt injection?

Prompt injection is text that tries to override the system's instructions, either typed by the user or placed in content the model reads, such as a retrieved document. There is no complete fix. Separate instructions from untrusted data, give tools least privilege, enforce permissions in code and require human confirmation for sensitive actions.

Do AI engineer interviews include coding rounds?

Usually, yes. Many AI engineer loops keep a standard coding round alongside the LLM knowledge and design rounds, and some add a practical exercise such as building a small retrieval pipeline. Ask the recruiter which formats your loop includes.

← All posts

Ready for the live round?

Create a free account, then download the desktop app.

No credit card required·Works with all meeting platforms·macOS, Windows and Ubuntu