AI & ML Fundamentals Interview Questions
Core concepts every AI interview opens with — AI vs ML vs GenAI, training vs inference, overfitting.
What is the difference between AI, machine learning and generative AI?
AI is the broad goal of machines doing tasks that need intelligence. Machine learning is the approach of learning patterns from data instead of hand-written rules. Generative AI is the subset of ML whose models create new content — text, images, code.
Key Points:
- GenAI models are usually ML models trained on huge datasets.
- Not every AI system learns; rule-based systems are AI but not ML.
What is overfitting and how do you prevent it?
Overfitting is when a model memorises training data and fails on new data. Prevent it with more data, regularisation, simpler models, early stopping and a proper validation split.
Key Points:
- Watch the gap between training and validation scores.
- Cross-validation gives a more reliable estimate.
What is the difference between training and inference?
Training adjusts a model's weights from data; inference uses the trained, frozen model to make predictions. Inference cost and latency matter most in production.
Key Points:
- Most LLM app work is inference, not training.
What is the difference between supervised, unsupervised and reinforcement learning?
Supervised learning trains on labelled examples (input → correct output), like spam vs not-spam. Unsupervised learning finds structure in unlabelled data, like clustering customers. Reinforcement learning learns by trial and error, taking actions in an environment and maximising a reward signal.
Key Points:
- Supervised = classification and regression; unsupervised = clustering and dimensionality reduction.
- RL powers game-playing agents and is used in RLHF to align LLMs.
- Self-supervised learning (predicting hidden parts of the data) is how LLMs are pre-trained.
What is the bias-variance trade-off?
Bias is error from a model that is too simple to capture the pattern (underfitting). Variance is error from a model that is too sensitive to the training data (overfitting). Making a model more complex lowers bias but raises variance, so you look for the point where total error on unseen data is lowest.
Key Points:
- High training and test error → high bias; low training but high test error → high variance.
- Fix bias with more features or a bigger model; fix variance with more data, regularisation or simpler models.
Why do we split data into training, validation and test sets?
The training set fits the model, the validation set is used to tune hyperparameters and choose between models, and the test set is held back until the end to give an honest estimate of real-world performance.
Key Points:
- If you tune on the test set, its score is no longer unbiased.
- Use cross-validation when data is small; use time-based splits for time-series data.
What is a loss function?
A loss function measures how wrong a model's predictions are on the training data as a single number. Training means adjusting the model's parameters to make that number smaller.
Key Points:
- Mean squared error is common for regression; cross-entropy for classification and for LLM next-token prediction.
- The loss you optimise is not always the metric the business cares about — track both.
How does gradient descent work?
Gradient descent computes the gradient of the loss with respect to each parameter (the direction that increases loss fastest) and nudges every parameter a small step in the opposite direction. Repeating this over many batches gradually lowers the loss.
Key Points:
- The learning rate controls step size: too high diverges, too low is slow.
- Stochastic / mini-batch gradient descent uses small batches; optimisers like Adam adapt the step per parameter.
- Backpropagation is the algorithm that computes the gradients efficiently in neural networks.
What is the difference between precision and recall?
Precision is the share of predicted positives that are actually positive (how trustworthy a 'yes' is). Recall is the share of actual positives the model found (how much it misses). Raising the decision threshold usually increases precision and lowers recall.
Key Points:
- Favour recall when misses are costly (fraud, disease screening); favour precision when false alarms are costly.
- F1 score is the harmonic mean of the two; accuracy is misleading on imbalanced data.
What is a neural network?
A neural network is a model made of layers of simple units. Each unit takes a weighted sum of its inputs and passes it through a non-linear activation function. Stacking many layers lets the network learn complex patterns, with the weights learned through training.
Key Points:
- 'Deep learning' just means neural networks with many layers.
- Non-linear activations (like ReLU) are what let networks model more than straight lines.
- Transformers, the architecture behind LLMs, are a type of neural network.
What are embeddings?
An embedding is a list of numbers (a vector) that represents a piece of data — a word, sentence, image or user — so that similar items end up close together in that vector space. Models learn embeddings so meaning can be compared with simple maths like cosine similarity.
Key Points:
- Embeddings power semantic search, recommendations, clustering and RAG.
- Text embeddings from the same model are comparable; embeddings from different models are not.
What is transfer learning?
Transfer learning reuses a model trained on a large general task as the starting point for a new, related task. Instead of training from scratch, you fine-tune the pre-trained model (or just its last layers) on a smaller task-specific dataset.
Key Points:
- It saves data, compute and time — the basis of how foundation models are used.
- Works best when the source and target tasks share underlying patterns.
What is data leakage and how do you spot it?
Data leakage happens when information that would not be available at prediction time sneaks into training — for example a feature derived from the target, or test rows duplicated in training. The model looks great in evaluation and then fails in production.
Key Points:
- Red flag: validation scores that seem too good to be true.
- Split before any preprocessing (scaling, imputation) and fit transforms on training data only.
- For time-series, never let future data inform past predictions.