66 AI Interview Questions and Answers

Updated · 18 min read

AI interview questions come from every direction: a product manager is asked how to measure an AI feature, a developer how RAG works, an ML engineer how backpropagation works. Interviewers want to hear that you understand what is happening and where it fails, not a list of buzzwords. This page has 66 questions in three levels, each with a model answer and a link to the lesson that explains it. For "what would you do if..." questions, see AI Scenario Questions.

How to Practice

  1. Pick a level with the buttons below: Easy is for everyone, Medium for product and builder roles, Hard for engineering roles.
  2. Answer out loud in under 2 minutes before opening the model answer.
  3. Compare your answer with the key points in the model answer.
  4. Missed something? Every answer ends with a link to the lesson to revise.

Easy Questions (1 to 21)

The foundations every interviewer may check, for any role.

1. What is Artificial Intelligence?

AI is the field of building computer systems that do tasks that usually need human intelligence, such as understanding language, recognizing images, making predictions and decisions. Most AI today learns patterns from examples rather than following hand-written rules. Revise: What Is Artificial Intelligence.

2. How are AI, machine learning and deep learning related?

They are nested circles. AI is the whole field; machine learning is the part of AI where systems learn from data; deep learning is the part of machine learning that uses neural networks with many layers. Generative AI and LLMs are built with deep learning. Revise: AI, Machine Learning and Deep Learning.

3. What is the difference between traditional programming and machine learning?

In traditional programming a person writes the rules, and the computer applies them to data to get answers. In machine learning a person provides data and answers (examples), and the computer learns the rules, which then work on new data. Revise: Traditional Programming vs Machine Learning.

4. What is a model?

A model is the learned result of training: a mathematical function, usually millions or billions of numbers, that turns an input (text, an image, a row of data) into an output (a prediction, a label, generated text). Revise: What Is an AI Model.

5. What are parameters?

Parameters are the numbers a model learns during training, such as the weights and biases of a neural network. SmolLM2-135M, used in this course, has 134,515,008 of them. More parameters can store more patterns, but cost more to train and run. Revise: Parameters: What a Model Learns.

6. What is the difference between training and inference?

Training is the slow, expensive phase where the model learns its parameters from data. Inference is using the trained model to make a prediction or generate output; the parameters don't change. Chatting with an assistant is inference. Revise: Training vs Inference.

7. What are supervised, unsupervised and reinforcement learning?

Supervised learning learns from labeled examples (inputs with correct answers). Unsupervised learning finds structure, such as clusters, in unlabeled data. Reinforcement learning learns by trial and error from rewards. Revise: Types of Machine Learning.

8. What is generative AI?

AI that creates new content, such as text, images, audio, video or code, instead of only classifying or predicting. It learns the patterns of its training data and produces new examples that follow them. Revise: What Is Generative AI.

9. What is a large language model?

A neural network, usually a Transformer, trained on a huge amount of text to predict the next token. That simple task teaches it grammar, facts and reasoning patterns; after instruction tuning it can follow requests like an assistant. Revise: What Is a Large Language Model.

10. What is a token?

The unit of text a language model reads and writes: a word, part of a word or a punctuation mark, each with an ID number. In English a token is about three quarters of a word on average; other languages often need more tokens for the same message. Revise: Tokens, Tokenization.

11. How does an LLM generate an answer?

One token at a time. It reads the prompt, gives a probability to every token in its vocabulary for what comes next, picks one (greedily or by sampling), adds it to the text, and repeats until it writes an end token or reaches a limit. Revise: How an LLM Generates Text.

12. What is a context window?

The maximum number of tokens a model can consider at once, prompt and reply together. Anything outside it is invisible to the model. Longer contexts cost more memory and time, and models may use the middle of long prompts less well. Revise: Context and Context Windows.

13. Why do LLMs hallucinate, and how do you reduce it?

Because they generate likely-sounding text, not checked facts, and rarely say "I don't know". Reduce it by grounding answers in retrieved sources (RAG), asking for citations, lowering temperature for factual tasks, and verifying important claims. Revise: Why LLMs Hallucinate, Grounding Prompts in Sources.

14. What makes a good prompt?

A clear task, the context the model needs, the format you want, examples where useful, and constraints such as length or what to avoid. Then test it on several inputs and refine. Revise: The Five-Part Prompt Framework.

15. What is few-shot prompting?

Including a few worked examples of input and ideal output in the prompt, so the model copies the pattern. It is often the fastest way to fix format and style without fine-tuning. Revise: Zero-Shot and Few-Shot Prompting.

16. What is an API?

An Application Programming Interface: a defined way for one program to send requests to another and get responses. Model APIs let your code send a prompt to a hosted model and receive its reply, usually as JSON over HTTPS. Revise: What Is an API.

17. What is the difference between a model and an application like ChatGPT?

The model is the trained network that predicts text. The application wraps it with a user interface, a system prompt, safety filters, memory, tools such as web search, and accounts. The same model can power many different applications. Revise: Model vs Application vs Interface.

18. What should you never share with an AI tool?

Passwords, API keys, government ID numbers, health and financial records, other people's personal data, and confidential company information, unless your organization has approved the tool and its data terms for that use. Revise: Privacy: What Not to Share with AI.

19. What is bias in AI, with an example?

Systematically worse results for some group, usually learned from data. In this course, a scholarship model trained on biased past decisions accepted qualified group B applicants far less often (61.5% vs 80.4%) without ever seeing the group column, because another column acted as a proxy. Revise: AI Bias in Everyday Tools, Bias and Fairness.

20. What AI role fits a software developer, and what should they learn first?

Usually AI application developer, then AI engineer. A developer already has most of the skills; the gaps are typically prompting, RAG and evaluation. Build one small app that answers from documents and measure it. Revise: AI Career Paths, Learning Paths by Background.

21. Where should a human stay in the loop?

Wherever a mistake would seriously affect people: health, money, hiring, law, education and safety-critical systems, and for uncertain cases in any app. Routing Campus Helper's uncertain answers to a person raised its score from 44/50 to 48/50. Revise: Keeping Humans in the Loop.

Medium Questions (22 to 43)

For product, builder and AI application roles.

22. When would you use prompting, RAG or fine-tuning?

Prompting first, for any task a clear prompt can handle. RAG when answers must come from your own or changing documents, with sources. Fine-tuning when you need consistent behavior, format or a narrow skill that prompting can't make reliable. Many systems combine RAG and fine-tuning. Revise: RAG vs Fine-Tuning vs Long Context, What Is Fine-Tuning.

23. How do you choose a model for a product?

Write an evaluation set from real tasks, then compare candidate models on quality, latency, cost per request, context length, data terms, license and availability. Pick the cheapest model that meets your quality bar, and re-test when models change. Revise: Choosing an AI Tool, Hosted, Open and Local Models.

24. How do you measure whether an AI feature works?

Before launch, score it on an evaluation set of realistic cases with clear pass rules. After launch, monitor quality signals (ratings, declines, escalations), cost and latency, and rerun the evaluation after every change. Revise: Why AI Needs Evaluation, Monitoring Quality, Cost and Latency.

25. How are AI API costs calculated, and how do you reduce them?

Input tokens × input price + output tokens × output price, per request. Reduce them with shorter prompts and retrieved context, smaller models for easy tasks, caching repeated requests, output length limits and batching. Revise: Tokens, Cost and Rate Limits.

26. What is structured output, and why validate it?

Asking the model to reply in a fixed format such as JSON with a schema, so code can use it. Validate it because models can still return missing fields, wrong types or invalid values; reject or retry on failure. Revise: Structured Output and JSON.

27. What is tool use (function calling)?

The model asks your application to run a function by returning its name and arguments; your code runs it and sends back the result. It lets models look things up, calculate or act, while your code stays in control. Revise: Tool Use and Function Calling.

28. What is an embedding, and what is cosine similarity?

An embedding is a list of numbers representing the meaning of text (or an image), so similar meanings get similar vectors. Cosine similarity measures how closely two vectors point the same way, from -1 to 1; it powers semantic search. Revise: What Are Embeddings, Similarity and Cosine Distance.

29. How does chunking affect RAG quality?

Retrieval returns chunks, not documents. Chunks that are too big dilute the match and waste context; too small and they lose meaning. Split on natural boundaries with some overlap, and test chunk sizes against your evaluation set. Revise: Chunking Documents.

30. How do you build an evaluation set?

Collect realistic questions, including hard, reworded and out-of-scope ones; write the expected answer or a pass rule for each; keep it under version control; and add every real failure as a new case. Campus Helper's set has 50 cases. Revise: Building an Evaluation Set.

31. What are guardrails?

Checks around a model that constrain its inputs and outputs: input validation, topic and safety filters, output schema checks, grounding checks, rate limits and human review for risky cases. Revise: Guardrails.

32. What is the difference between a workflow and an agent?

A workflow follows fixed steps written by a person, some of which call a model. An agent lets the model decide the next step and which tools to call, in a loop, until the goal is met. Workflows are more predictable; agents handle more open-ended tasks. Revise: Workflows vs Agents.

33. How do you keep an agent from taking harmful actions?

Least-privilege tools with argument checks in code, a step limit, human approval for anything that changes data or costs money, budgets, separate credentials and logging of every requested action. Revise: Securing Agents and Tools, Controlling Agent Autonomy.

34. What is MCP, and what problem does it solve?

The Model Context Protocol is a standard way to connect tools and data sources to AI applications. Instead of writing a custom integration for each app and tool, a tool is wrapped once as an MCP server and any MCP-capable app can use it. Revise: Connecting Tools with MCP.

35. How do you handle personal data in an AI product?

Collect only what you need, redact it before logging or sending to providers, check providers' data terms, apply user permissions in retrieval, limit retention and access, and keep it out of training data unless allowed. Revise: Data Leakage and Privacy Attacks, Data Privacy Basics.

36. How do you design an AI feature users trust?

Say it's AI, show sources, show uncertainty, make it easy to correct or escalate to a person, handle "I don't know" gracefully, and be consistent. Trust comes from honest behavior on the hard cases. Revise: Designing AI User Experiences.

37. Build or buy: how do you decide?

Buy when a vendor already meets your needs on your own test cases at an acceptable price and data terms; build when the feature is core to your product, needs your data deeply, or no vendor passes your evaluation. Compare total cost, not just license price. Revise: Choosing an AI Vendor.

38. How do you reduce latency in an AI application?

Use a smaller or faster model, stream the response, shorten prompts, cache repeated requests, batch where possible, run retrieval in parallel, and set limits on output length. Track the 95th percentile, not the average. Revise: Streaming Responses, Deploying Models and AI Apps.

39. What is the difference between open-weight and API-only models?

Open-weight models can be downloaded and run on your own hardware under their license; API-only models are used through a provider's service. Open weights give control and privacy; APIs give the most capable models with no servers to run. Revise: Open and Closed Models.

40. Which metrics matter for an AI product after launch?

Task success or quality scores, user ratings and escalations, decline and error rates, adoption and retention, cost per interaction, latency percentiles and safety incidents, broken down by user group. Revise: AI Product Metrics.

41. How do you review code written by an AI coding assistant?

Like a colleague's pull request, but more carefully: run it and its tests, check edge cases and error handling, look for security problems (injection, secrets, unsafe input), confirm any library or function it uses really exists, and make sure you understand every line before merging. Revise: Reviewing AI-Generated Code, AI Coding Assistants.

42. Why use NumPy and pandas instead of plain Python loops for data work?

They run operations on whole arrays and tables in fast compiled code. In this course, a NumPy calculation was about 10,000 times faster than the same Python loop, and pandas makes loading, cleaning and grouping data a few clear lines. Revise: NumPy Basics, Pandas Basics.

43. How do you evaluate an AI vendor?

Test quality on 20 or more of your own examples, then check data use and retention, security certifications, access control, pricing at your volume, limits and uptime, support, and how to export your data and leave. Revise: Choosing an AI Vendor.

Hard Questions (44 to 66)

For engineering roles that train, tune, secure or run models.

44. Explain gradient descent.

An optimization method: compute the gradient of the loss with respect to each parameter, then move each parameter a small step in the opposite direction, and repeat. The learning rate sets the step size: too small is slow, too big diverges (in the course, 0.2 blew up the loss to about 10⁴⁷). Revise: Gradient Descent.

45. Explain backpropagation.

The algorithm that computes gradients in a neural network efficiently: after the forward pass, apply the chain rule backward from the loss through each layer, reusing intermediate results. Gradient descent then uses those gradients to update the weights. Revise: Backpropagation.

46. What is overfitting, and how do you prevent it?

When a model learns the training data, including its noise, so well that it does worse on new data. Prevent it with more data, simpler models, regularization, early stopping, dropout, and by checking on validation data with cross-validation. Revise: Overfitting and Generalization, Overfitting, Underfitting and Cross-Validation.

47. Precision vs recall: when does each matter?

Precision: of the items flagged, how many were right. Recall: of the items that should be flagged, how many were found. Favor recall when missing a case is costly (fraud, disease); favor precision when false alarms are costly (spam blocking real email). Revise: Evaluating Models: Metrics.

48. What is data leakage, and how do you avoid it?

When information from the test set, or from the future, gets into training, making scores look better than they really are. Avoid it by splitting first, fitting preprocessing only on training data (pipelines), splitting by group or time where needed, and checking for duplicates. Revise: Overfitting, Underfitting and Cross-Validation, Preparing Fine-Tuning Data.

49. How does self-attention work?

Each token makes a query, key and value. Queries are compared with keys (softmax(QKᵀ / √d)) to get weights, and each token's output is the weighted mix of values. A causal mask stops language models looking ahead; multiple heads learn different relationships. Revise: Self-Attention.

50. What is inside a Transformer block?

Self-attention and a feed-forward network, each with normalization and a residual connection. Models stack many identical blocks between a token embedding layer and an output layer; SmolLM2-135M has 30. Revise: Inside a Transformer.

51. How does byte-pair encoding tokenize text?

BPE starts from bytes or characters and repeatedly merges the most frequent adjacent pair into a new token until reaching the vocabulary size. New text is tokenized by applying the learned merges in order, so unseen words are built from known pieces. Revise: Tokenization.

52. Pretraining vs instruction tuning vs RLHF?

Pretraining teaches next-token prediction on huge text and produces a base model. Instruction tuning (SFT) trains on example conversations so it answers like an assistant. RLHF or DPO tunes it toward answers people prefer. Revise: Pretraining, Instruction Tuning and RLHF.

53. How do temperature, top-k and top-p change generation?

Temperature divides the logits before softmax: lower is sharper and more predictable, higher is flatter and more random. Top-k keeps the k most likely tokens; top-p keeps the smallest set reaching probability p. Then one token is sampled. Revise: Sampling and Decoding.

54. What is LoRA, and why is it efficient?

LoRA freezes the model and learns a low-rank update B·A for selected weight matrices. Only the small matrices are trained, often under 1% of parameters (0.68% in the course's Campus Helper fine-tune), and the update can be merged for no inference cost. Revise: LoRA and Efficient Fine-Tuning.

55. What is distillation?

Training a small student model to imitate a large teacher, usually from its softened probabilities or generated text. In the course a student 70 times smaller reached 96.0% on digits using the teacher's answers and no labels. Revise: Distillation and Smaller Models.

56. What is quantization, and what does it cost in quality?

Storing weights in fewer bits (8, 4) with scales, to cut memory and often speed up inference. In the course, 8-bit barely changed perplexity (41.14 vs 39.70), 4-bit with group-wise scales stayed close (42.65), and 3-bit broke the model. Revise: Quantization and Running Models Locally.

57. How do diffusion models generate images?

They start from random noise and repeatedly remove predicted noise with a trained denoiser, guided by conditioning such as a text prompt, until an image remains. Latent diffusion does this in a compressed space and decodes at the end. Revise: Diffusion Models.

58. How do you evaluate a RAG system end to end?

Evaluate retrieval (is the right passage in the top k?) and generation (is the answer correct, grounded and cited?) separately and together, on a fixed question set with expected sources, including unanswerable questions. Revise: Retrieval Quality and Reranking, Answers with Sources.

59. How do you defend against prompt injection?

In layers: no secrets or authority in the prompt, screening of inputs and retrieved content, separating data from instructions, checking outputs against trusted sources before use, least-privilege tools with human approval, and monitoring with an attack test set. Revise: Prompt Injection and Jailbreaks.

60. How do you detect and handle model drift?

Monitor input distributions feature by feature, prediction distributions and quality metrics against a baseline, and rerun evaluations on fresh labeled samples. When drift crosses a limit, investigate, retrain on recent data through the release gate, or roll back. Revise: MLOps and LLMOps.

61. How would you scale a RAG system to millions of documents?

Use an approximate-nearest-neighbor vector index, shard it, and filter by metadata and permissions at search time; add hybrid keyword search and a reranker; cache frequent queries; and update the index incrementally. Measure retrieval quality as it grows. Revise: Vector Databases, Retrieval Quality and Reranking.

62. Design an evaluation pipeline that blocks bad releases.

Keep a versioned evaluation set and attack set; on every change, CI runs them, compares the score with a threshold and the current version, and fails the build if quality drops. After release, monitor and alert, and keep rollback ready. Revise: Advanced AI Projects, Monitoring Quality, Cost and Latency.

63. Why does machine learning need linear algebra, probability, statistics and calculus?

Linear algebra represents data and model weights as vectors and matrices; probability describes uncertainty and model outputs; statistics tells you whether results are real; calculus gives the gradients that training follows downhill. Revise: Why Math Matters for ML, Derivatives and Gradients.

64. How do you choose between linear regression, logistic regression, decision trees and random forests?

Start with the target: a number suggests regression, a category suggests classification. Begin with a simple, explainable baseline (linear or logistic regression), then try trees or a random forest for non-linear patterns, and choose with cross-validation on the same split, weighing accuracy against explainability and cost. Revise: Supervised Learning, The Scikit-Learn Workflow.

65. What is transfer learning, and why does it work so well for images?

Starting from a model pretrained on millions of images and training only the last part for your task. Early layers already detect edges, textures and shapes. In this course, with just 80 photos, a CNN from scratch reached 38%, pretrained features 98% and fine-tuning 100%. Revise: Transfer Learning, Convolutional Neural Networks.

66. Design Campus Helper for 100,000 students: architecture, cost, safety and monitoring.

A web and mobile frontend; an API service behind a load balancer; permission-aware retrieval over versioned school documents; a small model for most answers and a larger one for hard cases; caching; redaction before logging; injection defenses and human escalation; nightly evaluation, cost and latency dashboards with alerts; and a responsible AI review each term. Revise: Frontend, Backend and the Model, Responsible AI Principles.

Before the Interview

  1. Prepare one project story with numbers: the problem, what you built, the evaluation score and one failure you fixed. See Presenting Your AI Project.
  2. Explain one concept with a drawing, such as RAG or attention, in two minutes.
  3. Try the scenarios on AI Scenario Questions.
  4. Check your vocabulary with the AI Glossary.
  5. Do the final self-check on Can You Explain AI?.

Was this tutorial helpful?