AI and ML interview questions

715 questions across 87 topics, each with an answer that works, and 306 follow-ups for where an interviewer takes it next. Every question here is attached to the material that teaches its answer, so a question you cannot answer has somewhere obvious to go. Answers are shortened here and shown in full on each question’s own page, which is also what the search below matches.

Single questions are easy to memorise. The second and third question are where understanding shows, which is why the follow-up chains are here and worth more of your time than the openers.

Filtering by employer narrows to the topics that kind of company characteristically tests, which is a way to focus revision rather than a syllabus — a topic absent from a tier is not untested there. What each loop is actually made of.

715 of 715 questions

What is the difference between == and is?

== compares values. is compares whether two names point to the same object in memory. Use is only for None, True and False. Using it on numbers or strings seems to work for small…

PythonVariables, strings and numbers

What does s[::-1] do?

It reverses the string. The three parts of a slice are start, stop and step, so a step of -1 walks backwards through the whole thing.

PythonVariables, strings and numbers

How would you remove duplicates from a list?

list(set(items)) is the quickest way, but it loses the original order. If order matters, use list(dict.fromkeys(items)), because dictionaries keep insertion order in modern Python.

PythonLists, dictionaries and sets

What is wrong with def f(items=[])?

The default list is created once when the function is defined, not on each call, so every call shares the same list. Values accumulate across calls. Use None as the default and…

PythonLoops, conditions and functions

Why should you avoid a bare except?

It catches everything, including KeyboardInterrupt and SystemExit, so the program cannot be stopped normally. It also hides real bugs like typos, turning a crash you would have…

PythonErrors, files and modules

Why use with when opening a file?

It closes the file automatically when the block ends, even if an exception is raised inside it. Without it, a failure partway through can leave the file open.

PythonErrors, files and modules

Are Python type hints enforced at runtime?

No. Python ignores them while running. They exist for editors and type checkers, which is why data from an API still needs real validation with something like pydantic.

PythonType hints and pydantic

What does dict | None mean in a return type?

The function returns either a dictionary or None. A type checker will then warn if you use the result without checking for None first. Older syntax writes it as Optional[dict].

PythonType hints and pydantic

When does async not help?

When the work is CPU-bound. Async overlaps waiting, not computing, and there is still one thread. For heavy computation you need multiprocessing.

PythonAsync and concurrency

Can you call len() on a generator?

No. A generator does not know how many items it will produce and cannot look ahead. If you need a count, either convert it to a list or count as you iterate.

PythonGenerators and working with large data

Why is mocking heavily a problem?

Tests full of mocks assert that your code called your code, which stays true even after you break the behaviour. They also have to be rewritten on every refactor. Fake at the…

PythonTesting

Is 100% test coverage a good goal?

No. Coverage tells you which lines ran, not whether anything was verified. A suite at 90% that asserts almost nothing is worse than an honest 50%, because it creates confidence…

PythonTesting

How do you test code that calls an LLM?

Separate the deterministic parts and test those normally with a fake client returning fixed responses. The quality of the model's output is not a unit test; it needs an eval suite…

PythonTesting

Why use a virtual environment?

It isolates a project's dependencies. Without one, two projects needing different versions of the same library conflict, and installing globally can break system tools that rely…

PythonEnvironments, packaging and tooling

How do you handle secrets such as API keys?

Keep them in environment variables, loaded from a .env file that is gitignored, and read at runtime. Never commit them. In production they come from the platform's secret store…

PythonEnvironments, packaging and tooling

How do you read a Python traceback?

Bottom up. The last line names the exception. The frames above show the call path. Find the last frame in your own code, because that is usually where the mistake is.

PythonEnvironments, packaging and tooling

What is a branch in git?

A file containing one commit hash, plus an entry in HEAD saying which branch you are on. The commits are not stored in the branch, so creating and deleting branches is instant and…

Git & collaborationGit as you actually use it1 follow-up

Which HTTP errors should you retry?

429 after a backoff, and 5xx and network timeouts, which are often transient. Not 4xx generally, because an identical request will fail identically, so retrying wastes time and…

HTTP & APIsRequests, status codes and headers

Why add jitter to exponential backoff?

Without it, all clients that failed at the same moment retry at the same moment, producing a synchronised spike that can knock over the recovering service again. Randomness…

HTTP & APIsRetries, rate limits and timeouts

Where should validation happen?

At every boundary where data enters from somewhere you do not control, and only there. Past that point everything downstream can assume the shape is correct, which keeps the…

Typing & validationValidating at the boundary

When do you use a LEFT JOIN?

When you need every row from the left side regardless of whether there is a match, and absence is meaningful. Watch the counting trap: COUNT(*) counts the unmatched row,…

SQL & data accessGetting the data out

What is a window function for?

Computing across a set of related rows while keeping every row, rather than collapsing them as GROUP BY does. Ranking within a group, comparing to the previous row, and taking the…

SQL & data accessGetting the data out

Why can NOT IN return nothing?

If the subquery contains a NULL, the comparison with that NULL is unknown for every row, so no row satisfies NOT IN. NOT EXISTS does not have this problem.

SQL & data accessThe queries you will actually be asked to write

What does a dot product tell you?

How aligned two vectors are. It is the sum of elementwise products, and dividing out the magnitudes gives cosine similarity, which compares direction only. It underlies embedding…

Linear algebraVectors, matrices and what a multiply means

What is broadcasting and why is it risky?

NumPy stretching a smaller array to match a larger one when shapes are compatible. It is convenient and it can silently produce a valid array of the wrong shape rather than an…

Linear algebraVectors, matrices and what a multiply means

What does SVD give you?

A decomposition of any matrix into rotations and a scaling. Truncating to the largest singular values gives the best low-rank approximation, which underlies compression, PCA and…

Linear algebraNorms, projections and decompositions

How does PCA relate to eigenvectors?

PCA finds the eigenvectors of the data's covariance matrix. They are the directions of greatest variance, and the eigenvalues say how much variance each direction captures.

Linear algebraNorms, projections and decompositions

Explain PCA.

Centre the data, then find the orthogonal directions along which it varies most, in order. Projecting onto the first few keeps as much variance as possible in fewer dimensions. In…

Linear algebraPCA from scratch2 follow-ups

What is perplexity?

The exponential of the average cross-entropy per token. It reads as an average branching factor: a perplexity of 8 means the model is as uncertain as if it were choosing uniformly…

Probability & statisticsEntropy, cross-entropy, KL and perplexity3 follow-ups

What is KL divergence?

The average extra surprise from using distribution q when the truth is p: cross-entropy minus entropy. It is zero when the two match and grows as they diverge, and it is measured…

Probability & statisticsEntropy, cross-entropy, KL and perplexity1 follow-up

What does a p-value of 0.03 mean?

If there were no real effect, data at least this extreme would occur about 3% of the time. It does not mean there is a 97% chance the effect is real, and it says nothing about the…

Probability & statisticsHypothesis tests and intervals, practically1 follow-up

What is a gradient?

The vector of partial derivatives of the loss with respect to every parameter. It points in the direction of steepest increase, so training steps against it to reduce the loss.

Calculus for MLDerivatives and the chain rule

What does momentum do?

It accumulates a running average of past gradients, so consistent directions gain speed and oscillations cancel. That carries the optimiser across saddle points and plateaus and…

Calculus for MLThe shape of the loss surface

Explain the Adam update.

It keeps a running average of gradients, which acts as momentum, and a running average of squared gradients, which estimates each parameter's gradient scale. Both are…

Calculus for MLGradient descent, momentum and Adam from scratch2 follow-ups

How would you handle missing values?

First find out whether missingness is informative, and if so record it as a feature before imputing. Then drop rows missing something essential, and impute the rest with a median…

NumPy & pandasThinking in arrays

How do you handle late-arriving data?

Decide explicitly how late an event may be and still be included, using a watermark, and define what happens to events after that. Assuming ordered arrival produces subtly wrong…

Data pipelinesOrchestration, streaming and lineage

What is a token?

A piece of text that the model treats as one unit, usually a subword. Text is converted into a list of token ids before the model sees it, and the model only ever works with those…

TokenizationWhat a token is

What is a context window?

The maximum number of tokens a model can process in one request. It includes the system prompt, the full conversation history, any retrieved content, tool definitions and the…

TokenizationContext limits and what fits

What happens if you exceed it?

The request is rejected rather than truncated. Anything building a prompt from variable-length pieces has to check the size before sending.

TokenizationContext limits and what fits

Are LLM APIs stateful or stateless?

Stateless. The model retains nothing between calls. Conversation is created by the caller resending the full history each turn. Some products offer a session id, but underneath…

The Messages APIThe model has no memory

What does temperature do?

It scales the probability distribution before a token is sampled. Low values concentrate probability on the most likely token, high values spread it out. It can only produce…

The Messages APIParameters that change the output

Is temperature 0 deterministic?

Not on a hosted API. Batched GPU execution, non-associative floating point addition, expert routing and varying hardware all introduce small differences. This is why exact-match…

The Messages APIParameters that change the output1 follow-up

How many examples should you use?

Usually three to five, chosen so each teaches something different. More similar examples add cost without adding information. Always include the empty or unknown case, or the…

PromptingExamples, and when they earn their cost

What is a risk of few-shot prompting?

The model imitates the examples closely, including any inconsistency or mistake in them, and it can over-fit to their surface pattern. It can also bias the output distribution if…

PromptingExamples, and when they earn their cost

Does chain-of-thought prompting still help?

It depends on the model. On older and smaller models it gives a real improvement on multi-step tasks. Newer reasoning models do it internally, and explicit instructions can…

PromptingReasoning, and improving a prompt honestly

Is temperature 0 deterministic?

Not on a hosted API. Batched GPU execution, non-associative floating point addition, expert routing and varying hardware all introduce small differences. Locally, with a fixed…

Sampling & decodingHow a model picks the next token

What is self-consistency?

Sampling several answers to the same question and taking the most common one. Independent errors rarely agree, so the majority answer is more accurate than one sample. It costs…

Sampling & decodingSampling settings for real tasks2 follow-ups

Should every field be required?

No. Marking a field required when the source may not contain it forces the model to invent a value. Make genuinely optional fields optional and instruct the model to return null…

Structured outputAsking for JSON versus guaranteeing it

What breaks prompt caching?

Any change in the prefix, since matching runs from the start and stops at the first difference. Timestamps, request ids, a user name near the top, or JSON serialised with unstable…

Prompt cachingPrompt caching

When does prompt caching not save money?

When requests are too infrequent for the cache to stay warm, so most requests pay the write price, or when the prompt changes near the start so the prefix rarely matches. Work out…

Prompt cachingThe cost maths, and caching whole responses1 follow-up

What are the risks of semantic caching?

Returning an answer to a question that is similar but means something different, and leaking answers between users when responses are personal. Limit it to non-personal questions,…

Prompt cachingThe cost maths, and caching whole responses1 follow-up

What makes a good tool description?

It says when to use the tool, not only what it does, and it says what the tool returns. The model uses the description to choose between tools, so vague or overlapping…

Tool callingHow tool calling works

Why use an enum in a parameter schema?

It constrains the argument to valid values at generation time, so an invalid status or category cannot be produced. It also removes a whole class of validation code from your…

Tool callingHow tool calling works

Why does the size of a tool result matter?

It enters the context and is resent on every subsequent turn, so a large result raises the cost of the whole remaining conversation. Return only what is needed and cap anything…

Tool callingFailures, parallel calls and keeping results small

When would you not use an agent?

When the steps are known in advance. A fixed pipeline is cheaper, faster and far easier to debug. Agents earn their cost only when the path depends on what is discovered along the…

The agent loopWhat an agent actually is2 follow-ups

Where does the loop run?

In your code. The model cannot execute anything or call itself. It only emits a structured request, and your program decides whether to act on it and what to send back.

The agent loopWhat an agent actually is

How do you stop an agent running forever?

Three independent budgets: turns, wall-clock time and cost. Any one being exceeded stops the run. Turns alone are not enough because a single turn can be slow or expensive.

The agent loopBudgets, loops and giving up well3 follow-ups

What must survive compaction?

The original task, anything the user said including corrections and constraints, decisions already taken, and failures already hit. Losing those causes the agent to wander or…

The agent loopManaging the context as it grows

How many eval tasks do you need?

Twenty real ones beats two hundred synthetic ones. Draw them from actual usage, include every failure you have already seen in production, and version the set so a score from last…

The agent loopKnowing whether it works

When would you not use MCP?

A single application with a few tools that nobody else needs. Plain function calling is simpler and has fewer moving parts. The protocol pays off with multiple clients or when you…

MCP & tool interfacesWhat MCP is for

Have you built an MCP server?

Answer with the specific thing you built, what it wrapped, and one design decision you had to make, such as how you capped result size or handled auth. This is asked to find out…

MCP & tool interfacesBuilding and shipping a server

What goes wrong with critic loops?

Without a stopping rule they never end, because a reviewer can always find something. Cap the rounds and define what acceptable means, since quality usually plateaus after the…

Multi-agent systemsCoordination patterns and their costs1 follow-up

How do you make an agent safe to retry?

Idempotent tools keyed on run id and intent, so a repeated call returns the previous result instead of acting twice. Checkpoint after each turn so a resumed run continues rather…

Agent reliabilityDesigning so failure is survivable1 follow-up

What is an embedding?

A vector representing a piece of text, positioned so that text with similar meaning lands nearby. It converts semantic similarity into geometric distance, which makes similarity…

EmbeddingsTurning meaning into coordinates

What is hybrid search?

Running keyword and vector search together and fusing the results, usually by rank rather than raw score since the two scoring scales are incomparable. Keyword catches exact…

EmbeddingsWhere embedding search fails

What does a reranker do?

It scores each candidate against the query directly rather than comparing pre-computed vectors, which is more accurate and much slower. You use it to reorder a shortlist, never to…

EmbeddingsWhere embedding search fails

Why use two retrieval stages?

Recall and precision want different things. The first stage is cheap and broad so the answer is definitely in the candidate set. The second is expensive and accurate and orders a…

Reranking & hybrid searchRetrieve broadly, then rank precisely

Why does gradient boosting work?

Each tree is fitted to the gradient of the loss with respect to the current ensemble's predictions, so adding it moves the ensemble towards lower loss. It is gradient descent over…

Supervised learningHow the main algorithms actually work

Explain the bias-variance trade-off.

Error from a model has a part from wrong assumptions, bias, and a part from sensitivity to the particular training sample, variance. Simple models have high bias and low variance;…

Supervised learningThe questions every ML interview asks, answered properly2 follow-ups

What is the curse of dimensionality?

As the number of features grows, data becomes sparse in the space and distances between points become similar, so methods that rely on neighbourhoods, like k-nearest neighbours,…

Supervised learningThe questions every ML interview asks, answered properly

What does regularisation do?

It adds a cost for model complexity, such as large weights, so the model prefers simpler explanations that generalise better. L2 shrinks weights smoothly; L1 drives many to zero.…

Supervised learningThe questions every ML interview asks, answered properly

When does feature scaling matter?

For linear models, neural networks and distance-based methods, where a feature on a larger numeric scale otherwise dominates. Tree models are invariant to monotonic…

Feature engineeringShaping inputs so the model can use them

What is PCA doing?

Finding the orthogonal directions of greatest variance and projecting the data onto the first few. It compresses while keeping as much variance as possible, and the components are…

Unsupervised learningFinding structure without labels

What is the dying ReLU problem?

A unit whose input is always negative outputs zero and has zero gradient, so it never updates and is permanently dead. Leaky ReLU and GELU avoid it by keeping a small gradient for…

Neural networksWhat a neural network is

What does Adam do that SGD does not?

It adapts the step size per parameter using running estimates of the gradient and its square, so parameters with consistently small gradients still move. It is less sensitive to…

BackpropagationHow training actually works

Why use a learning rate warmup?

Early in training the weights are random and gradients can be large, so a full-size step can destabilise the run. Warming up from a small rate avoids that, and it matters most for…

BackpropagationHow training actually works

What does model.eval() do?

Switches layers that behave differently at inference, notably dropout and batch normalisation, into evaluation mode. Forgetting it makes validation numbers noisy and pessimistic,…

PyTorchPyTorch in practice

Why wrap validation in torch.no_grad()?

It stops the framework recording operations for gradient computation, which is unnecessary during evaluation. It saves memory and time, and without it a large validation pass can…

PyTorchPyTorch in practice

How would you speed up a training run?

Profile first, because the bottleneck is usually data loading or synchronisation rather than arithmetic. Then mixed precision, more data loader workers, removing per-step .item()…

PyTorchAutograd, custom pieces and performance

Walk me through a minimal GPT-style model.

Token ids go through token and position embeddings and are added. A stack of blocks follows, each with layer norm, causal multi-head self-attention added back to the residual,…

PyTorchBuild and train a small transformer from scratch2 follow-ups

Explain how attention works.

Each position produces a query, a key and a value. The query is compared against every key to produce weights, and the output is a weighted mixture of the values. It lets any…

Transformers & attentionAttention, conceptually3 follow-ups

What does causal masking do?

It prevents each position attending to later positions, so the model learns left-to-right prediction. It also lets the full sequence be trained in parallel, since every position…

Transformers & attentionFrom attention to a full language model

What is the KV cache?

Stored keys and values for tokens already processed, so each generation step computes only the new position rather than recomputing the whole prefix. It makes generation practical…

Transformers & attentionFrom attention to a full language model

How does a language model learn?

By predicting the next token across an enormous corpus. General capability is a side effect: predicting well requires modelling whatever produced the text, so reasoning, world…

PretrainingWhere capability comes from

What are scaling laws?

Loss falls predictably as a power law in compute, data and parameters, across many orders of magnitude. They let a lab decide how to spend a compute budget before committing, and…

PretrainingWhere capability comes from

What is LoRA?

Parameter-efficient fine-tuning. The original weights are frozen and a small number of added parameters are trained, reaching most of the benefit at a fraction of the cost. The…

Fine-tuningPrompt, retrieve or fine-tune

What is distillation?

Training a smaller model to imitate a larger one's outputs. For LLM products it is frequently the largest cost reduction available, because a distilled small model can match the…

Fine-tuningPrompt, retrieve or fine-tune

How much data do you need to fine-tune?

Depends on the goal: a few hundred clean examples for format or style, more for new behaviour. Quality and consistency matter more than volume, since the model learns exactly what…

Fine-tuningRunning a fine-tune properly2 follow-ups

Where do the examples come from?

Rarely from writing them by hand, which stalls at a few hundred. The two that work are a larger model's output filtered through your own evaluation, which is cheap and bootstraps…

Fine-tuningRunning a fine-tune properly

What is catastrophic forgetting?

Fine-tuning on a narrow task degrading the model's general abilities. LoRA reduces it by leaving the original weights untouched, and mixing general examples into training helps…

Fine-tuningRunning a fine-tune properly2 follow-ups

Which layers would you put adapters on?

The attention projections first — query and value are the usual default, and they were what the original work found sufficient. Adding key and output projections, and then the…

Fine-tuningA LoRA adapter from scratch

Why are models sycophantic?

Preference data rewards answers people like, and people tend to prefer agreement. The training signal therefore encourages agreeing, and separating being helpful from being…

Alignment & RLHFTurning a predictor into an assistant

What is the KL penalty in RLHF for?

It penalises the policy for moving too far from the original model. Without it, optimising against the reward model finds exploits: odd or sycophantic outputs that score well and…

Alignment & RLHFHow preference training is done

What is constitutional AI?

A model critiques and revises its own outputs against written principles, producing preference data without human annotators for every comparison. It scales feedback and moves…

Alignment & RLHFHow preference training is done

What do the ZeRO stages shard?

Stage 1 shards optimiser state, stage 2 adds gradients, stage 3 adds the weights. Each saves more memory and adds more communication, with weights being the costliest because they…

Distributed trainingSharded data parallelism in practice

What is activation checkpointing?

Storing only some forward-pass activations and recomputing the rest during the backward pass. It trades roughly a third more compute for a large reduction in memory, and is often…

Distributed trainingSharded data parallelism in practice

What is mixed precision training?

Using 16-bit for most operations and 32-bit where precision matters, with loss scaling to stop small gradients underflowing. It roughly halves memory and can double throughput at…

GPUs & acceleratorsWhat the hardware is doing

What does kernel fusion do?

Combines several operations into one kernel so intermediate results stay on-chip instead of being written to and read from memory between steps. The saving is in memory traffic…

GPUs & acceleratorsGetting the most from the hardware

What is an eval?

A fixed set of inputs with a defined way of scoring the output, run on every change, producing a number you can compare between versions. It is the equivalent of a test suite for…

EvaluationWhy evals exist

Why can you not just use unit tests?

Model output varies between runs and there is usually no single correct string. Exact-match assertions flake and get deleted. Evals score properties and use graded judgement…

EvaluationWhy evals exist

Why note only the first failure in a trace?

Later failures are often consequences of the first. If retrieval fetched the wrong document, the wrong answer that follows is not a separate problem. Counting both inflates the…

EvaluationError analysis: read traces before you write evals

Where do eval cases come from?

Real traffic, not imagination. Common cases in realistic proportions, every production failure you have seen, edge cases, and cases where the right answer is to refuse or return…

EvaluationBuilding the dataset

How big should an eval set be?

Twenty real cases is enough to start and already catches regressions. A few hundred gives tighter confidence. Beyond that, variety matters far more than volume.

EvaluationBuilding the dataset

What are the known biases of an LLM judge?

Preference for longer answers, preference for its own writing style, sensitivity to the order of compared options, and general leniency. Each has a mitigation: rule length out in…

EvaluationGrading: code first, judges second

What are the biases of an LLM judge?

Preference for length, preference for its own style, sensitivity to the order of compared options, and general leniency. Mitigate by ruling length out in the rubric, using a…

LLM-as-judgeGrading with a model

What is prompt injection?

Untrusted content containing instructions that the model follows. It works because a model has no separation between instructions and data: the system prompt, user input,…

Prompt injection & guardrailsWhy prompt injection cannot be prompted away

What is training-serving skew?

Features computed differently at training and serving time, so the deployed model sees inputs unlike its training data. It degrades accuracy with no error, and sharing one…

MLOps & model lifecycleThe platform around the model2 follow-ups

What would you build first?

Ingestion, retrieval with permission filtering, and a retrieval eval, because retrieval quality and access control decide whether the system works. Generation is comparatively…

AI system designWorked design: questions over company documents

How would you evaluate this agent?

Against the end state of test accounts rather than the agent's words: whether the correct action happened, for the right amount, exactly once. Include adversarial cases where the…

AI system designWorked design: an agent acting on customer accounts

Explain eventual consistency.

Replicas converge over time rather than immediately, so a read straight after a write may return the old value. Most systems accept this in exchange for availability under…

Distributed systemsThe classic fundamentals

How do you keep up with the literature?

Triage rather than volume. Abstract, figures and conclusion for most, method and results for the promising ones, full depth only for what I will build on. Breadth comes from…

Reading papersReading papers without reading papers

How many seeds should you run?

Enough to know the variance, usually three to five for expensive runs and more when cheap. Without knowing the spread you cannot say whether a difference means anything.

Experiment designIsolating what actually caused the improvement

Why state limitations explicitly?

An unacknowledged limitation found by a reviewer reads as a flaw. The same limitation stated by the author reads as scope and rigour. It also stops readers drawing conclusions the…

Writing & communicationWork nobody can follow has not landed1 follow-up

What surprised you recently?

Something specific you expected to go one way and did not, and what you concluded. Following up on your own surprises is how directions are found, and the answer shows whether you…

Research tasteChoosing a problem worth solving

How do you find research problems?

Read for gaps rather than results, especially limitations sections, which are authors honestly saying where the work stops. Keep a running list of questions you cannot answer,…

Research tasteReading in order to find problems

Pitch me a research project in two minutes.

State the question in one sentence, why it matters and to whom, why it is tractable now, the first cheap experiment and what result would make you stop, and what you would do if…

Research tasteWriting a one-page research pitch1 follow-up

Why does Dockerfile layer order matter?

Each instruction is a cached layer, and a change invalidates every layer after it. Copying dependency files and installing before copying source means a code change does not…

ContainersContainers and deployment

Why should a container not run as root?

If the application is compromised, root inside the container makes it easier to damage mounted data or exploit a container escape. A normal user limits what an attacker gets.

ContainersA Dockerfile that builds fast and runs safely

How do you test code that calls an LLM?

Fake the model at the boundary with scripted replies, which makes everything around it deterministic: parsing, retries, budgets, tool dispatch, prompt assembly. The quality of the…

TestingTesting a system with a non-deterministic part

What is the difference between a test and an eval?

A test asserts something that must always hold and is deterministic. An eval measures a rate over a task set and is expected to be imperfect. Mixing them produces flaky tests that…

TestingTesting a system with a non-deterministic part

How do you test an agent without calling a model?

Replace the model with a scripted fake that returns a planned sequence of tool calls and answers. Then test the loop's behaviour: tools run with the right arguments, results are…

TestingTests for prompts, tools and agent loops1 follow-up

Walk me through how you debug something.

Reproduce it reliably first. Then one hypothesis at a time, choosing the cheapest experiment that could falsify it rather than confirm it. Bisect the pipeline to eliminate half…

DebuggingDebugging systematically

How do you approach an intermittent bug?

Find what varies between runs: concurrency, timing, external dependencies, or sampling. For AI systems, non-zero temperature means identical input genuinely produces different…

DebuggingDebugging systematically

What does git bisect do?

Binary search through commit history to find the one that introduced a problem. You mark a good and a bad commit, and git checks out midpoints for you to test, or runs a test…

DebuggingThe tools: debugger, profiler, logs, bisect

How would you choose between two models?

Use benchmarks only to shortlist, then run my own eval on real tasks and compare pass rate, cost and p95 latency together. Keep the prompt identical for the first comparison, then…

Choosing a modelChoosing and changing models1 follow-up

Why pin model versions?

So behaviour does not change without a deliberate decision. An alias that moves to a new version can alter output format or quality overnight, and you learn about it from users.

Choosing a modelChanging models without breaking things

What did LSTM add?

Gates that let information pass through the cell state largely unchanged, which helped gradients survive across many steps. It addressed long-range dependencies and did nothing…

Sequence models before transformersSequence models before transformers

Why does transfer learning work?

Early layers learn general features of the medium rather than the task, so they transfer. Only the later, specialised layers need replacing, which is why a new head plus a small…

Transfer learningStarting from someone else's training run

Why use learning rate warmup?

Early in training the weights and the optimiser's running statistics are poorly set, so a full learning rate can cause divergence. Ramping up over the first steps avoids that,…

Hyperparameter tuningLearning rate schedules and a tuning workflow

What would you log for a training run?

Hyperparameters, metrics per epoch, the git commit with a dirty flag, the data version as a content hash, the environment and package versions, the seed, and the resulting model…

Experiment trackingKnowing which run produced which result2 follow-ups

How would you evaluate a demand forecasting model?

Rolling-origin backtesting that trains only on the past and forecasts the real horizon, a seasonal naive baseline, a scale-free metric such as MASE so products of different volume…

Time seriesForecasting in code: baselines, backtests and intervals2 follow-ups

What is a two-tower model?

Separate networks embed users and items, and relevance is their similarity. Item embeddings are precomputed, so retrieval is a fast nearest-neighbour search. It is the same design…

Recommendation systemsRanking models and how to measure them

What is reward hacking?

Optimising a proxy hard enough that the model finds unintended ways to score well. With human preference data that shows up as confident, agreeable, well-formatted answers being…

Reinforcement learningLearning by acting

Explain the Q-learning update.

Q of a state and action moves towards the reward received plus the discounted best Q value of the next state. The gap between that target and the current estimate is the temporal…

Reinforcement learningValue learning: Q-learning from scratch2 follow-ups

Walk me through the PPO objective.

The ratio compares the new policy's probability of an action with the old policy's. Multiplied by the advantage, it says how much better the new policy is on that data. Clipping…

Reinforcement learningPolicy gradients: from REINFORCE to PPO2 follow-ups

What is mechanistic interpretability?

Reverse-engineering the computation a network performs, identifying circuits of components that implement a specific behaviour. More ambitious than attribution or probing, which…

InterpretabilityWorking out what the network is doing

Why is attribution not an explanation?

It shows which inputs influenced the output, which is consistent with correct reasoning and with pattern matching. It is evidence about where the model attended rather than about…

InterpretabilityThe techniques, and what each establishes

What is red teaming?

Deliberately trying to make a model behave badly. Manual work finds creative attacks automated methods miss; automated work scales. Findings feed back into training and…

Safety & evaluation researchMeasuring and reducing what could go wrong

What is compute-optimal training?

Allocating a fixed compute budget between model size and training tokens to minimise loss. The key finding was that they should grow together, and that earlier large models were…

Scaling lawsPredicting capability from compute

Are emergent abilities real?

Disputed. Sudden capability jumps are widely reported, and a serious counter-argument holds that they are partly an artefact of discontinuous metrics, where smooth improvement…

Scaling lawsPredicting capability from compute

What do scaling laws not tell you?

When specific abilities appear, how a model performs on a particular downstream task, and what happens with a different architecture or data mix than the one the law was fitted on.

Scaling lawsUsing scaling laws: the arithmetic