AI Interview Questions · Lesson 1 of 8
AI and Machine Learning Fundamentals
The warm-up round: AI vs ML vs deep learning, learning paradigms, overfitting, precision and recall, imbalanced data, drift and gradient descent.
- Beginner
- 16 min read
- 11 questions
What you will learn
- Answer the classic AI and ML warm-up questions in under a minute each
- Explain overfitting, bias-variance and evaluation metrics with examples
- Describe how models are trained, validated, monitored and kept healthy in production
Your Progress
0 of 8 lessons 0%
- Lessons0 / 8
- Completed0
- Est. time left~ 2 hours
Create a free account to keep your progress on every device.
Almost every AI interview starts here. Interviewers use fundamentals to check that you understand the ideas under the tools: why models generalise or fail, how they are measured, and what changes once they meet real data. Candidates who jump straight to LLM buzzwords and then stumble on "what is overfitting?" lose the room quickly.
This lesson covers ten questions that appear, in some form, in loops at large technology companies and in most public interview guides. The answers are deliberately compact: a definition, an example, and the trade-off.
The 11 questions in this lesson
- What is Artificial Intelligence, and how does it differ from traditional programming?
- What is the difference between AI, machine learning, deep learning and generative AI?
- Explain supervised, unsupervised, semi-supervised, self-supervised and reinforcement learning.
- What is overfitting? How do you detect and prevent it, and how does it relate to the bias-variance trade-off?
- Explain precision, recall, F1 and accuracy. When is accuracy misleading?
- How do you handle an imbalanced dataset?
- What are training, validation and test sets? What is cross-validation, and what is data leakage?
- What is model drift? Explain data drift versus concept drift and how you monitor for it.
- What is regularisation? Compare L1 and L2, and explain dropout and early stopping.
- Explain gradient descent, the learning rate, and the vanishing and exploding gradient problems.
- How do you choose a model for a new tabular problem, and how do you trade accuracy against interpretability?
1. What is Artificial Intelligence, and how does it differ from traditional programming?
Warm-up
Artificial Intelligence is the field of building systems that perform tasks that normally need human intelligence: perceiving, reasoning, learning, planning and using language. The practical difference from traditional programming is where the rules come from.
In traditional programming a developer writes the rules: input + program = output. In machine-learning-based AI the developer supplies examples and a learning algorithm, and the system infers the rules: input + desired output = program (model). A spam filter written as a hundred hand-coded if statements is traditional; a classifier trained on millions of labelled emails is AI.
Mention the Turing test if asked about definitions: Alan Turing's 1950 imitation game asks whether a machine's conversation can be told apart from a human's. It is a historical benchmark, not how modern systems are evaluated, and passing it says little about reasoning or truthfulness.
When rules still win: if the logic is fully known and must be auditable (tax calculation, access control), write code. Use ML when the rules are too many or too fuzzy to write down, such as recognising faces or ranking search results.Follow-up: Give an example where you would deliberately not use machine learning, and why.
2. What is the difference between AI, machine learning, deep learning and generative AI?
Warm-up
They are nested ideas, from broadest to most specific. AI is the goal: machines that behave intelligently. Machine learning is one way to get there: algorithms that learn patterns from data instead of being explicitly programmed. Deep learning is a subset of ML that uses neural networks with many layers, which excel at unstructured data such as images, audio and text. Generative AI is the subset of models, usually deep networks, that create new content: text, images, code, audio.
Classic AI also includes non-learning techniques: search algorithms, rule-based expert systems and planners. That is why "AI" is wider than "ML". And not all ML is deep: gradient-boosted trees still win many tabular-data problems, and they are cheaper to train and easier to explain.
A good closing line: "Deep learning matters when you have lots of data and unstructured inputs; classical ML matters when data is small, tabular, or must be explained."
Follow-up: Is a large language model machine learning? Where does it sit in this hierarchy?
3. Explain supervised, unsupervised, semi-supervised, self-supervised and reinforcement learning.
Core
| Paradigm | Signal it learns from | Typical tasks | Example |
|---|---|---|---|
| Supervised | Inputs with human-provided labels | Classification, regression | Predict churn from past customers who did or did not leave |
| Unsupervised | Inputs only, no labels | Clustering, dimensionality reduction, anomaly detection | Group customers into segments; find fraud as outliers |
| Semi-supervised | A few labels plus many unlabelled examples | Same as supervised when labels are costly | Label 1,000 X-rays, learn from 100,000 more |
| Self-supervised | Labels created from the data itself | Pre-training language and vision models | Predict the next word or a masked patch of an image |
| Reinforcement | Rewards from interacting with an environment | Control, games, sequential decisions, aligning LLMs | A policy that learns to play chess, or RLHF for chatbots |
The one to stress in a 2026 interview is self-supervised learning: it is why LLMs exist. Text supplies its own labels (the next token), so models can train on trillions of tokens without human labelling. Reinforcement learning then reappears in post-training, where human or AI feedback becomes the reward.
Follow-up: Which paradigm would you use to detect fraud when you only have a handful of confirmed fraud cases?
4. What is overfitting? How do you detect and prevent it, and how does it relate to the bias-variance trade-off?
Core
A model overfits when it memorises the training data, noise included, instead of learning the underlying pattern. It scores very well on training data and poorly on new data. Underfitting is the opposite: the model is too simple to capture the pattern, so it does badly on both.
This is the bias-variance trade-off. High bias means a model is too rigid (underfits). High variance means it is too sensitive to the particular training sample (overfits). Making a model more complex lowers bias and raises variance; the goal is the sweet spot with the lowest error on unseen data.
Here is a runnable demonstration. A model that memorises the nearest training point scores perfectly on training data but worse on fresh data than a simple line, on the same noisy dataset:
import random
random.seed(7)
def make(n):
xs = [random.uniform(0, 10) for _ in range(n)]
return [(x, 2 * x + random.gauss(0, 3)) for x in xs] # true rule: y = 2x, plus noise
train, test = make(30), make(200)
def mse(model, data):
return sum((model(x) - y) ** 2 for x, y in data) / len(data)
# Model A: memoriser (1-nearest-neighbour) -> fits the noise
def memoriser(x):
return min(train, key=lambda p: abs(p[0] - x))[1]
# Model B: simple line fitted by least squares
mx = sum(x for x, _ in train) / len(train)
my = sum(y for _, y in train) / len(train)
slope = sum((x - mx) * (y - my) for x, y in train) / sum((x - mx) ** 2 for x, _ in train)
line = lambda x: my + slope * (x - mx)
print("memoriser train %.1f test %.1f" % (mse(memoriser, train), mse(memoriser, test)))
print("line train %.1f test %.1f" % (mse(line, train), mse(line, test)))Follow-up: Your validation loss starts rising while training loss keeps falling. What do you do, in order?
5. Explain precision, recall, F1 and accuracy. When is accuracy misleading?
Core
Start from the confusion matrix, the four outcomes of a binary classifier: true positives (TP), false positives (FP), true negatives (TN) and false negatives (FN).
| Metric | Formula | Plain-English question it answers |
|---|---|---|
| Accuracy | (TP + TN) / all | Overall, how often is the model right? |
| Precision | TP / (TP + FP) | When it says positive, how often is it right? |
| Recall (sensitivity) | TP / (TP + FN) | Of all real positives, how many did it find? |
| F1 | 2 x P x R / (P + R) | One number balancing precision and recall (harmonic mean) |
tp, fp, fn, tn = 80, 20, 40, 9860 # 120 real positives in 10,000 cases: a rare-positive problem
accuracy = (tp + tn) / (tp + fp + fn + tn)
precision = tp / (tp + fp)
recall = tp / (tp + fn)
f1 = 2 * precision * recall / (precision + recall)
print("accuracy %.4f" % accuracy) # looks great
print("precision %.2f" % precision)
print("recall %.2f" % recall) # exposes the missed positives
print("f1 %.2f" % f1)
print("always-negative baseline accuracy %.4f" % ((fp + tn) / (tp + fp + fn + tn)))Follow-up: How would you pick the classification threshold for a fraud model with a fixed review-team capacity?
6. How do you handle an imbalanced dataset?
Core
Work on three levels: the data, the algorithm and the evaluation, and always fix evaluation first because it decides whether the other changes helped.
- Evaluation: stop using accuracy. Use precision, recall, F1, PR-AUC or a cost-weighted metric, and use stratified splits so each fold keeps the class ratio.
- Data: collect more minority examples if you can; oversample the minority class or undersample the majority; use SMOTE (synthesise new minority points between existing neighbours) with care and only on the training fold.
- Algorithm: use class weights or a cost-sensitive loss so mistakes on the rare class cost more; try focal loss; use tree ensembles that cope well with imbalance; or frame the task as anomaly detection when positives are extremely rare.
- Decision: tune the probability threshold on validation data instead of using 0.5, and calibrate probabilities if downstream systems consume them.
A frequent trap: resampling before splitting leaks copies of the same example into both train and test sets and inflates every metric. Split first, resample only the training portion.
Follow-up: Why can SMOTE hurt on high-dimensional or noisy data?
7. What are training, validation and test sets? What is cross-validation, and what is data leakage?
Core
The training set fits the parameters. The validation set is used to make choices: hyperparameters, features, model type, early stopping. The test set is touched once, at the end, to give an unbiased estimate of real-world performance. If you keep tuning against the test set it silently becomes a second validation set, and your final number is optimistic.
k-fold cross-validation splits the data into k parts, trains on k-1, validates on the remaining one, and rotates so every part is used for validation once. It gives a more stable estimate on small datasets at k times the cost. Use stratified folds for imbalanced classes, group folds when rows from the same user or patient must not straddle splits, and time-based splits (train on the past, validate on the future) for anything with a timeline. Data leakage is information from outside the training context sneaking into training, making results look better than they will ever be in production. Common forms: a feature that is only known after the outcome (e.g. "refund issued" when predicting churn); fitting scalers or imputers on the full dataset before splitting; duplicates across splits; random splits on time-series data. The symptom is a model that is suspiciously good offline and disappointing live.Follow-up: A model has 99% validation accuracy on a churn task but performs poorly after launch. List three leakage causes you would check.
8. What is model drift? Explain data drift versus concept drift and how you monitor for it.
Core
Model drift is the decay of a deployed model's performance over time because the world changed. Two distinct causes matter. Data drift (covariate shift): the distribution of the inputs changes, for example a new customer segment or a new phone camera, while the relationship between inputs and outputs stays the same. Concept drift: the relationship itself changes, for example fraudsters adapt, or a pandemic changes what "normal" spending looks like.In practice, ground-truth labels often arrive late (a loan defaults months later), so you monitor proxies first: input feature distributions (population stability index, Kolmogorov-Smirnov test), prediction-score distribution, and business KPIs, then confirm with real performance when labels land. Responses range from scheduled retraining to triggered retraining on drift, rolling training windows, and shadow-deploying a challenger model before it takes traffic.
For LLM applications the same idea applies to prompts and retrieved content: track topic mix, refusal rate, feedback thumbs and an offline eval set that you re-run on every model or prompt change.
Follow-up: Labels arrive after 90 days. How do you know the model is degrading now?
9. What is regularisation? Compare L1 and L2, and explain dropout and early stopping.
Core
Regularisation is any technique that discourages a model from becoming too complex so it generalises better. The classic form adds a penalty on the size of the weights to the loss.- L2 (ridge, weight decay): adds the sum of squared weights. It shrinks all weights smoothly towards zero but rarely to exactly zero. Good default; handles correlated features well.
- L1 (lasso): adds the sum of absolute weights. It pushes many weights to exactly zero, so it performs feature selection and yields sparse models.
- Elastic net: mixes both.
- Dropout: during training, randomly switch off a fraction of neurons on each step so the network cannot rely on any single path. It behaves like training an ensemble of thinner networks. It is turned off at inference.
- Early stopping: monitor validation loss and stop (keeping the best checkpoint) when it stops improving. It is the cheapest and often the most effective regulariser.
- Others: data augmentation, label smoothing, smaller models, more data, and batch/layer normalisation as a side effect.
Explain the intuition rather than the maths: a penalty says "only keep a large weight if it is really earning its place", which pushes the model towards simpler explanations of the data.
Follow-up: Why does L1 give sparse solutions while L2 does not? (Hint: think of the shape of each penalty around zero.)
10. Explain gradient descent, the learning rate, and the vanishing and exploding gradient problems.
Deep dive
Training a neural network means minimising a loss function that measures how wrong the predictions are. Gradient descent does this iteratively: compute the gradient (the direction of steepest increase in loss) with respect to every weight using backpropagation, then move each weight a small step in the opposite direction. The step size is the learning rate. Too large and training oscillates or diverges; too small and it crawls or gets stuck. Modern practice uses mini-batches (stochastic gradient descent) for speed and noise that helps escape poor minima, adaptive optimisers such as Adam, and a learning-rate schedule (warm-up then decay).
# Minimise f(w) = (w - 3)^2 with gradient descent. The gradient is 2 * (w - 3).
def descend(lr, steps=25):
w = 0.0
for _ in range(steps):
w -= lr * 2 * (w - 3)
return w
for lr in (0.01, 0.1, 0.9, 1.1):
print("lr=%-4s -> w=%.4f" % (lr, descend(lr))) # 3.0 is the answer
# 0.01 is slow, 0.1 converges, 0.9 overshoots but still converges, 1.1 divergesRemedies: ReLU-family activations, careful weight initialisation (He or Xavier), residual (skip) connections, normalisation layers (batch or layer norm), gradient clipping for exploding gradients, and gated units (LSTM/GRU) in recurrent networks. Residual connections and layer norm are exactly why very deep transformers train at all.
Follow-up: Why do transformers use residual connections and layer normalisation together?
11. How do you choose a model for a new tabular problem, and how do you trade accuracy against interpretability?
Core
Start from the problem, not the algorithm. My default loop for a tabular problem is: define the metric and its cost of errors; build a trivial baseline (predict the mean or majority class, or a logistic regression) so I know what "better" means; then try a strong tree ensemble; and only reach for deep learning if data volume or input type justifies it.
| Model family | Strengths | Watch out for |
|---|---|---|
| Linear / logistic regression | Fast, robust, very explainable, a great baseline | Cannot capture interactions unless you engineer them |
| Decision trees | Readable rules, no scaling needed | Overfit easily when deep |
| Random forest / gradient boosting (XGBoost, LightGBM) | Best all-round accuracy on tabular data, handle mixed types and missing values | Less interpretable; needs tuning; slower to serve than linear |
| k-NN, SVM | Simple, good on small data | Do not scale to millions of rows; sensitive to feature scaling |
| Neural networks | Necessary for images, audio, text and very large data | Data-hungry, costly, harder to explain and debug |
The accuracy vs interpretability tension is real: regulated domains (credit, healthcare, hiring) often need to explain each decision, which favours simpler models or post-hoc tools like SHAP values and monotonic constraints. I would rather ship a slightly less accurate model that stakeholders can audit than a black box nobody trusts. Always state the assumption that drove the choice.
Follow-up: Your gradient-boosting model beats logistic regression by 0.5% AUC. Do you ship it? What else do you weigh?
Sources and further reading
- Google: Machine Learning Crash Course
- scikit-learn: model evaluation and cross-validation
- AI Engineering interview questions (Outcome School, Apache-2.0)
- GeeksforGeeks: Artificial Intelligence interview questions
