1. Home
  2. Explore
  3. Computer Science
  4. Transformers and Large Language Models

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Transformers and Large Language Models

  • 70Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: NLP Tasks and Metrics
  • spaceFlip card
  • KI knew it
  • DI didn't know it
  • ←Previous card
  • →Next card

What does NLP stand for, and what does the field study?

Tap to flipClick to flipspace

Natural Language Processing; it concerns computationally manipulating and processing text.

Or swipe the card

70 cards

  1. What does NLP stand for, and what does the field study?

    Natural Language Processing; it concerns computationally manipulating and processing text.

  2. What are the three broad categories of NLP tasks?

    Classification, multi-classification (such as labeling individual tokens), and generation.

  3. What is a classification task in NLP?

    A task that takes text as input and predicts a label or other output category.

  4. What does Named Entity Recognition (NER) do?

    It identifies and labels words or spans in text as entities, such as locations or times.

  5. What characterizes text generation tasks in NLP?

    They take text as input and produce text as output, often with a variable-length output.

  6. What kinds of data are commonly used for sentiment classification?

    Movie reviews, product reviews, and social media posts.

  7. What does classification accuracy measure?

    The proportion of observations that the model predicts correctly.

  8. How do precision and recall differ?

    Precision asks what fraction of predicted positives are correct; recall asks what fraction of actual positives are found.

  9. What does the F1 score summarize?

    It combines precision and recall using their harmonic mean.

  10. Why can accuracy be misleading on an imbalanced dataset?

    A model can predict only the majority class and still achieve high accuracy while failing on the minority class.

  11. At what levels can NER predictions be evaluated?

    At the token level or at the entity-type level.

  12. Why does machine translation evaluation often require paired text data?

    Each source sentence needs a corresponding target-language sentence for comparison or supervision.

  13. What do BLEU and ROUGE measure in text generation evaluation?

    They compare generated text with reference text; BLEU is a translation metric, while ROUGE is a suite of metrics used for text overlap evaluation.

  14. What does perplexity measure, and which direction is better?

    It measures how surprised a model is by text based on its output probabilities; lower perplexity is better.

  15. What is tokenization?

    The process of dividing text into units called tokens.

  16. What is word-level tokenization, and what is one key limitation?

    It treats whole words as tokens; similar word forms, such as “bear” and “bears,” become separate tokens.

  17. What does OOV mean in tokenization?

    Out of Vocabulary: a token encountered at inference that was not included in the training vocabulary.

  18. What is the main advantage of subword tokenization?

    It can represent related word forms using shared word pieces and generally reduces the risk of OOV tokens.

  19. What is a trade-off of subword tokenization?

    It can produce longer token sequences than word-level tokenization.

  20. What is a strength of character-level tokenization?

    It can handle misspellings and casing variations more robustly than word- or subword-level tokenization.

  21. What are two drawbacks of character-level tokenization?

    It produces very long sequences and makes it difficult for individual character representations to capture meaning.

  22. Why does sequence length matter when choosing a tokenizer?

    Longer token sequences generally require more computation and take longer to process.

  23. What vocabulary sizes were described as typical orders of magnitude for tokenizers?

    Tens of thousands of tokens for a single language, and sometimes hundreds of thousands for multilingual or code-capable models.

  24. What is a one-hot encoding of a token?

    A vector with a 1 in the token's vocabulary position and 0s in all other positions.

  25. Why are one-hot vectors poor representations for measuring semantic similarity?

    Different one-hot vectors are orthogonal, so they do not naturally indicate that some tokens are more similar than others.

  26. What does cosine similarity compare between two vectors?

    The angle between them: vectors pointing in similar directions have high similarity, while orthogonal vectors have similarity near zero.

  27. What should a useful token representation encode about similarity?

    Tokens with similar meanings should have high similarity, while unrelated tokens should be less similar.

  28. What was Word2vec designed to learn, and why was it influential?

    It learned meaningful word embeddings from text and offered interpretable relationships between words.

  29. How do Continuous Bag of Words (CBOW) and Skip-gram differ?

    CBOW uses surrounding words to predict a target word; Skip-gram uses a target word to predict surrounding words.

  30. Why are word-prediction objectives in Word2vec called proxy tasks?

    The prediction task is a means to learn useful representations, rather than the ultimate goal itself.

  31. How can a simple neural network learn token embeddings from a next-word prediction task?

    It maps a one-hot input through a smaller hidden layer, predicts the next token, compares the prediction with the target, and updates weights using backpropagation.

  32. After training a simple one-hot-input network, how can its learned token embedding be obtained?

    Use the hidden representation produced by multiplying the token's one-hot vector by the learned input-to-hidden weights.

  33. What is the typical relationship between vocabulary size and embedding dimension?

    The embedding dimension is typically much smaller than the vocabulary size.

  34. What trade-offs influence the choice of embedding dimension?

    A more complex downstream task may benefit from richer embeddings, while smaller dimensions can reduce computation, latency, and cost.

  35. Why might an unknown-token representation be needed?

    It provides a shared representation for tokens that were not recognized in the training vocabulary.

  36. What is a Recurrent Neural Network (RNN)?

    A sequence model that processes tokens one at a time and carries a hidden state summarizing the sequence so far.

  37. What does an RNN hidden state represent?

    A representation of the sequence processed up to the current time step.

  38. How can an RNN use its representation for sentence classification?

    Use the final hidden state and project it into the space of class labels.

  39. How can an RNN support token labeling or text generation?

    For token labeling, use a representation for the token of interest; for generation, use the encoded source sequence to help decode output.

  40. What problem do Long Short-Term Memory networks (LSTMs) aim to address?

    They extend RNNs to help preserve information that is important to remember over a sequence.

  41. What are the hidden state and cell state in an LSTM?

    The hidden state represents the current sequence processing, while the cell state provides an additional pathway for carrying information.

  42. What is the vanishing-gradient problem in recurrent models?

    During backpropagation through time, repeated multiplication by values below 1 can make gradients shrink toward zero.

  43. Why can RNNs struggle with long-range dependencies and slow computation?

    Their sequential processing makes it difficult to retain information from far back, and each step depends on earlier hidden states.

  44. What was the broad progression of key language-modeling developments described in the lecture?

    LSTM models appeared in the 1990s, Word2vec in 2013, attention in 2014, and the Transformer in 2017; later scaling in data and compute helped enable LLMs.

  45. What problem does attention address in sequence models?

    It provides direct links from a prediction to relevant parts of the input, helping address long-range dependency problems.

  46. What is self-attention?

    A mechanism that computes each token's representation using information from other tokens in the same sequence.

  47. How does self-attention help represent a word whose meaning depends on context?

    It gives the word a representation based on its surrounding sequence, so the same spelling can have different representations in different contexts.

  48. What are the query, key, and value in attention?

    The query represents what is being sought; keys are compared with it for relevance; values are the information combined according to those relevance weights.

  49. How does attention use a query to combine information from other tokens?

    It scores the query against keys, turns the scores into weights, and computes a weighted sum of the corresponding values.

  50. Why was the Transformer architecture a major change from RNN-based processing?

    It used attention to connect tokens directly across a sequence instead of relying on sequential recurrent processing.

  51. What are the two main parts of the original Transformer architecture?

    An encoder and a decoder.

  52. What does the Transformer encoder do?

    It creates context-aware representations of the input tokens using self-attention and feedforward layers.

  53. What does masked self-attention do in the Transformer decoder?

    It lets each output position attend only to itself and earlier generated tokens, not future tokens.

  54. What does cross-attention do in a Transformer decoder?

    It lets the decoder use information from the encoded input when generating the output.

  55. What is the role of a feedforward network (FFN) in a Transformer block?

    It further transforms token representations, giving the model additional capacity to learn useful features.

  56. Why does a Transformer need positional information?

    Self-attention alone does not encode the order of tokens, so positional information identifies their positions in the sequence.

  57. How were positional encodings represented in the original Transformer?

    With sine and cosine functions, added element-wise to token embeddings.

  58. What is the shape of the matrix of token embeddings for a sequence?

    It has one dimension for the embedding size, dmodeld_{model}dmodel​, and one for the sequence length, typically nnn.

  59. How are queries, keys, and values created for Transformer self-attention?

    The input embeddings are projected using learned matrices WQW_QWQ​, WKW_KWK​, and WVW_VWV​.

  60. What is the scaled dot-product attention formula?

    softmax⁡(QKTdk)V\operatorname{softmax}\left(\frac{QK^{\mathsf T}}{\sqrt{d_k}}\right)Vsoftmax(dk​​QKT​)V

  61. Why are query–key scores divided by dk\sqrt{d_k}dk​​ in scaled dot-product attention?

    To normalize dot products that can grow with the key and query dimension.

  62. What does one row of the attention weight matrix represent?

    The softmax distribution of one query's scores over the keys.

  63. What is multi-head attention?

    Running attention several times in parallel using different learned query, key, and value projections.

  64. How are the outputs of multiple attention heads combined?

    Their outputs are concatenated and projected back to the model dimension using a learned matrix such as WOW_OWO​.

  65. Why can the Transformer FFN's hidden dimension be larger than its input and output dimensions?

    A larger hidden layer gives the model more capacity and degrees of freedom to learn useful representations.

  66. How are encoder and decoder layers organized in the Transformer?

    They are stacked in sequences of layers; the encoder's final representations are supplied to the decoder's cross-attention.

  67. How does Transformer decoding generate a sequence?

    It starts with a beginning-of-sequence token, predicts one token at a time, and stops when it generates the end-of-sequence token.

  68. How does the Transformer turn its final decoder representation into a next-token prediction?

    A linear projection produces vocabulary scores, and softmax converts them into a probability distribution.

  69. What is label smoothing in next-token prediction?

    A technique that replaces a one-hot target with a softened distribution, assigning most probability to the target and a small amount to other tokens.

  70. For a vocabulary of size vvv, what target distribution does label smoothing use in the described formulation?

    It assigns 1−ϵ1-\epsilon1−ϵ to the target token and ϵv−1\frac{\epsilon}{v-1}v−1ϵ​ to each of the other tokens.

Card 1 of 70
Card 1 of 70

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent