QA Interview Hub · Knowledge base · Quizzes · Українська

All topics

AI interview questions and answers for QA

19 AI questions that come up in QA interviews, with short answers. Open the topic in the knowledge base for a deeper explanation.

What is an LLM and how does it generate an answer?

An LLM (large language model) is a neural network trained on large amounts of text to predict the next token. The prompt is split into tokens, the model computes probabilities for the next token, picks one (depending on parameters like temperature), appends it to the text and repeats until the answer is finished. The model works within a context window, a limited number of tokens. It does not "know facts" but reproduces patterns, so it can invent plausible but wrong answers (hallucinations) and does not guarantee the same result every time. That is why testing an LLM needs eval sets and checks by meaning rather than exact text match.

Read the topic

Explain what a token and a context window are, and why the model is "stateless".

A token is the unit of text the model reads and writes (a piece of a word or a mark); both the cost and whether the text fits depend on the token count. The context window is the maximum number of tokens per request: system prompt, history, documents, tool definitions and results, and the answer itself. The model does not store the conversation between requests, so the history is fed into the context again every time (by the client or by server-side state in the app or API) and billed as input tokens. For QA this means: long dialogues get more expensive and hit the limit, and facts from the middle of a long context may be lost.

Read the topic

Which generation parameters do you know and why does temperature 0 not make a test deterministic?

temperature is the randomness of token choice, top_p cuts by cumulative probability, max_tokens limits length, stop is stop sequences, seed is not supported by everyone. Even at 0 the output may differ: the server batch size changes with load, the vendor updates its infrastructure, and an alias may move to a new model. So a test checks properties (structure, facts, tool calls) and measures the pass rate over several runs, and the model version is pinned.

Read the topic

What are few-shot and structured output and how do you test them?

Few-shot is a few "input → output" examples in the prompt that pin down format and style. Structured output is a requirement to answer in a schema format (JSON). Tests: validating the answer against the schema at the system boundary, negative cases (truncated JSON, extra fields, wrong types), error handling with retry or a controlled refusal, and regression on the eval set on every prompt change.

Read the topic

Describe the RAG pipeline and where it breaks.

Documents → chunking → embeddings → vector DB; for a query the top-k nearest fragments are taken, added to the prompt and the model answers (ideally with sources). It breaks at retrieval (the needed fragment is missing or outdated), when the model ignores the context, when the answer is not based on the sources, and on access rights. Evaluate separately: recall@k / precision@k for search and faithfulness for the answer, and add questions with no answer in the knowledge base.

Read the topic

What is tool calling and who executes the tool?

Tools are described to the model (name, description, parameter schema). It returns an intent to call a tool with arguments, but your tool is executed by the application code (the vendor's built-in server tools run on its platform), and the result goes back into the context. So argument validation, permissions, limits and confirmation of dangerous actions are on the code side. Test separately: the tool itself (ordinary tests), the model's tool selection and the whole trajectory.

Read the topic

What are an agent and MCP, and what should be tested?

An agent is a loop "model decides → tool runs → result into context → next step", with side effects and its own choice of sequence. MCP is an open protocol for connecting external tools, resources and prompts. Test: the tool contract and schemas, permissions, errors and timeouts, step and budget limits, loops, idempotency of side effects and behaviour when the MCP server is unavailable.

Read the topic

Why are LLMs not tested with ordinary asserts and what is done instead?

Because of non-determinism, no single reference answer and hidden dependencies (model, prompt, data). Instead of string equality: deterministic property checks (schema, required fields, the right tool and arguments, DB state), semantic checks and LLM-as-judge for free text, and statistics — the success rate over a set and several runs. The pyramid stays: many fast tests with a mocked model, fewer evals, fewest e2e.

Read the topic

How do you build an eval set and use LLM-as-judge?

Golden dataset: real (anonymised) requests, edge cases, negative scenarios, every found bug as a case; for each, expected behaviour and category tags. The judge: a clear narrow rubric, a short justification before the score, a different model with a pinned version (temperature 0 only where the model accepts it), calibration on human labels. The result is a pass rate per category, cost and latency, compared with a baseline; critical categories have their own thresholds.

Read the topic

How would you test an LLM agent that performs actions in a system?

Three levels: the tool (ordinary tests of contract, errors, idempotency), the model's decision (the right tool and arguments, no extra ones) and the trajectory with the outcome (DB state, created entities, not just text). I mock the outside world for stability and keep separate sandbox runs. I check tool failures, multi-turn dialogues, step and budget limits, confirmation of dangerous actions and security (injections). Assertions are over the set of acceptable paths, not a single one.

Read the topic

What belongs in a quality gate and monitoring for LLM features?

CI: fast tests with a mocked model on every commit, an eval with the real model on PRs that change the prompt, model, tools or RAG and the full set nightly; the gate is a pass rate no lower than a threshold and no worse than the baseline, plus cost and latency limits. Production: traces (versions, tool calls, tokens, cost), sampled judge evaluation, user feedback, canary release, alerts on spikes in cost, refusals and tool errors; every incident becomes a case in the set.

Read the topic

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

It is text in the input data (direct from the user or indirect in a document, email, page) that hijacks the model's instructions. The model cannot reliably tell data from commands, so defence is layered: least-privilege tools, human confirmation for dangerous actions, input and output filtering, isolation of untrusted content, limits, audit. Test: a set of adversarial prompts and poisoned documents; the metric is the share of successful attacks and the absence of dangerous side effects.

Read the topic

How do you test hallucinations, bias and privacy?

Hallucinations: groundedness against the provided context, reference facts, questions with no answer (we expect "I don't know"), source checks. Bias: paired requests changing only a sensitive attribute and a comparison of decisions and tone. Privacy: no PII in other users' answers and logs, masking, retention policy. Over-refusal is measured separately, because excessive caution is a defect too.

Read the topic

Why must model output be treated as untrusted input?

A model can be made to generate anything (via injection, RAG data or an error). If the output reaches HTML, SQL, a shell or an API call, XSS, injections and dangerous actions appear. So escaping, parameterisation, schema validation and allow-lists are applied. Test: answers with markup, scripts and control characters.

Read the topic

How do you state acceptance criteria for an AI feature with non-deterministic output?

Not as exact text but as checkable properties: required facts, forbidden content (inventions, other people’s data), form (length, language, valid JSON) and a threshold as a share of passed cases. They are measured on a golden set with typical and edge cases and unanswerable questions. For answers from documents, check groundedness: the quote is in the source and supports the claim. Production incidents feed the set.

Read the topic

What do you do when the model or prompt changes and what are the limits of LLM-as-judge?

Run the golden set on the old and the new configuration, compare per category against a threshold and the baseline, pin the model version rather than an alias. An LLM judge saves time but has biases (length, position, its own style) and is unstable, so it is calibrated on human scores and critical cases are reviewed by a person. Where a deterministic check is enough, use it. Release through an A/B and a flag with guardrail metrics.

Read the topic

What do you check in structured output and in user content?

Output: JSON schema validation on every response (types, enum, required fields), truncation at the length limit, a refusal instead of JSON, semantic correctness of values, behaviour on invalid output. User content: poisoned documents with embedded instructions, output escaping in HTML, PII in logs, traces and analytics and the data sent to the provider.

Read the topic

How do you test streaming, latency, limits and provider failure?

Streaming: a partial answer without broken markup, cancelling stops the stream and token spending, a dropped connection is visible to the user. Latency: time to first token and p95, timeouts, input and output limits and a token budget. Limits: 429 and 5xx get a retry with exponential backoff, jitter and Retry-After, with bounded attempts. Degradation: fault injection on a provider stub, a fallback path, a kill switch via a flag.

Read the topic

How do you watch an AI feature in production and what do you automate versus review by hand?

Monitoring: model and prompt versions, tokens, latency, refusals, invalid JSON, cost, alerts on jumps; a sample of live answers is scored by a judge or a person. 👍/👎 feedback is a signal for finding problems, not a correctness metric; negatives become set cases. Automate the schema, forbidden patterns, language, provider errors and a regression eval in CI; review by hand a sample of answers, tone, new classes of requests and judge calibration.

Read the topic

Practice AI with flashcards