AI Engineering Interview Questions: Evaluation, Safety and Guardrails

Reviewed by Mark Dickie · Last updated

5 questions on this page you can answer and see marked on the spot. Go to the first one

AI engineering is the work of building software on top of foundation models such as large language models, then making that software reliable enough to ship. Interviewers who focus on evaluation, safety and guardrails want to see whether you can measure output quality before users do, catch harmful or ungrounded answers, and keep a model inside its rules when a prompt tries to break them. Be ready to design a test set for a task, choose metrics that match it, and say where a guardrail sits in the request path.

Which evaluation methods do AI engineering interviews test?

MethodWhat to explainFailure it catches
Golden-set regression evalsA versioned set of questions with reference answers, rerun on every prompt or model changeA prompt edit that quietly lowers accuracy on older cases
LLM-as-judge scoringA grader prompt with a rubric, checked against a sample of human labelsA judge that rewards longer answers or favours its own model family
Retrieval metrics (recall@k, MRR)Whether the right chunk reached the model before generation was scoredA well-written answer built on the wrong context
Pairwise human reviewSide-by-side preference labels plus inter-rater agreementScores that look fine while users prefer the previous version

How do guardrails work in a production LLM request?

  1. Input screening: check the user message for prompt injection and personal data before it reaches the model.
  2. Constrained generation: system prompt rules, an allowed tool list, and a structured output schema.
  3. Output checks: a classifier or pattern match for PII, unsafe content, or claims with no support in the retrieved sources.
  4. Fallback path: refuse, return a fixed message, or hand the case to a human when a check fails.
  5. Logging: record each blocked request and the rule that fired, so thresholds can be tuned from real traffic.

Key facts

  • Tarmac has 30 AI Engineering interview questions on this topic, 10 of them on this page, at difficulty 2–5 of 5.
  • Tarmac tracked 2,397 job postings asking for AI Engineering in November 2026.
  • Roles asking for AI Engineering advertise a median base salary of £80,000, across 622 job postings as of November 2026.
  • Tarmac last reviewed these AI Engineering interview questions on 2 November 2026.

At a glance

Questions10 shown · 30 in the bank
Difficulty2–5 of 5
FormatsTrue / false, Fill in the blank, Ordering, Multiple answer, Find the bug, Short answer, Flashcard, Multiple choice, Design exercise

What you'll review

  1. guardrails
  2. prompt injection
  3. agent loops

Practice questions

Try one before you open the answer. Pick an option and press Check; it's marked on the spot.

A prompt injection attack occurs when a malicious user embeds instructions inside their input (e.g., inside a document the LLM is asked to summarize) that override or hijack the system prompt's intended behavior.#

Options

Show answer

True. Prompt injection is the attack where malicious instructions are embedded in user-supplied content (e.g., a document the model is asked to summarize), causing the model to treat those instructions as authoritative and override the legitimate system prompt. It is a key concern in LLM safety because models do not inherently distinguish between trusted instructions and data they are processing.

Why:

This statement is true. Prompt injection is precisely the attack class where adversarial content—often hidden in user-supplied data such as documents, web pages, or tool outputs—contains instructions that the model interprets as authoritative, potentially causing it to ignore safety rules, leak information, or take unintended actions.

Complete the following sentence about LLM evaluation safety frameworks:#

Show answer

Complete the following sentence about LLM evaluation safety frameworks:

"In LLM evaluation, using one LLM to automatically score another model's outputs for quality or safety is called LLM-as-a-judge, while a red-team dataset is a curated collection of prompts crafted to provoke harmful or policy-violating responses, used to test whether a model's guardrails can be bypassed."

Why:

The first blank is the LLM-as-a-judge pattern: one LLM scores another model's outputs for criteria such as helpfulness, harmlessness, or factual accuracy, serving as a scalable alternative to human review. Several names are standard for this technique (LLM judge, judge model, LLM evaluator, autorater, model-graded evaluation), so all of them are accepted. The second blank is a dataset of prompts deliberately written to elicit harmful or policy-violating output so that guardrail weaknesses can be found. Its common names (red-team, adversarial, jailbreak, attack) all describe this same kind of dataset, so each of them is accepted for the blank.

Arrange the following components of a defense-in-depth LLM guardrail pipeline into the correct order of execution, from first to last.#

Put these in order

Show answer

The correct order is: (1) Input sanitization/normalization, (2) Prompt-injection/jailbreak detection, (3) LLM generation, (4) Response policy evaluation, (5) Deliver to user. Sanitizing first ensures the injection detector sees clean text; detecting attacks before generation prevents the LLM from ever processing a malicious prompt; output evaluation catches policy violations in the model's reply before it reaches the user.

Why:

The correct order of a defense-in-depth LLM guardrail pipeline is: (1) sanitize/normalize the raw input, (2) run the input through a prompt-injection / jailbreak detector, (3) pass the clean prompt to the LLM to generate a response, (4) evaluate the response for policy violations (toxicity, PII, off-topic content), and finally (5) deliver the approved response to the user. Placing the content-policy check before generation makes no sense because there is no model output yet; placing injection detection after generation leaves the model exposed to the attack.

You are building an automated evaluation pipeline that uses GPT-4 as an LLM-as-a-judge to score candidate model responses. Which of the following are systematic judge biases that have been documented in published LLM-as-a-judge studies (for example, Zheng et al. 2023 on MT-Bench)?#

Options

Pick every one that applies.

Show answer

Position bias, verbosity bias, and self-enhancement bias are all documented systematic biases of LLM judges such as GPT-4. Position bias means verdicts can shift with presentation order, verbosity bias favors longer responses regardless of quality, and self-enhancement bias favors outputs from the judge's own model family. A reverse-order rule that always favors the second response is not a documented finding.

Why:

Three biases are documented in published LLM-as-a-judge work. Zheng et al. (2023) report position bias, where the verdict depends on presentation order; the direction varies by judge (GPT-4 mostly favored the first position, and Claude-v1 showed a strong first-position preference), so the bias is framed as order sensitivity rather than a fixed direction. They also report verbosity bias, where longer answers are favored regardless of correctness, and self-enhancement bias, where a model rates outputs from its own family higher. The claim that the judge always favors the second-presented response is clearly wrong, since the documented finding is a first-position preference for GPT-4 and Claude-v1, and it is not a universal rule for any judge.

The following Python guardrail code uses the OpenAI Moderation API (openai SDK v1+) to block policy-violating user messages before they reach an LLM. It contains one bug that causes a runtime error on every call. Identify the buggy line.#

import openai

def moderate(user_message: str) -> str | None:
    client = openai.OpenAI()
    results = client.moderations.create(input=user_message)
    if results[0]['flagged']:
        return None  # block the message
    return user_message

def chat(user_message: str) -> str:
    client = openai.OpenAI()
    safe_message = moderate(user_message)
    if safe_message is None:
        return "Your message was blocked by the content policy."
    response = client.chat.completions.create(
        model="gpt-4o",
        messages=[{"role": "user", "content": safe_message}]
    )
    return response.choices[0].message.content
Show answer

The bug is on line 6.

Why:

Line 6 indexes the object returned by client.moderations.create with results[0]. In the v1+ SDK that return value is a ModerationCreateResponse Pydantic model, not a list or dict, so it does not support subscripting. Every call to moderate therefore raises TypeError ('ModerationCreateResponse' object is not subscriptable) before any flag check runs. The correct access is results.results[0].flagged. The other lines are correct: line 5 uses the v1 client call, and chat handles a None return from moderate by returning a refusal, so the None check is present. Line 14 only runs when a message is blocked, so it is not a bug.

A production LLM application uses a RAG pipeline. Security review flags two failure modes:#

Show answer

An input guardrail runs before the LLM call and only sees the user's query, so it cannot observe PII that the model later copies from retrieved documents into its response. That PII only exists after generation, so the violation happens after the LLM call. The guardrail that addresses it is an output guardrail placed after the LLM call: it scans the generated response for PII (using regex, named-entity recognition, or a classifier) before the response is returned to the user. For failure mode 1, the input guardrail sits before the LLM call and screens the user query for prompt-injection patterns. Together these two layers form the request/response boundary, and each covers a failure mode the other cannot see.

Why:

The question is scoped to guardrails at the request and response boundary of the LLM call, so the answer is judged on that scope. An input guardrail runs before the LLM call and inspects only the user's query. PII in failure mode 2 comes from retrieved documents, which enter the prompt inside the pipeline and appear only in the model's output, so an input guardrail never sees it. The output guardrail runs after the LLM call and scans the generated response for PII before delivery, which is where that leak can be detected. The input guardrail is still needed for failure mode 1, because prompt injection in the user query must be screened before it reaches the model. The answer is therefore an input guardrail before the LLM call for injection and an output guardrail after the LLM call for PII.

What layers make up a realistic defense-in-depth strategy against prompt injection, since no single fix closes it?#

Show answer

No single technique is sufficient, so combine several: least-privilege tool scopes (give the model only the narrow permissions a task needs, e.g. a scoped API key, not admin credentials); privilege separation / dual-LLM patterns (isolate the component that reads untrusted content from the component that can take action); sandboxing tool execution (run code/shell tools in an isolated, resource-limited environment with no access to secrets); input filtering (heuristics or classifiers that flag likely-injected content before it reaches the model); output filtering (scan the model's response and tool calls before they're executed or rendered, e.g. block auto-fetched images or unexpected destinations); human-in-the-loop approval for high-impact or irreversible actions; and delimiting/labeling untrusted content so it's at least marked as data. Each layer is bypassable alone; together they bound the damage even when one layer fails.

Why:

Treat every individual defense as reducing probability, not proving safety — the strategy is redundancy across independent layers so that one bypassed control (a fooled classifier, an overridden system-prompt rule) doesn't translate directly into a successful attack, because a later layer (a scoped credential, a sandbox boundary, a human check) still has to be defeated too.

Anthropic's Constitutional AI (CAI) framework trains a model to be helpful, harmless, and honest without relying on human-labelled preference comparisons for harmlessness. Which sequence of steps most accurately describes the CAI training pipeline?#

Options

Show answer

The correct sequence is: the model generates a response, then critiques and revises it according to the constitutional principles (producing SL-CAI supervised fine-tuning data), then uses the model itself to generate preference labels from those revisions, and finally runs RLHF/RLAIF on those AI-generated preference pairs to update weights (RL-CAI). No human preference labels are needed for the harmlessness component; the preference signal is entirely AI-generated from the constitution.

Why:

Constitutional AI (CAI) uses a two-phase process: (1) a 'critique-revision' loop where the model critiques its own response according to a set of principles (the 'constitution') and rewrites it, and (2) RLHF/RLAIF using preference data generated from those revised outputs. The key distinction is that the preference labels in phase 2 are produced by the AI itself using the constitution, not by human labellers — hence 'AI feedback' (RLAIF). This makes it fundamentally different from standard RLHF (human-labelled preferences) and from simple output filtering (which doesn't update weights). The constitution is not a runtime prompt filter injected per-query; it is a training-time mechanism.

You are designing a LLM-as-judge evaluation pipeline to score free-form RAG answers on a 1–5 helpfulness scale. Which of the following statements about LLM-as-judge reliability are well-evidenced findings that your pipeline design must account for? Select all that apply.#

Options

Pick every one that applies.

Show answer

Verbosity bias, order sensitivity, and prompt sensitivity are the well-documented LLM-as-judge reliability effects a pipeline must handle. Judges often reward longer answers, their pairwise verdicts can flip when candidate order is swapped, and scores shift with judging-prompt or rubric wording. Position independence and claims that a different-provider judge removes bias are not supported by the evidence.

Why:

The three keyed findings are the ones with consistent empirical support across studies. Verbosity bias: judges frequently favour longer, more elaborate answers even when a shorter one is more accurate, so the pipeline should control for length. Order sensitivity: pairwise verdicts can change when the two candidates are swapped, so the design should evaluate both orderings and aggregate. Prompt sensitivity: scores move when the judging prompt or rubric wording changes, so the rubric must be fixed, versioned and validated. The statement claiming position independence is false because order effects are documented, and the statement claiming a different-provider judge fully eliminates bias is false because systematic biases persist across models and calibration is still needed.

Design the agent loop behind a support assistant that answers billing questions. It can read invoices, read the customer's plan, and issue refunds up to a limit. Runs take anywhere from 2 to 40 iterations. Cover how the loop terminates, what happens when a tool fails, how context is kept under the window, how refunds are controlled, and how you would debug a bad run a week later. State your assumptions.#

Show answer

Assume a few thousand runs a day, a refund ceiling of $200, and 30-day trace retention. Most tickets follow a handful of shapes, so I would route: a classifier sends the common ones down fixed workflows and only the tail reaches the agent, which cuts cost and shrinks the surface where things can go wrong.

The loop terminates on four conditions, not one: the model returns a final answer that passes a goal check; a cumulative token budget for the run is exhausted; a step cap fires as a backstop; or a repeated-call detector sees the same (tool, arguments) hash twice with nothing new in context. Budget is the primary control because steps are a poor proxy for cost — each iteration re-sends the transcript, so late steps cost far more than early ones. On any stop without an answer the agent hands the ticket to a human with its partial findings attached, rather than replying with something it is not sure of.

Tool failures go back into the context as tool results flagged as errors, so the model can adapt — try a different lookup, or tell the user. Retry policy is per-tool, not global: reads retry with exponential backoff, and the refund call never retries blindly, because a 5xx there is ambiguous rather than failed. Refunds carry an idempotency key so a duplicate collapses server-side.

For a 40-iteration run I pin the system prompt, tool schemas and goal, summarise older turns into a running recap once the transcript passes a threshold, clear stale tool results while keeping the calls that produced them, and keep large invoice payloads in storage behind a reference the agent re-reads on demand.

Refunds are gated in code. The loop intercepts the call before execution, verifies the amount against the invoice server-side, and requires human approval above a threshold — the model's authority is whatever the loop grants it, and the system prompt is a hint, not a control. Invoice text is untrusted: it reaches the context as data, and instructions inside it have no privilege, which is exactly why enforcement cannot live in the prompt.

Every run writes a trace keyed by run id and ticket id, one span per iteration, capturing the rendered prompt, the tool calls and arguments, results, token counts, and the stop reason. A week later I can open the ticket, find the run, and see which iteration went wrong and what the model was looking at when it did.

The main tradeoff is autonomy against friction: a lower approval threshold means fewer bad refunds and more human load. I would start conservative, measure the approval queue, and raise the threshold only against evidence.

Why:

This exercise separates people who have run an agent in production from people who have read about them. The tells are consistent. A weak answer treats max_steps as termination, wraps every tool in one retry, plans to 'use a bigger context window', and puts the refund limit in the system prompt. A strong answer knows that a step cap does not bound cost, that retry policy is a property of the tool rather than of the loop, that trimming has to pin the instructions it must never drop, and above all that a prompt instruction is not an authorization boundary — the loop executes tools, so the loop is the only place a refund limit can be enforced. The prompt-injection probe is the sharpest discriminator: any design where the model's instructions are the sole control fails it, because the invoice is attacker-influenced text arriving in the same context. The debuggability criterion is what makes the whole thing operable — without per-iteration traces tied to a run id, nobody can answer 'why did it do that' a week later, and every incident becomes a guess.

Related interview questions

Job market

See ai-engineering salaries and hiring demand from live job postings.

The other 20 questions

This page shows 10 and marks what you pick. That's as far as a page can go. A free account opens the other 20 and keeps every answer. What you miss comes back until it's right: after a day, then at longer gaps.

Start with this topic

Free · the whole bank · 100 answers per 30 days, each marked with written feedback

Interview booked? Practise the job ad instead

What moved, monthly

One email a month when the bulletin comes out: what moved in the markets we track, and the new question topics we published. Confirm your address to join. Unsubscribe any time.