AIInterviewTraining logoAIInterview/Training
🧠 Foundations of LLMs & GenAI
Core

Causal Masking and Teacher Forcing

A causal mask adds a triangular block of large negative values to the attention scores before the softmax, so every position gets exactly zero attention weight on the future. That one trick lets you push a whole sequence through in a single forward pass and compute a loss at every position at once, which is teacher forcing, and it is the reason transformer training parallelizes while RNN training could not. AI, ML, and GenAI engineer interviews probe it because it explains the deepest asymmetry in LLMs: training is parallel over positions and generation is irreducibly serial, which is exactly why the KV cache exists.

a free account unlocks the core curriculum tier · no card
RELATED CONCEPTS
PRACTICE THIS IN REAL QUESTIONS
COMPANIES THAT ASSUME THIS
NEXT IN FOUNDATIONS OF LLMS & GENAILogits, Log-Probs, and Logit Bias