Questions you might face when interviewing for Research Scientist positions. Click to reveal answers, grouped by difficulty.
AI refers to systems that can perform tasks typically requiring human intelligence, such as learning, reasoning, and perception. Unlike traditional software that follows explicit rules, AI systems learn patterns from data and can generalise to new inputs.
Narrow AI (ANI) is designed for a specific task like image classification or language translation. General AI (AGI) would have human-level reasoning across all domains. All current AI systems, including ChatGPT and AlphaGo, are narrow AI. AGI remains a theoretical concept.
AI is the broadest term covering any technique that enables machines to mimic human intelligence. ML is a subset of AI where models learn from data without explicit programming. Deep Learning is a subset of ML using neural networks with multiple layers to learn hierarchical representations.
Supervised learning uses labelled data (e.g., spam detection). Unsupervised learning finds patterns in unlabelled data (e.g., customer segmentation for Indian e-commerce platforms). Reinforcement learning learns via rewards (e.g., training a robot to navigate a warehouse).
The Turing Test, proposed by Alan Turing in 1950, evaluates whether a machine can exhibit behaviour indistinguishable from a human in conversation. While historically significant, modern AI researchers consider it insufficient because a system can pass via tricks without true understanding, and it does not measure reasoning or generalisation.
An LLM is a neural network trained on massive text corpora to predict the next token in a sequence. It generates text autoregressively by sampling from a probability distribution over its vocabulary, one token at a time, using the previously generated tokens as context. Models like GPT-4 and Claude use the Transformer architecture.
A scalar is a single number (0D), a vector is a 1D array of numbers, a matrix is a 2D array, and a tensor is a generalisation to any number of dimensions. Each is a special case of a tensor. In ML, model weights are stored as tensors, and frameworks like PyTorch and NumPy operate on these n-dimensional arrays.
The dot product of two vectors is the sum of their element-wise products, producing a scalar. It measures similarity between vectors. In neural networks, each neuron computes a dot product between its weights and inputs, followed by a bias and activation function. Matrix multiplication, which powers layer computations, is built from dot products.
Gradient descent is an iterative optimisation algorithm that updates parameters in the direction opposite to the gradient of the loss function. The gradient points in the direction of steepest ascent, so moving against it reduces the loss. The learning rate controls step size. Variants include SGD, Adam, and AdaGrad, each handling learning rates differently.
A probability distribution describes how probabilities are assigned to different outcomes. The Gaussian (normal) distribution is bell-shaped, defined by mean and variance, and arises naturally due to the Central Limit Theorem. The Bernoulli distribution models binary outcomes with probability p for success. These are foundational in ML for modelling data and defining loss functions.
Correlation means two variables tend to change together but does not imply one causes the other. Causation requires a direct mechanism. ML models primarily learn correlations, which can lead to spurious predictions when the underlying causal relationship changes. Understanding this distinction is critical for model robustness, fairness, and deployment in high-stakes domains.
A deterministic model always produces the same output for the same input. A stochastic model incorporates randomness and may produce different outputs each time. Most ML training is stochastic (random initialisation, mini-batch sampling, dropout). Stochasticity often helps by preventing overfitting and escaping local minima during optimisation.
AI bias occurs when a model produces systematically unfair outcomes due to biased training data, flawed feature selection, or skewed labelling. This matters because biased models can discriminate against underrepresented groups, especially critical in applications like loan approvals, hiring, and criminal justice.
Parametric models have a fixed number of parameters regardless of data size (e.g., linear regression, logistic regression). Non-parametric models grow in complexity with more data (e.g., k-NN, decision trees). Parametric models are faster but may underfit; non-parametric models are more flexible but can overfit.
Overfitting occurs when a model memorises training data and performs poorly on unseen data, detected by a large gap between training and validation accuracy. Underfitting means the model is too simple to capture patterns, shown by poor performance on both sets. Regularisation, dropout, and cross-validation address overfitting; increasing model complexity or features addresses underfitting.
The bias-variance tradeoff describes the tension between a model's ability to fit training data (low bias) and its ability to generalise to new data (low variance). High bias leads to underfitting while high variance leads to overfitting. The goal is to find the optimal complexity that minimises total error.
Discriminative models learn the decision boundary between classes by modelling P(y|x) directly, such as logistic regression and SVMs. Generative models learn the joint probability P(x,y) or P(x|y) to understand how data is generated, such as Naive Bayes and GANs. Generative models can create new data samples while discriminative models typically cannot.
An activation function determines whether a neuron should fire by applying a transformation to the weighted sum of inputs. Without non-linear activations, a multi-layer network would collapse to a single linear transformation, unable to learn complex patterns. Common non-linear activations include ReLU, sigmoid, and tanh.
Backpropagation is an algorithm that computes the gradient of the loss function with respect to each weight by applying the chain rule layer by layer from output to input. These gradients tell the optimiser how to adjust weights to minimise loss. It makes training deep networks computationally feasible.
Batch gradient descent computes gradients over the entire dataset per update, which is stable but slow. Stochastic gradient descent (SGD) updates weights after each sample, which is noisy but fast. Mini-batch gradient descent is the practical middle ground, computing gradients over small batches (32-512 samples), offering both speed and stability.
Regularisation adds a penalty term to the loss function to prevent overfitting. L1 (Lasso) adds the absolute value of weights, encouraging sparsity and effective feature selection. L2 (Ridge) adds the squared weights, shrinking all weights toward zero without eliminating them. Elastic Net combines both approaches.
The Transformer uses self-attention mechanisms to process all tokens in parallel rather than sequentially like RNNs. This enables better long-range dependency capture and massive parallelisation during training. Key components include multi-head attention, positional encoding, feed-forward layers, and layer normalisation.
Attention computes a weighted sum of Value vectors, where the weights are determined by the compatibility between Query and Key vectors. For each token, Q represents what it is looking for, K represents what it offers, and V represents the actual content. The attention score is computed as softmax(QK^T / sqrt(d_k)) * V.
Multi-head attention runs several attention operations in parallel, each with different learned projection matrices. This allows the model to attend to information from different representation subspaces simultaneously. For example, one head might capture syntactic relationships while another captures semantic ones. The outputs are concatenated and linearly projected.
Since Transformers process all tokens in parallel (unlike RNNs), they have no inherent sense of token order. Positional encodings add information about each token's position in the sequence. The original Transformer used sinusoidal functions, while modern models often use learned positional embeddings or rotary positional embeddings (RoPE).
Encoder-only models like BERT process entire input bidirectionally and are great for classification and embeddings. Decoder-only models like GPT generate text autoregressively using causal masking. Encoder-decoder models like T5 use a full encoder for input understanding and a decoder for generation, excelling at translation and summarisation.
The context window is the maximum number of tokens an LLM can process in a single forward pass. Extending it is challenging because self-attention has O(n^2) computational complexity and memory usage. Techniques like FlashAttention, sparse attention, sliding window attention, and RoPE scaling help extend context windows to 100K+ tokens.
Causal language modelling (used by GPT) predicts the next token using only previous tokens, enforced by a causal attention mask. Masked language modelling (used by BERT) randomly masks tokens and predicts them using bidirectional context. Causal LM is suited for generation, while masked LM is better for understanding tasks.
Cross-entropy loss measures the average negative log probability of correct tokens. Perplexity is the exponential of cross-entropy and represents the effective number of equally probable token choices the model considers. Lower perplexity indicates better prediction. Perplexity is more interpretable but both metrics are mathematically equivalent for comparison.
Key risks include generating harmful content, producing convincing misinformation, leaking private training data, being manipulated through prompt injection, encoding and amplifying biases, and enabling malicious uses like phishing. Mitigations include RLHF alignment, content filtering, red-teaming, and responsible deployment practices.
Vocabulary size determines how text is segmented. Larger vocabularies produce fewer tokens per text (saving context window) but increase embedding layer size and memory usage. Smaller vocabularies are more efficient memory-wise but create longer sequences. Typical sizes range from 32K to 128K tokens. Multilingual models need larger vocabularies to cover diverse scripts.
PyTorch uses eager execution by default, making it intuitive for debugging and research with a Pythonic API. TensorFlow uses graph-based execution for better production optimisation and has a more mature serving ecosystem (TF Serving, TFLite). PyTorch dominates research and is increasingly popular in production; TensorFlow is still strong in mobile and edge deployment.
__init__ defines the layers and parameters of the module. forward defines the computation graph for the forward pass. __call__ is inherited from nn.Module and wraps forward with additional logic like hooks and autograd tracking. You should always call the module directly (model(x)) rather than model.forward(x) to ensure hooks execute properly.
Eigenvectors of a matrix are vectors whose direction remains unchanged when multiplied by that matrix; eigenvalues are the scaling factors. In ML, they are central to PCA for dimensionality reduction, spectral clustering, understanding covariance structures, and analysing the stability of dynamical systems and recurrent networks.
The chain rule states that the derivative of a composite function f(g(x)) is f'(g(x)) * g'(x). In backpropagation, each layer in a neural network is a composed function, and the chain rule enables computing how the loss changes with respect to each parameter by multiplying local gradients along the computation path.
Bayes' theorem states P(A|B) = P(B|A) * P(A) / P(B), relating posterior probability to likelihood, prior, and evidence. In ML, Naive Bayes classifiers use it for text classification. Bayesian inference updates beliefs about model parameters as new data arrives. It is also fundamental to probabilistic graphical models and Bayesian neural networks.
PCA finds the directions (principal components) of maximum variance in the data by computing the eigenvectors of the covariance matrix. Data is projected onto the top-k eigenvectors to reduce dimensionality while preserving the most variance. Mathematically, it is equivalent to SVD of the centered data matrix. It assumes linear relationships between features.
The L1 norm is the sum of absolute values of vector elements, while the L2 norm is the square root of the sum of squared elements. L1 regularisation (Lasso) promotes sparsity by driving weights to exactly zero, useful for feature selection. L2 regularisation (Ridge) distributes penalty evenly, shrinking all weights. L1 has diamond-shaped constraint regions; L2 has circular ones.
Cross-entropy loss measures the difference between predicted probability distribution and true distribution: -sum(y_i * log(p_i)). It is preferred over MSE for classification because it penalises confident wrong predictions heavily, has better gradient properties (avoids saturation with sigmoid/softmax), and is derived from maximum likelihood estimation for categorical distributions.
In CNNs, convolution slides a learnable kernel (filter) across the input, computing element-wise multiplication and summing at each position. Technically it is cross-correlation (no kernel flip). For a 2D input, output[i,j] = sum(input[i+m, j+n] * kernel[m,n]). This operation extracts local features like edges, textures, and patterns while sharing parameters across spatial positions.
Adam maintains two exponential moving averages: first moment (mean of gradients, like momentum) and second moment (mean of squared gradients, like RMSProp). It adapts per-parameter learning rates using these estimates with bias correction. The update rule is: theta -= lr * m_hat / (sqrt(v_hat) + epsilon). This combination makes it robust across different architectures.
The CLT states that the mean of many independent random variables tends toward a normal distribution, regardless of the original distribution. In ML, this justifies using Gaussian assumptions in many models, underpins statistical testing of model performance, explains why batch normalisation works, and is why many natural phenomena are approximately normally distributed.
As dimensions increase, data becomes increasingly sparse, and distance metrics become less meaningful because points tend to be equidistant. This makes nearest-neighbour methods ineffective, increases the data needed for reliable estimation exponentially, and complicates optimisation. Dimensionality reduction techniques like PCA, t-SNE, or autoencoders help mitigate this problem.
Batch normalisation normalises each layer's inputs to zero mean and unit variance across the mini-batch, then applies learnable scale and shift parameters. Mathematically, it reduces internal covariate shift, smooths the loss landscape, and allows higher learning rates. It acts as a regulariser due to the noise introduced by per-batch statistics.
The learning rate determines the step size in gradient descent: theta_new = theta_old - lr * gradient. Too high a learning rate causes oscillation or divergence (overshooting minima). Too low makes training prohibitively slow and can get stuck in poor local minima. The optimal learning rate depends on the loss curvature, which varies throughout training.
Single-agent systems use one LLM to handle all reasoning and actions. Multi-agent systems use multiple specialised agents that collaborate, each with different roles, tools, or expertise. Multi-agent systems handle complex tasks better through division of labour but add coordination complexity. Examples include manager-worker patterns, debate systems, and assembly line pipelines.
Planning is how agents decompose complex goals into executable steps. Approaches include: task decomposition (breaking into sub-tasks upfront), iterative planning (plan one step at a time based on observations), hierarchical planning (plans at multiple abstraction levels), and plan-and-execute (generate full plan, then execute with replanning on failure). Choice depends on task predictability.
Full fine-tuning updates all model parameters, requiring significant GPU memory and risking catastrophic forgetting. PEFT methods like LoRA, QLoRA, and adapters only modify a small subset of parameters, reducing compute and memory needs by 10-100x while achieving comparable performance. PEFT is preferred for most practical use cases due to its efficiency.
LoRA freezes the pre-trained weights and injects trainable low-rank decomposition matrices into each layer. Instead of updating a full weight matrix W (d x d), it learns two smaller matrices A (d x r) and B (r x d) where r is much smaller than d. This reduces trainable parameters by 100-1000x while maintaining performance. Multiple LoRA adapters can be swapped for different tasks.
Catastrophic forgetting occurs when fine-tuning causes the model to lose previously learned general capabilities. Prevent it by using a low learning rate, keeping training epochs low, mixing in general-purpose data, using PEFT methods like LoRA which preserve base weights, applying elastic weight consolidation, and validating on both the target task and general benchmarks.
SFT trains the model to mimic demonstration data by minimising the difference between its outputs and the training examples. RLHF adds a preference optimisation step where a reward model learns human preferences and the LLM is optimised to maximise that reward using reinforcement learning. SFT teaches what to generate; RLHF teaches what humans prefer among options.
Continual pre-training extends the model's knowledge by training on domain-specific corpora using the same objective as pre-training (next-token prediction on raw text). Fine-tuning adapts the model's behaviour using instruction-response pairs. Continual pre-training adds knowledge; fine-tuning teaches how to use it. For domain adaptation, do continual pre-training first, then instruction fine-tuning.
The learning rate schedule controls how the learning rate changes during training. For fine-tuning, a warmup phase (5-10% of steps) gradually increases from zero to prevent large initial weight updates. Followed by cosine or linear decay to allow fine-grained convergence. The peak learning rate for fine-tuning is typically 10-100x lower than pre-training to preserve learned representations.
Fine-tuning updates model weights (all or a subset) using gradient descent on task data. Prompt tuning learns continuous prompt embeddings prepended to the input while keeping all model weights frozen. Prompt tuning uses far fewer parameters (often under 0.1% of model size) and can store multiple task adaptations cheaply, but generally underperforms LoRA for complex tasks.
LLM-as-judge uses a powerful LLM to evaluate the quality of another model's outputs by scoring or comparing responses. It scales better than human evaluation and correlates well with human judgments for many criteria. Limitations include self-preference bias, inconsistency across runs, sensitivity to evaluation prompt phrasing, and inability to catch factual errors without ground truth.
Intrinsic evaluation measures the model's core capabilities in isolation using task-specific benchmarks (perplexity, BLEU, accuracy). Extrinsic evaluation measures how the model performs in the end application, affecting real-world outcomes (user satisfaction, task completion rate, business metrics). A model with better intrinsic scores may not always lead to better extrinsic performance.
MMLU (Massive Multitask Language Understanding) evaluates LLMs across 57 subjects from STEM, humanities, and social sciences at varying difficulty levels. It measures a model's breadth of knowledge and reasoning through multiple-choice questions. While widely used for model comparison, it has limitations including potential training data contamination and not measuring generation quality.
Pointwise evaluation scores each response independently on a scale (e.g., 1-5 for quality). Pairwise evaluation compares two responses and selects the better one. Pairwise is easier for human evaluators and LLM judges (comparing is easier than absolute scoring) but requires more evaluations to rank many models. Pairwise is preferred for model comparison; pointwise for tracking absolute quality.
Red teaming involves deliberately trying to make AI systems fail or produce harmful outputs through creative adversarial inputs. This includes prompt injection attempts, jailbreaking, edge case exploitation, and bias probing. It uncovers vulnerabilities that standard testing misses. Effective red teaming requires diverse evaluators with different backgrounds and perspectives to cover a wide attack surface.
Data contamination occurs when evaluation benchmark data appears in a model's training data, inflating performance scores without reflecting true capability. It is a major problem because contaminated benchmarks give misleading comparisons. Detect it by checking for memorisation of test examples, using held-out data created after training cutoff, and implementing novel evaluation tasks.
BLEU only measures n-gram overlap and misses semantic quality. Better approaches include BERTScore (embedding similarity), METEOR (semantic matching with synonyms), human evaluation along dimensions like fluency, coherence, and relevance, LLM-as-judge scoring, and task-specific metrics. For summarisation, use ROUGE and factual consistency checks. Combine multiple metrics for a comprehensive view.
The Elo rating system, adapted from chess, assigns models a rating based on head-to-head comparisons. Chatbot Arena shows users two anonymous model responses and collects preferences. Models gain or lose rating points based on wins and losses against opponents of known strength. This crowdsourced approach provides robust rankings that account for human preferences and reduces individual evaluator bias.
A model card documents the model's intended use, training data, evaluation results across subgroups, limitations, and ethical considerations. Include performance metrics disaggregated by demographic groups. Document known failure modes and biases. Specify the evaluation methodology and datasets used. Include environmental impact of training. Follow templates from Google or Hugging Face for consistency.
Use PyTorch's DistributedDataParallel (DDP) with NCCL backend for inter-GPU communication. Set up process groups with one process per GPU. Use DistributedSampler for data partitioning. Launch with torchrun specifying nproc_per_node. Enable mixed precision with AMP. Ensure batch size is per-GPU and adjust learning rate for effective global batch size. Profile to verify GPU utilisation.
Generative Adversarial Networks consist of two networks: a generator that creates synthetic data and a discriminator that distinguishes real from fake data. They are trained adversarially, with the generator improving at fooling the discriminator and the discriminator improving at detecting fakes. This process produces increasingly realistic synthetic data.
The vanishing gradient problem occurs when gradients become extremely small as they propagate through many layers, effectively stopping learning in earlier layers. It is addressed by using ReLU activation functions instead of sigmoid/tanh, batch normalisation, residual connections (skip connections), and proper weight initialisation techniques like He or Xavier initialisation.
Reinforcement Learning from Human Feedback trains a reward model on human preferences about response quality, then uses PPO or similar algorithms to fine-tune the LLM to maximise that reward. It aligns model outputs with human values, making responses more helpful, harmless, and honest compared to pure supervised fine-tuning.
Emergent abilities are capabilities that appear only above certain model scale thresholds and are not present in smaller models. Examples include in-context learning, chain-of-thought reasoning, and few-shot arithmetic. These are debated in the research community, with some arguing they may be artefacts of evaluation metrics rather than true phase transitions.
Scaling laws (Kaplan et al., Chinchilla) describe how model performance improves predictably as a power law of model size, dataset size, and compute budget. Chinchilla showed that models should be trained on roughly 20 tokens per parameter for compute-optimal training. These laws help estimate the resources needed for a desired performance level.
FlashAttention is an IO-aware exact attention algorithm that reduces memory reads/writes by tiling the computation and keeping intermediate results in fast SRAM. It achieves 2-4x speedup in wall-clock time and reduces memory usage from O(n^2) to O(n) without approximating the attention computation. It has become standard in modern LLM training and inference.
Speculative decoding uses a smaller draft model to generate candidate tokens quickly, then the larger target model verifies them in a single forward pass. If the draft tokens match what the target would have generated, multiple tokens are accepted at once. This can achieve 2-3x speedup without changing the output distribution.
MoE models contain multiple expert sub-networks and a gating network that routes each token to a subset of experts. Only a fraction of parameters are activated per token, enabling much larger total parameter counts with manageable compute costs. Mixtral 8x7B, for example, has 47B total parameters but only activates 13B per token.
Distillation trains a smaller student model to mimic the outputs of a larger teacher model, resulting in a genuinely smaller architecture. Quantisation keeps the same architecture but reduces the numerical precision of weights. Distillation requires retraining but can achieve better compression ratios; quantisation is faster to apply but limited in compression.
DPO directly optimises the LLM policy using preference pairs without training a separate reward model, simplifying the RLHF pipeline. It reformulates the reward-based objective as a classification loss on preference data. DPO is simpler to implement and more stable but may not perform as well as RLHF with a well-tuned reward model on complex alignment tasks.
Set accumulation_steps to the desired factor. In the loop, divide loss by accumulation_steps before backward(). Call optimizer.step() and optimizer.zero_grad() only every accumulation_steps iterations. This effectively increases batch size without requiring proportionally more GPU memory, useful when training large models on limited hardware.
Mixed precision uses FP16 for most operations and FP32 for numerically sensitive operations, reducing memory usage by nearly half and speeding up training on modern GPUs. In PyTorch, use torch.cuda.amp.autocast() for the forward pass and torch.cuda.amp.GradScaler for gradient scaling to prevent underflow. This typically yields 1.5-2x speedup.
Use torch.nn.parallel.DistributedDataParallel (DDP) for data parallelism. Initialise process groups with torch.distributed.init_process_group. Wrap the model in DDP and use DistributedSampler for the DataLoader. Launch with torchrun or torch.distributed.launch. For model parallelism across GPUs, use pipeline parallelism or tensor parallelism with libraries like DeepSpeed or FSDP.
In convex optimisation, any local minimum is the global minimum, guaranteeing convergence. Neural network loss landscapes are non-convex with many local minima and saddle points. This means gradient descent may get stuck. In practice, research shows that most local minima in high-dimensional spaces have similar loss values, and SGD's noise helps escape saddle points.
The Jacobian is a matrix of all first-order partial derivatives of a vector-valued function. In deep learning, it represents how each output dimension changes with respect to each input dimension. It is used in backpropagation through layers, normalising flows, and analysing the sensitivity of model outputs. The Jacobian determinant measures volume change under transformations.
KL divergence measures how one probability distribution Q differs from a reference distribution P: KL(P||Q) = sum(P(x) * log(P(x)/Q(x))). It is always non-negative and zero only when P=Q. Cross-entropy equals the entropy of P plus the KL divergence from P to Q. Minimising cross-entropy is equivalent to minimising KL divergence when P is fixed.
For binary cross-entropy L = -[y*log(sigma(z)) + (1-y)*log(1-sigma(z))], where sigma is sigmoid. Using the fact that sigma'(z) = sigma(z)(1-sigma(z)), the gradient dL/dz simplifies to sigma(z) - y, which is the predicted probability minus the true label. This elegant simplification is why sigmoid + BCE is commonly used.
SVD decomposes any matrix A into three matrices: A = U * Sigma * V^T, where U and V are orthogonal and Sigma is diagonal with singular values. In ML, it is used for PCA, matrix factorisation in recommendation systems, low-rank approximation for model compression, and latent semantic analysis in NLP.
MLE finds parameter values that maximise the probability of observing the training data. For a classification network with softmax output, maximising the likelihood of correct labels is equivalent to minimising cross-entropy loss. For regression with Gaussian noise, MLE is equivalent to minimising MSE. This probabilistic interpretation connects loss functions to statistical theory.
The Hessian is the matrix of all second-order partial derivatives of the loss function. It captures the curvature of the loss landscape and can inform optimal step sizes. For a network with n parameters, the Hessian has n^2 entries, making it infeasible to compute for large models. Approximations like Fisher information matrix, KFAC, or diagonal Hessian are used instead.
The reparametrisation trick transforms sampling from a learned distribution into a deterministic function of the parameters plus noise: z = mu + sigma * epsilon, where epsilon is from N(0,1). This makes the sampling operation differentiable, enabling backpropagation through the stochastic layer. Without it, VAEs cannot be trained end-to-end with gradient descent.
Self-consistency generates multiple reasoning paths for the same question using sampling (higher temperature) and selects the most common answer via majority voting. It improves reliability on reasoning tasks by reducing the impact of individual reasoning errors. It increases cost proportionally to the number of samples but can significantly boost accuracy on complex tasks.
Tree-of-thought (ToT) explores multiple reasoning branches simultaneously, evaluates partial solutions, and backtracks from unpromising paths. Unlike linear chain-of-thought, ToT considers alternative approaches and self-evaluates. It is particularly useful for complex planning, puzzle-solving, and creative tasks where the first reasoning path may not be optimal.
Constitutional AI uses a set of principles (a constitution) to guide model behaviour through self-critique and revision. The model generates responses, critiques them against the constitution, and revises accordingly. In prompt engineering, similar principles can be embedded in system prompts to create self-correcting behaviour without explicit human feedback on each response.
Meta-prompts are prompts designed to generate or optimise other prompts. You describe the task and constraints to an LLM and ask it to produce an effective prompt. This is useful for rapid prototyping, discovering non-obvious prompting strategies, and automating prompt optimisation. Tools like DSPy automate this meta-prompting process with optimisation algorithms.
Graph RAG combines knowledge graphs with vector-based retrieval. It constructs a graph of entities and relationships from documents, enabling multi-hop reasoning across connected information. When a query arrives, it retrieves both vector-similar chunks and graph-connected entities, providing richer context. It excels at questions requiring reasoning across multiple related documents.
HyDE generates a hypothetical answer to the query using an LLM, then embeds that hypothetical answer to search the vector store instead of embedding the query directly. Since the hypothetical answer is closer in semantic space to actual document chunks than the question is, it often retrieves more relevant results, especially for complex queries.
Define a standardised task suite with varying complexity. Measure success rate, average steps to completion, cost, latency, and error recovery effectiveness. Test on edge cases and adversarial inputs. Compare single-agent vs multi-agent, different LLM backends, and various prompting strategies. Use frameworks like AgentBench or custom evaluation harnesses. Run multiple trials for statistical significance.
Adapter layers insert small bottleneck modules between existing layers of a frozen model. They consist of a down-projection, non-linearity, and up-projection. Compared to LoRA, adapters add sequential computation (slightly increasing latency) while LoRA modifies existing weights in parallel. LoRA has become more popular due to zero additional inference latency and easier merging with base weights.
RLAIF (RL from AI Feedback) replaces human feedback with AI-generated feedback based on a constitution (set of principles). An AI model critiques and revises outputs according to these principles, generating preference data. This preference data trains a reward model or directly optimises the policy. It is more scalable than human feedback while maintaining alignment quality.
Knowledge distillation trains a smaller student model to mimic a larger teacher model's output distributions, not just hard labels. The student learns the teacher's soft probabilities, which contain richer information. It is used to create efficient production models. Combined with fine-tuning, you can distill a large fine-tuned model into a smaller, deployable one with minimal quality loss.
DPO simplifies preference-based fine-tuning by eliminating the need for a separate reward model. It directly optimises the policy model using pairs of preferred and rejected responses. The loss function implicitly defines a reward and trains the model to increase the probability of preferred responses while decreasing rejected ones. It is simpler and more stable than PPO-based RLHF.
Prefix tuning prepends learnable continuous vectors (soft prompts) to the input at each layer while keeping model weights frozen. These prefixes steer the model's behaviour without modifying its parameters. Compared to LoRA, prefix tuning has fewer parameters but slightly higher inference latency due to added prefix tokens. LoRA generally achieves better performance and has become the preferred PEFT method.
Test with adversarial prompts designed to elicit harmful outputs. Evaluate fairness across demographic groups using disaggregated metrics. Test for common biases (gender, caste, regional in Indian context). Use red-teaming with diverse evaluators. Check for PII leakage. Evaluate content safety with toxicity classifiers. Test prompt injection resistance. Document findings in a model card.
Develop task-specific test sets covering major Indian languages (Hindi, Tamil, Telugu, Bengali, etc.). Include code-mixed data (Hinglish, Tanglish). Address script variations and transliterations. Recruit native speaker evaluators for each language. Account for dialectal variations. Create culturally relevant test cases. Measure per-language performance to identify disparities. Share benchmarks with the community.
Data parallelism replicates the model on each GPU and splits data batches. Tensor parallelism splits individual layers across GPUs (each GPU computes part of each layer). Pipeline parallelism splits layers across GPUs in stages. Data parallelism is simplest and scales well. Tensor parallelism is for layers too large for one GPU. Pipeline parallelism handles very deep models. Production systems often combine all three.
DeepSpeed is a deep learning optimisation library from Microsoft that enables training models with billions of parameters. Its ZeRO (Zero Redundancy Optimiser) partitions model states across GPUs to reduce memory per GPU. It supports 3D parallelism (data, tensor, pipeline), mixed precision, gradient checkpointing, and offloading to CPU/NVMe. It can train trillion-parameter models on clusters of GPUs.