AIInterviewTraining logoAIInterview/Training

long context

AI, ML & GenAI interview questions tagged long context, across every topic.

18 questions · 1 unlocked for you

Concepts behind "long context"

The curriculum that explains the ideas these questions test.

Foundational
🧠 Foundations of LLMs & GenAI
The Context WindowThe context window is the largest number of tokens a model can attend to at once, prompt plus generation. It is capped by attention's quadratic cost, the KV cache's linear memory growth, and the length the model trained on. A bigger window is neither free nor uniformly useful (models lose information in the middle), which is why retrieval often beats cramming everything into context. AI, ML, and GenAI engineer interviews probe it because it drives cost, latency, and the RAG-vs-long-context decision.
Core
🧠 Foundations of LLMs & GenAISign in
Positional Encodings (RoPE and ALiBi)Attention is order-blind, so models inject token position separately. Modern LLMs rely on relative schemes: RoPE rotates query/key vectors by an angle proportional to position so the attention score hinges only on the offset between tokens, and ALiBi adds a distance penalty to attention scores. Both extrapolate to longer sequences far better than learned absolute positions, which is why RoPE-with-scaling is how context windows get extended. AI, ML, and GenAI engineer interviews probe it because it explains how long-context models are built.
Core
🧠 Foundations of LLMs & GenAISign in
Context Rot and Long-Context Failure ModesContext rot is the practical degradation of model quality as the input window fills up, even when the official window is a million tokens. Information in the middle gets ignored, attention concentrates on the first and last tokens, and reasoning that needs several scattered facts at once falls apart. AI, ML, and GenAI interviews probe it because candidates routinely assume a large window is a substitute for retrieval, and it is not.
Core
🤖 Retrieval & AgentsSign in
Retrieval vs Long ContextIf a whole document fits in a model's large context window, should you paste it, or retrieve only the relevant chunks? Long context is simpler but costly (quadratic attention), slower, and used unevenly (lost in the middle); retrieval is cheaper, faster, refreshes without retraining, and surfaces only what matters. The usual answer is retrieval for large, changing, or partially-relevant corpora, and long context for small, cohesive inputs. AI, ML, and GenAI engineer interviews test it because 'just use the big context window' is a common, costly oversimplification.
Core
🖥️ ML Infrastructure & ServingSign in
FlashAttention and IO-Aware KernelsNaive attention is slow not because of the matmuls but because it writes the full N-by-N attention matrix out to GPU high-bandwidth memory and reads it back, making it memory-bandwidth bound. FlashAttention merges the entire attention computation into one kernel that tiles the inputs in fast on-chip SRAM and never materializes the full matrix, relying on an online-softmax trick to remain exact. AI, ML, and GenAI engineer interviews probe it because it is what made long-context training and serving affordable and a clean test of GPU memory-hierarchy reasoning.