- Objective: - Breadcrumb: # 概念阐释 在自然语言处理中NLP 中,向量(vector)是用于表示文本的数学工具。通过[[Embedding]]将文本的 token ID转换成可被[[Transformer]]处理的向量。 1. 文本 -> token 2. token -> 整数序列 sequences of integers 3. 整数序列 -> 向量 vector ![](https://image.harryrou.wiki/2024-10-14-CleanShot%202024-10-15%20at%2007.27.15%402x.png) # 实例 左边为三维空间中的坐标点,但是一个词向量的维度可以远高于3 个维度,例如在 GPT-3 中,词向量可以达到 12,288 个维度。 ![](https://image.harryrou.wiki/2024-10-21-CleanShot%202024-10-21%20at%2011.52.04%402x.png) # 相关内容 ## 数学中的向量 $x=2,y=3,z=4$ $\mathbf{a} = \begin{pmatrix} 2 \\ 3 \\ 4 \end{pmatrix}, \quad \mathbf{b} = \begin{pmatrix} 1 \\ 0 \\ -1 \end{pmatrix}$ - 加法 $\mathbf{a} + \mathbf{b} = \begin{pmatrix} 2 \\ 3 \\ 4 \end{pmatrix} + \begin{pmatrix} 1 \\ 0 \\ -1 \end{pmatrix} = \begin{pmatrix} 2+1 \\ 3+0 \\ 4-1 \end{pmatrix} = \begin{pmatrix} 3 \\ 3 \\ 3 \end{pmatrix}$ - 乘法 $\mathbf{a} \cdot \mathbf{b} = 2 \cdot 1 + 3 \cdot 0 + 4 \cdot (-1) = 2 + 0 - 4 = -2 $ # 参考资料 - [3B1B-Chapter 5, Deep Learning - How large language models work, a visual intro to transformers](https://readwise.io/reader/shared/01ja40kj0zhbkgkf4t3rwnfcbq) - [Vectors | Chapter 1, Essence of linear algebra](https://readwise.io/reader/shared/01ja43zbyx478r04dkar21ptst)