NVIDIA GenAI LLM study materials
NVIDIA GenAI LLM study resources

NVIDIA GenAI LLM practice questions

One question at a time. Build your NVIDIA GenAI LLM understanding.

First 50 of 200 questions. Each one lists the choices, the correct answer, and an explanation. The checker at the top of this page saves progress in this browser when it is available.

Continue in the practice tool above to load more questions, 50 at a time.

Question 1Core Machine Learning and AI Knowledge

In scaled dot-product attention, what is the purpose of dividing the query-key dot product by the square root of the key dimension?

  1. It rescales every token embedding to unit length before attention weights are computed.
  2. It shrinks the number of trainable parameters inside each attention head.
  3. It keeps the dot products from growing with key dimension and stabilizes the softmax. Correct answer.
  4. It converts the raw attention scores into a normalized probability distribution.

Explanation

Query and key components are roughly independent with unit variance, so a dot product over d_k dimensions has variance proportional to d_k; large scores saturate the softmax and shrink gradients. Dividing by sqrt(d_k) keeps the score variance near one regardless of head dimension.

Question 2Core Machine Learning and AI Knowledge

Which statement best describes how a byte-pair encoding (BPE) tokenizer constructs its vocabulary?

  1. It splits text on whitespace and gives one identifier to every distinct whole word.
  2. It strips stop words and reduces each remaining term to its linguistic root.
  3. It starts from characters and repeatedly merges the most frequent adjacent pair. Correct answer.
  4. It maps each word to a fixed-size bucket using a rolling hash function.

Explanation

BPE begins with a character-level vocabulary and iteratively merges the most frequent adjacent symbol pair, so common substrings become single tokens. This yields a compact vocabulary that still represents any input through a fallback character sequence.

Question 3Core Machine Learning and AI Knowledge

Which activation function outputs max(0, x), returning zero for negative inputs and the input itself for positive inputs?

  1. Rectified linear unit Correct answer.
  2. Sigmoid
  3. Softmax
  4. Hyperbolic tangent

Explanation

The rectified linear unit is defined as max(0, x), so it clamps negative inputs to zero and passes positive values unchanged. Its constant gradient of one for positive inputs keeps backpropagation simple in deep transformer blocks.

Question 4Core Machine Learning and AI Knowledge

Which loss is the standard objective for training a causal language model to predict the next token?

  1. Mean squared error between predicted and target token identifiers
  2. Contrastive InfoNCE loss between paired sequences
  3. Hinge loss over the vocabulary logits
  4. Categorical cross-entropy over the vocabulary Correct answer.

Explanation

Next-token prediction is a multi-class classification over the vocabulary, so training minimizes cross-entropy between the predicted distribution and the one-hot target token. Perplexity, the exponentiated value of this loss, is what reports then summarize.

Question 5Core Machine Learning and AI Knowledge

A classifier reaches 99% accuracy on its training set but only 62% on a held-out test set. What does this pattern most likely indicate?

  1. The model is overfitting the training data. Correct answer.
  2. The model is underfitting the training data.
  3. The learning rate was set too low.
  4. The test set contains label noise only.

Explanation

A large gap between near-perfect training accuracy and much lower held-out accuracy is the classic signature of a model that has memorized its training examples. The usual remedies are more data or stronger regularization rather than a different loss.

Question 6Core Machine Learning and AI Knowledge

What does an embedding layer produce for a given token identifier?

  1. An integer pointer to the token's position in the corpus
  2. A one-hot vector whose length equals the vocabulary size
  3. A fixed hash code derived from the token string
  4. A dense vector of learned continuous values Correct answer.

Explanation

The embedding layer is a lookup table that maps each integer token id to a trainable dense vector whose values are learned from the training objective. These vectors place tokens in a continuous space where semantically similar tokens end up close together.

Question 7Core Machine Learning and AI Knowledge

Which decoding setting controls output randomness by dividing the logits by a scalar before the softmax?

  1. Beam width
  2. Repetition penalty
  3. Temperature Correct answer.
  4. Top-k cutoff

Explanation

Temperature divides the logits by a scalar before the softmax: values below one sharpen the distribution and values above one flatten it. It therefore controls randomness without changing which tokens are in the vocabulary.

Question 8Core Machine Learning and AI Knowledge

Which floating-point format has 8 exponent bits and 7 mantissa bits, giving a wide dynamic range that suits LLM pretraining?

  1. INT8
  2. FP16
  3. BF16 Correct answer.
  4. FP32

Explanation

BF16 keeps the 8-bit exponent of FP32 but truncates the mantissa to 7 bits, so it represents the same wide range of magnitudes with reduced precision. That wide range avoids the overflow and loss-scaling problems FP16 faces during large-model training.

Question 9Core Machine Learning and AI Knowledge

Why do transformer architectures typically use LayerNorm rather than BatchNorm?

  1. It normalizes each example across its features, so it is independent of batch composition. Correct answer.
  2. It normalizes each feature across the batch dimension, which stabilizes training when batch sizes are large.
  3. It removes the need for residual connections between the attention and feed-forward sub-layers.
  4. It reduces the quadratic cost of self-attention to linear in the sequence length.

Explanation

LayerNorm computes its mean and variance per example across the feature dimension, so the result does not depend on other examples in the batch. That makes it robust to small or variable batch sizes and to the varying sequence lengths seen in training.

Question 10Core Machine Learning and AI Knowledge

During autoregressive inference, what does a key-value cache store?

  1. A compressed copy of the model weights for each generated token
  2. The gradients of the attention projections from the last training step
  3. The attention weight matrix for every head of the current token only
  4. The keys and values of previously processed tokens for each layer Correct answer.

Explanation

Each decoding step needs new queries, while the keys and values of earlier tokens do not change, so caching them avoids recomputing projections for the whole prefix. The cache turns generation from quadratic to roughly linear work per token, at the cost of memory that grows with context length.

Question 11Core Machine Learning and AI Knowledge

In LoRA fine-tuning of a large model, which parameters receive gradient updates?

  1. Only the layer normalization scale and shift parameters
  2. All weights of the attention and feed-forward projections
  3. The embedding table, while every transformer block stays frozen
  4. Two small low-rank matrices that are added to a frozen weight Correct answer.

Explanation

LoRA freezes the pretrained weight W and learns a low-rank update B times A that is added to it, so only A and B receive gradients. Because the rank is small, the number of trainable parameters and optimizer states drops sharply.

Question 12Core Machine Learning and AI Knowledge

A spam filter flags 100 messages, of which 60 are truly spam. The inbox contains 100 spam messages in total. What are the precision and recall?

  1. Precision 0.60 and recall 1.00
  2. Precision 1.00 and recall 0.60
  3. Precision 0.60 and recall 0.60 Correct answer.
  4. Precision 0.40 and recall 0.60

Explanation

Precision is TP/(TP+FP) = 60/100 = 0.60, because 100 messages were flagged and 60 were truly spam. Recall is TP/(TP+FN) = 60/100 = 0.60, because 40 of the 100 spam messages were missed as false negatives.

Question 13Core Machine Learning and AI Knowledge

In RLHF for aligning a language model, what is the purpose of the reward model?

  1. It stores the raw human preference annotations that were used to pretrain the base language model.
  2. It computes the token-level cross-entropy loss that is used during the supervised fine-tuning stage.
  3. It scores candidate responses and supplies the reward signal the policy is optimized against. Correct answer.
  4. It generates the reference responses that later replace the human-written demonstrations in supervised fine-tuning.

Explanation

The reward model is trained on human preference comparisons to output a scalar score for a response. During RL fine-tuning, the policy is updated to raise that score while a KL penalty keeps it close to the supervised model.

Question 14Core Machine Learning and AI Knowledge

Why is positional information required in a transformer encoder?

  1. Because self-attention is permutation invariant, so token order would otherwise be lost. Correct answer.
  2. Because the feed-forward sub-layer processes each position independently.
  3. Because self-attention has far fewer parameters than a recurrent network of the same depth.
  4. Because the softmax in attention cannot handle negative input values.

Explanation

Self-attention compares every token with every other and aggregates values using weights based only on content, so shuffling the input order leaves the output unchanged as a set. Positional encodings inject the order information that the attention mechanism cannot infer on its own.

Question 15Core Machine Learning and AI Knowledge

How does top-p (nucleus) sampling choose the tokens it samples from?

  1. It keeps only the single most likely token at each step of generation.
  2. It keeps every token whose probability exceeds a fixed per-token threshold.
  3. It keeps the k tokens with the highest logits and renormalizes their probabilities.
  4. It keeps the smallest set of tokens whose cumulative probability exceeds p. Correct answer.

Explanation

Nucleus sampling sorts tokens by probability, keeps the smallest prefix whose cumulative mass reaches p, and samples from that renormalized set. The candidate pool therefore shrinks when the model is confident and grows when it is uncertain.

Question 16Core Machine Learning and AI Knowledge

What does the Adam optimizer add beyond plain stochastic gradient descent?

  1. A second-order Hessian approximation computed at every step
  2. Gradient clipping applied before each parameter update
  3. A fixed learning rate schedule that decays as the inverse square root of the step
  4. Per-parameter adaptive step sizes from running first and second moment estimates Correct answer.

Explanation

Adam maintains exponential moving averages of the gradient and of its square, then divides the update by the square root of the second moment. That gives each parameter an adaptive step size, which helps on the ill-conditioned loss surfaces of large networks.

Question 17Core Machine Learning and AI Knowledge

In k-fold cross-validation, which statement about the data splits is correct?

  1. The model is retrained k times on identical training subsets.
  2. Each example is used for validation exactly once across the k iterations. Correct answer.
  3. A single fold is held out permanently and the rest are used for testing.
  4. The same validation split is reused in all k training iterations.

Explanation

The data is partitioned into k folds; each fold serves as validation once while the remaining k-1 folds train the model. Averaging the k scores gives a lower-variance estimate of generalization than a single split.

Question 18Core Machine Learning and AI Knowledge

What is the main benefit of retrieval-augmented generation?

  1. It increases the parameter count of the base model so it can memorize more facts.
  2. It removes the need for a tokenizer when the retrieved passages are long.
  3. It grounds responses in retrieved documents, improving factuality without retraining. Correct answer.
  4. It guarantees that the model cannot produce incorrect statements.

Explanation

A retriever selects passages relevant to the query and the generator conditions on them, so factual content can be refreshed by changing the index rather than the weights. This reduces, though it does not eliminate, unsupported claims.

Question 19Core Machine Learning and AI Knowledge

How does dropout act as a regularizer during training?

  1. It adds a penalty proportional to the squared norm of the weights.
  2. It reduces the learning rate whenever the validation loss stops improving.
  3. It randomly zeroes activations, which discourages co-adaptation of units. Correct answer.
  4. It averages the weights of several independently trained models.

Explanation

Dropout sets a random fraction of activations to zero on each training step, so no unit can rely on a specific partner being present. At inference all units are used, which approximates averaging many thinned subnetworks.

Question 20Core Machine Learning and AI Knowledge

In a sparse mixture-of-experts layer, what does the router network do?

  1. It compresses each expert's weights so the layer fits in memory.
  2. It averages the outputs of all experts with equal weight for every token.
  3. It sorts the batch by sequence length before dispatching tokens to experts.
  4. It selects a small subset of experts to process each token. Correct answer.

Explanation

The router produces a score per expert for each token and dispatches the token to only the top few, so total parameters can be large while per-token compute stays small. Load-balancing terms are usually added so that experts do not collapse onto a handful of tokens.

Question 21Core Machine Learning and AI Knowledge

A language model reports a cross-entropy loss of 2.0 nats per token. What is its perplexity?

  1. About 7.39 Correct answer.
  2. About 100
  3. 2.00
  4. 4.00

Explanation

Perplexity is the exponentiated per-token cross-entropy, so PPL = exp(2.0), which is about 7.39. It can be read as the effective number of equally likely choices the model is torn between at each step.

Question 22Core Machine Learning and AI Knowledge

For a sequence of length n with model dimension d, what are the time and memory costs of standard self-attention?

  1. O(n² · d) time and O(n²) memory Correct answer.
  2. O(d²) time and O(d²) memory, independent of n
  3. O(n · d) time and O(n · d) memory
  4. O(n log n · d) time and O(n · d) memory

Explanation

Every token attends to every other token, so the score matrix has n² entries and each entry is computed with a d-dimensional dot product. The input and output projections add O(n · d²) work, but the attention matrix dominates memory for long sequences.

Question 23Core Machine Learning and AI Knowledge

As model capacity increases on a fixed training set, what usually happens to bias and variance?

  1. Bias increases and variance decreases, so total error stays flat.
  2. Both bias and variance decrease steadily toward zero.
  3. Both stay constant because they depend only on the data distribution.
  4. Bias tends to decrease while variance tends to increase. Correct answer.

Explanation

High-capacity models can fit complex functions, which lowers bias, but the fitted function becomes more sensitive to the particular training sample, which raises variance. Test error is typically minimized at an intermediate capacity.

Question 24Core Machine Learning and AI Knowledge

What is the main trade-off of post-training INT8 weight-only quantization for LLM inference?

  1. It doubles the arithmetic throughput of the GPU but requires retraining from scratch.
  2. It increases weight memory so that fewer requests can be batched together.
  3. It shrinks weight memory and speeds memory-bound decoding, at some cost in quality. Correct answer.
  4. It removes the KV cache, which forces the model to recompute attention at every step.

Explanation

Weight-only INT8 quantization cuts the bytes read per weight, which is the bottleneck for memory-bound token generation, and it lowers storage requirements. The price is dequantization overhead and some accuracy loss from rounding.

Question 25Core Machine Learning and AI Knowledge

What does activation checkpointing trade during training of a deep network?

  1. Fewer optimizer states for a longer convergence schedule
  2. Smaller batch size for a shorter wall-clock time per epoch
  3. Extra forward recomputation during the backward pass for lower activation memory Correct answer.
  4. Lower numerical precision in the forward pass for higher throughput

Explanation

Instead of keeping every intermediate activation for the backward pass, checkpointing stores only a few and recomputes the rest on demand. Memory drops substantially while total compute rises because portions of the forward pass are repeated.

Question 26Core Machine Learning and AI Knowledge

What property does the output of a softmax layer over a set of class logits always have?

  1. The values are non-negative and sum to one. Correct answer.
  2. The values are integers between zero and the number of classes.
  3. The values are all equal to the largest logit.
  4. The values are unbounded and sum to the logit total.

Explanation

Softmax exponentiates each logit and then divides by the sum of those exponentials, which produces a normalized probability distribution. Every entry is therefore non-negative and the entries sum to exactly one.

Question 27Core Machine Learning and AI Knowledge

Why is a validation set used during model development?

  1. To provide the final unbiased estimate reported after training ends.
  2. To supply extra gradient updates that the training set cannot provide.
  3. To tune hyperparameters and compare models without touching the test set. Correct answer.
  4. To store examples that are excluded from all reported metrics.

Explanation

Validation data is held out from parameter updates and used for model selection decisions such as choosing hyperparameters or comparing architectures. The test set stays untouched until the very end so that the final estimate remains unbiased.

Question 28Core Machine Learning and AI Knowledge

A ReLU activation receives the input value -3.5. What does it output?

  1. 1
  2. 0 Correct answer.
  3. 3.5
  4. -3.5

Explanation

The ReLU function is defined as max(0, x), so any negative input is clamped to zero. The magnitude of the negative value is discarded rather than reflected.

Question 29Core Machine Learning and AI Knowledge

In greedy decoding, how is the next token chosen at each step?

  1. By taking the token with the highest predicted probability. Correct answer.
  2. By taking the token with the lowest perplexity in the current prefix.
  3. By selecting uniformly at random among the top ten candidates.
  4. By sampling from the full vocabulary according to the model probabilities.

Explanation

Greedy decoding is deterministic: at every position it selects the argmax of the model's next-token distribution. No randomness is involved, which can make the output repetitive.

Question 30Core Machine Learning and AI Knowledge

Which pattern of training and validation loss indicates overfitting?

  1. Training loss is high and validation loss is equally high.
  2. Both losses rise steadily from the first epoch onward.
  3. Both training and validation loss fall and then plateau together.
  4. Training loss keeps falling while validation loss starts to rise. Correct answer.

Explanation

Overfitting means the model is fitting training-specific noise, so training loss continues to improve while held-out loss worsens. The growing gap between the two curves is the signature of this behavior.

Question 31Core Machine Learning and AI Knowledge

Two embedding vectors are identical and non-zero. What is their cosine similarity?

  1. It depends on their magnitude.
  2. -1
  3. 1 Correct answer.
  4. 0

Explanation

Cosine similarity is the dot product divided by the product of the vector norms. For identical non-zero vectors the numerator equals the product of norms, so the ratio is exactly one regardless of scale.

Question 32Core Machine Learning and AI Knowledge

What is the main purpose of data augmentation in training?

  1. To enlarge the training set with label-preserving variations. Correct answer.
  2. To relabel the training data more accurately.
  3. To guarantee that the test set matches the training distribution.
  4. To reduce the size of the model so it trains faster.

Explanation

Augmentation creates modified copies of training examples whose labels are unchanged, effectively enlarging the dataset. This exposes the model to more variation and typically reduces overfitting.

Question 33Core Machine Learning and AI Knowledge

Why do LLM tokenizers commonly use subword units rather than whole words?

  1. Subword units balance vocabulary size with rare-word coverage. Correct answer.
  2. Subword units guarantee every token maps to exactly one character.
  3. Subword units remove the need for an embedding matrix.
  4. Subword units make the model's attention mechanism quadratic.

Explanation

Subword schemes such as byte-pair encoding keep the vocabulary at a manageable size while still representing rare or unseen words as sequences of smaller pieces. This avoids a huge word-level vocabulary without falling back to an unknown token.

Question 34Core Machine Learning and AI Knowledge

A model trained with L2 regularization is compared with an otherwise identical unregularized model. What is the expected effect of the penalty?

  1. A fixed fraction of weights is set exactly to zero each step.
  2. Weights are pulled toward zero, shrinking model complexity. Correct answer.
  3. The learning rate is reduced automatically near convergence.
  4. Weights are pushed away from zero, increasing model capacity.

Explanation

L2 regularization adds a penalty proportional to the squared norm of the weights to the loss. Its gradient is proportional to the weights themselves, so each update shrinks them slightly toward zero.

Question 35Core Machine Learning and AI Knowledge

In a binary classifier, what does recall measure?

  1. The share of actual negatives that are correctly rejected.
  2. The share of all examples that are classified correctly.
  3. The share of predicted positives that are truly positive.
  4. The share of actual positives that are correctly identified. Correct answer.

Explanation

Recall is true positives divided by the sum of true positives and false negatives, so it measures how much of the positive class was retrieved. A high recall means few positive cases were missed.

Question 36Core Machine Learning and AI Knowledge

Why does scaled dot-product attention divide the dot products by the square root of the key dimension?

  1. To make the attention weights sum to one after the softmax.
  2. To keep the attention output within the range zero to one.
  3. To prevent large dot products from saturating the softmax gradients. Correct answer.
  4. To reduce the number of parameters in the attention layer.

Explanation

For large key dimensions, dot products grow in magnitude, which pushes the softmax into saturated regions where gradients are tiny. Dividing by the square root of the dimension keeps the score variance near one and preserves useful gradients.

Question 37Core Machine Learning and AI Knowledge

What is the main benefit of multi-head attention over a single attention head of the same total dimension?

  1. It guarantees that attention weights are sparse and interpretable.
  2. It lets the model attend to several representation subspaces in parallel. Correct answer.
  3. It reduces the asymptotic cost of attention from quadratic to linear.
  4. It removes the need for positional information in the model.

Explanation

Each head projects queries, keys, and values into its own lower-dimensional subspace, so different heads can capture distinct types of relationships at the same layer. Their outputs are then concatenated and projected.

Question 38Core Machine Learning and AI Knowledge

Why do deep transformers use residual connections around each sublayer?

  1. They increase the number of trainable parameters per layer.
  2. They force all layers to learn identical representations.
  3. They normalize activations to zero mean and unit variance.
  4. They give gradients a short path back to earlier layers. Correct answer.

Explanation

A residual connection lets each sublayer learn an additive update on top of the identity mapping. This shortens the path gradients travel during backpropagation and makes very deep stacks easier to optimize.

Question 39Core Machine Learning and AI Knowledge

Why is a learning-rate warmup schedule used at the start of LLM pretraining?

  1. It avoids large unstable updates while optimizer statistics are unreliable. Correct answer.
  2. It replaces the need for weight decay during early steps.
  3. It guarantees the loss decreases monotonically at every step.
  4. It increases the final learning rate reached at the end of training.

Explanation

Adaptive optimizers estimate second-moment statistics from very few samples in the earliest steps, so those estimates are noisy. Beginning with a small rate and ramping up prevents a single large update from destabilizing training.

Question 40Core Machine Learning and AI Knowledge

What does gradient clipping do during training?

  1. It rescales gradients whose norm exceeds a set maximum. Correct answer.
  2. It zeroes out gradients smaller than a fixed threshold.
  3. It skips updates whose loss exceeds a threshold.
  4. It rounds gradients to the nearest representable float.

Explanation

Clipping caps the norm of the gradient vector at a chosen value, rescaling it when it grows too large. This limits the size of any single update and helps prevent divergence from exploding gradients.

Question 41Core Machine Learning and AI Knowledge

In a decoder-only transformer, what is the purpose of the causal attention mask?

  1. It prevents attention from attending to padding tokens only.
  2. It pads short sequences to a uniform length in the batch.
  3. It randomly drops attention weights as a regularizer.
  4. It stops each position from attending to future tokens. Correct answer.

Explanation

The causal mask sets the attention scores for positions after the current one to negative infinity before the softmax. Each position therefore conditions only on itself and earlier tokens, which preserves the autoregressive factorization used in training.

Question 42Core Machine Learning and AI Knowledge

In sequence-to-sequence training, what is teacher forcing?

  1. Forcing all decoder layers to share the same weights.
  2. Feeding the model its own previous predictions as inputs.
  3. Feeding the ground-truth previous token as the decoder input. Correct answer.
  4. Training the model to imitate a larger model's soft outputs.

Explanation

Teacher forcing supplies the reference prefix to the decoder at each step instead of the model's own prior prediction. Training converges faster and more stably, though it introduces a mismatch between training and inference conditions.

Question 43Core Machine Learning and AI Knowledge

A large pretrained language model is fine-tuned on a small domain corpus. What is catastrophic forgetting?

  1. Gradients vanish in the earliest layers of the transformer.
  2. The model memorizes the small corpus and reports zero training loss.
  3. Performance on the original broad tasks degrades as the model adapts. Correct answer.
  4. The fine-tuning loss fails to decrease because of a high learning rate.

Explanation

Gradient updates during narrow fine-tuning overwrite weights that supported prior capabilities, so general skills can degrade. Techniques such as mixing in general data or parameter-efficient tuning are used to limit this effect.

Question 44Core Machine Learning and AI Knowledge

An analyst normalizes the full dataset with its mean and standard deviation before splitting into train and test. What problem does this create?

  1. The test set becomes larger than the training set.
  2. The model can no longer be trained with gradient descent.
  3. The class labels become unbalanced after the split.
  4. Information from the test set leaks into training preprocessing. Correct answer.

Explanation

Computing statistics over the entire dataset encodes information from the test examples into the preprocessing applied to training data. Evaluation then becomes optimistically biased, so scaling statistics must be fit on the training split only and applied to the test split.

Question 45Core Machine Learning and AI Knowledge

What does chain-of-thought prompting ask a language model to do?

  1. Produce many independent answers and vote among them.
  2. Answer with the single most likely token and no explanation.
  3. Retrieve supporting documents before answering.
  4. Write out intermediate reasoning steps before the final answer. Correct answer.

Explanation

Chain-of-thought prompting elicits intermediate reasoning steps, giving the model more computation before it commits to a final answer. This often improves performance on multi-step arithmetic and logical tasks.

Question 46Core Machine Learning and AI Knowledge

A softmax is computed over logits of roughly 1000. Why do implementations subtract the maximum logit before exponentiating?

  1. It removes the need to divide by the sum of exponentials.
  2. It makes the largest probability exactly equal to one.
  3. It changes the temperature of the distribution.
  4. It avoids overflow without changing the probabilities. Correct answer.

Explanation

Subtracting a constant from every logit cancels in the ratio exp(z_i - c) divided by the sum of exp(z_j - c), so the probabilities are mathematically identical. The largest exponent then becomes exp(0), which keeps the computation within floating-point range.

Question 47Core Machine Learning and AI Knowledge

Why is loss scaling used in mixed-precision training with FP16?

  1. It converts all model weights permanently to FP32.
  2. It keeps small gradients from underflowing to zero in FP16. Correct answer.
  3. It removes the need for a master copy of the weights.
  4. It increases the effective batch size seen by the optimizer.

Explanation

FP16 has a narrow exponent range, so small gradient values can underflow to zero. Multiplying the loss by a large scale factor shifts gradients into representable range, and they are unscaled again before the optimizer step so the update is unchanged.

Question 48Core Machine Learning and AI Knowledge

A ReLU layer with n_in inputs is initialized with zero-mean weights. Which variance keeps activation variance roughly constant across layers, as in He initialization?

  1. 1 / n_in
  2. 1 / n_in squared
  3. 2 / n_in Correct answer.
  4. n_in / 2

Explanation

ReLU zeroes roughly half of its inputs, which halves the variance passing through the layer. Multiplying the base variance 1/n_in by two compensates for this, keeping activation magnitudes stable as depth increases.

Question 49Core Machine Learning and AI Knowledge

In speculative decoding, a small draft model proposes several tokens that a larger target model verifies in one pass. What property does the procedure preserve?

  1. It removes the need for a key-value cache during generation.
  2. It matches the target model's sampling distribution exactly. Correct answer.
  3. It guarantees the draft model's tokens are always accepted.
  4. It reduces the target model's parameter count at inference.

Explanation

Speculative decoding uses a rejection-sampling correction so that accepted and resampled tokens together follow the target model's distribution. Generation is faster when the draft model's proposals are often accepted, but the output distribution is unchanged.

Question 50Core Machine Learning and AI Knowledge

A binary detector is trained on data where positives are 1% of examples. Focal loss is proposed instead of standard cross-entropy. What does focal loss change?

  1. It replaces the sigmoid output with a softmax over classes.
  2. It clips gradients to a fixed maximum norm.
  3. It rebalances the dataset by duplicating minority examples.
  4. It down-weights well-classified examples to focus on hard ones. Correct answer.

Explanation

Focal loss multiplies the cross-entropy of each example by a factor that shrinks as the predicted probability for the true class grows. Easy, confidently classified examples therefore contribute little, and training concentrates on the hard or rare cases.