Example

Example of Input Embedding Composition for a Sentence Pair

To demonstrate the composition of embeddings for a sentence pair (e.g., 'It is raining.' and 'I need an umbrella.'), each token receives three vectors: a token embedding (x\mathbf{x}), a positional embedding (epos\mathbf{e}_{\mathrm{pos}}), and a segment embedding (eseg\mathbf{e}_{\mathrm{seg}}). The segment embedding assigns eA\mathbf{e}_{A} to tokens of the first sentence and eB\mathbf{e}_{B} to tokens of the second. The structure is as follows:

Token[CLS]Itisraining.[SEP]Ineedanumbrella.[SEP]
x\mathbf{x}x0\mathbf{x}_{0}x1\mathbf{x}_{1}x2\mathbf{x}_{2}x3\mathbf{x}_{3}x4\mathbf{x}_{4}x5\mathbf{x}_{5}x6\mathbf{x}_{6}x7\mathbf{x}_{7}x8\mathbf{x}_{8}x9\mathbf{x}_{9}x10\mathbf{x}_{10}x11\mathbf{x}_{11}
epos\mathbf{e}_{\mathrm{pos}}PE(0)\mathrm{PE}(0)PE(1)\mathrm{PE}(1)PE(2)\mathrm{PE}(2)PE(3)\mathrm{PE}(3)PE(4)\mathrm{PE}(4)PE(5)\mathrm{PE}(5)PE(6)\mathrm{PE}(6)PE(7)\mathrm{PE}(7)PE(8)\mathrm{PE}(8)PE(9)\mathrm{PE}(9)PE(10)\mathrm{PE}(10)PE(11)\mathrm{PE}(11)
eseg\mathbf{e}_{\mathrm{seg}}eA\mathbf{e}_{A}eA\mathbf{e}_{A}eA\mathbf{e}_{A}eA\mathbf{e}_{A}eA\mathbf{e}_{A}eA\mathbf{e}_{A}eB\mathbf{e}_{B}eB\mathbf{e}_{B}eB\mathbf{e}_{B}eB\mathbf{e}_{B}eB\mathbf{e}_{B}eB\mathbf{e}_{B}
Image 0

0

1

Updated 2026-05-02

Contributors are:

Who are from:

Tags

Ch.1 Pre-training - Foundations of Large Language Models

Foundations of Large Language Models

Foundations of Large Language Models Course

Computing Sciences

Related