🌍 Deep Learning · flashcards

Deep Learning Transformers and Attention Flashcards

58 question-and-answer cards covering Transformers and Attention as it is examined in Deep Learning. 24 of them are printed below, taken from across the deck — no signup, no paywall on the preview.

58Cards in deck
24Free preview
20Syllabus topics
~261Chars per answer
FreePrice

24 sample cards from the Transformers and Attention deck

Sampled from the end of the deck, so these are different cards from the ones shown on the syllabus page.

  1. What is chain-of-thought (CoT) prompting?

    Prompting the model to produce intermediate reasoning steps before the final answer (e.g., 'Let's think step by step'), which substantially improves performance on arithmetic, commonsense, and symbolic reasoning tasks, especially at large scale.

  2. What is the difference between fine-tuning and pretraining?

    Pretraining trains a model from scratch on massive unlabeled data with a self-supervised objective. Fine-tuning takes the pretrained model and further trains it (updating weights) on a smaller labeled or task-specific dataset to specialize it.

  3. What is instruction tuning?

    Fine-tuning a pretrained LLM on a diverse collection of tasks phrased as natural-language instructions with responses, so the model learns to follow instructions and generalizes to unseen instruction-formatted tasks in zero-shot settings.

  4. Describe the three stages of RLHF (Reinforcement Learning from Human Feedback).

    (1) Supervised fine-tuning on demonstration data; (2) train a reward model from human preference rankings of outputs; (3) optimize the policy against the reward model using RL, typically PPO, often with a KL penalty to stay close to the SFT model.

  5. What is DPO (Direct Preference Optimization) and how does it differ from RLHF?

    DPO directly optimizes the policy on preference pairs using a classification-style loss derived from the reward-model objective, eliminating the need to train a separate reward model or run RL/PPO. It is simpler and more stable while targeting the same preference-alignment goal.

  6. What is Parameter-Efficient Fine-Tuning (PEFT) and why is it used?

    PEFT adapts a large pretrained model by training only a small number of new or selected parameters while freezing most of the backbone. It drastically reduces memory, storage, and compute cost, and mitigates catastrophic forgetting, enabling many task-specific adapters per base model.

  7. How does LoRA (Low-Rank Adaptation) work?

    LoRA freezes pretrained weights $W$ and learns a low-rank update $\Delta W = BA$ where $B \in \mathbb{R}^{d \times r}$, $A \in \mathbb{R}^{r \times k}$, and $r \ll d,k$. The forward pass becomes $h = Wx + BAx$, so only $A$ and $B$ are trained, greatly reducing trainable parameters.

  8. What is QLoRA?

    QLoRA fine-tunes with LoRA adapters on top of a base model quantized to 4-bit (NF4), using techniques like double quantization and paged optimizers. It enables fine-tuning very large models on a single GPU with minimal quality loss.

  9. Name three families of PEFT methods besides LoRA.

    Adapter modules (small bottleneck layers inserted between Transformer sublayers), prompt/prefix tuning (learning soft continuous prompt vectors), and (IA)^3 / BitFit (scaling activations or training only bias terms).

  10. What is Retrieval-Augmented Generation (RAG)?

    RAG augments an LLM by retrieving relevant documents from an external knowledge source (often via vector similarity search) and conditioning generation on them, improving factual accuracy, enabling up-to-date knowledge, and reducing hallucination without retraining.

  11. Outline the main steps of a RAG pipeline.

    (1) Chunk and embed a document corpus into a vector store; (2) embed the user query; (3) retrieve top-$k$ similar chunks (e.g., by cosine similarity); (4) insert retrieved context into the prompt; (5) the LLM generates an answer grounded in that context.

  12. How does a Vision Transformer (ViT) adapt Transformers to images?

    ViT splits an image into fixed-size patches (e.g., $16\times16$), linearly embeds each patch into a token, adds positional embeddings and a learnable [class] token, then feeds the sequence into a standard Transformer encoder for classification.

  13. What is a key data requirement of ViTs compared to CNNs?

    ViTs lack the built-in inductive biases (locality, translation equivariance) of CNNs, so they need large-scale pretraining data (e.g., JFT-300M) to match or exceed CNNs; with limited data CNNs often perform better.

  14. What is CLIP and how is it trained?

    CLIP (Contrastive Language-Image Pretraining) jointly trains an image encoder and text encoder on image-caption pairs with a contrastive objective, maximizing cosine similarity of matched image-text embeddings and minimizing it for mismatched pairs within a batch (symmetric InfoNCE loss).

  15. How does CLIP enable zero-shot image classification?

    Class names are turned into text prompts (e.g., 'a photo of a {class}') and encoded; the image embedding is compared by cosine similarity to each class-text embedding, and the highest-similarity class is chosen, with no task-specific training.

  16. What is the contrastive InfoNCE-style loss objective used in contrastive pretraining?

    For a matched pair among $N$ candidates, minimize $$\mathcal{L} = -\log \frac{\exp(\text{sim}(z_i, z_i^{+})/\tau)}{\sum_{j=1}^{N} \exp(\text{sim}(z_i, z_j)/\tau)}$$ where $\tau$ is a temperature and $\text{sim}$ is cosine similarity.

  17. What are common strategies for fusing modalities in multimodal Transformer architectures?

    Early fusion (concatenate modality tokens into one Transformer with cross-modal self-attention), late fusion (separate encoders combined at the end), and cross-attention fusion (one modality attends to another, e.g., Flamingo's gated cross-attention injecting vision into a language model).

  18. How do multimodal LLMs typically connect a vision encoder to a language model?

    A frozen or trained vision encoder (often ViT/CLIP) produces image features that a projection/adapter module (e.g., a linear layer or Q-Former as in BLIP-2, or an MLP as in LLaVA) maps into the LLM's token embedding space so images become 'tokens' the LLM reads.

  19. What problem does FlashAttention solve and how?

    It removes the $O(n^{2})$ memory bottleneck of materializing the full attention matrix. FlashAttention is an IO-aware, exact attention algorithm that tiles $Q$, $K$, $V$ into SRAM blocks and uses online softmax to compute attention without ever writing the $n\times n$ matrix to HBM, giving large speedups and linear memory.

  20. Is FlashAttention an approximation of attention?

    No. FlashAttention computes exact attention (identical outputs to standard attention). Its gains come from reducing memory reads/writes to slow HBM via kernel fusion, tiling, and recomputation in the backward pass, not from approximating the softmax.

  21. What is sparse attention and how does it reduce complexity?

    Sparse attention restricts each token to attend to a subset of positions (e.g., local windows, strided, or global tokens as in Longformer/BigBird) instead of all $n$, reducing complexity from $O(n^{2})$ toward $O(n)$ or $O(n\log n)$ while retaining most modeling power.

  22. How does linear attention achieve $O(n)$ complexity?

    Linear attention replaces the softmax with a kernel feature map $\phi(\cdot)$ so attention becomes $\phi(Q)\big(\phi(K)^{T}V\big)$. By computing $\phi(K)^{T}V$ first (associativity), it avoids the $n\times n$ matrix, giving $O(n\,d^{2})$ time and memory linear in sequence length.

  23. What is Multi-Query Attention (MQA) / Grouped-Query Attention (GQA)?

    MQA shares a single Key/Value head across all Query heads, and GQA shares K/V among groups of query heads. Both shrink the KV cache and speed up autoregressive inference with little quality loss, interpolating between full multi-head (per-head KV) and single-head KV.

  24. Why is the KV cache used during autoregressive generation, and what is its memory cost?

    During generation, previously computed Key and Value vectors are cached so each new token only computes attention against stored K/V instead of recomputing them. Its memory grows linearly with sequence length and number of layers/heads, and often becomes the dominant inference memory cost, motivating MQA/GQA.

What this deck covers

The Transformers and Attention deck follows the Deep Learning Transformers and Attention syllabus — 5 chapters and 20 topics — so questions land on material that is genuinely examinable rather than trivia around it. That works out to roughly 11.6 cards per chapter.

Answers are written to be recallable, not just readable — averaging about 261 characters, which is long enough to carry the reasoning and short enough to say out loud.

A deck like this earns its keep on the second and third pass. Read the syllabus first so you know the shape of the subject, then use the cards to find the specific facts that have not stuck.

Transformers and Attention flashcards FAQ

How many Transformers and Attention flashcards are in this Deep Learning deck?

58 cards. This page previews 24 of them, sampled evenly across the deck so you can judge the difficulty before installing anything.

Are these Deep Learning flashcards free?

Yes. The preview here is free to read with no signup, and the full 58-card deck is free inside the Examius app.

What do the Transformers and Attention cards cover?

They follow the Deep Learning Transformers and Attention syllabus — 5 chapters and 20 topics — so the questions track what is actually examinable.

How should I use these flashcards?

Read the syllabus first so you know the shape of the subject, then drill the deck. Examius schedules each card with spaced repetition, so cards you keep missing come back sooner and ones you know drift further apart.