Jump to content

Token embedding (machine learning)

From Wikibase
Revision as of 20:46, 10 November 2026 by Rongzhou (talk | contribs)

Languages: English · français · Esperanto

A visual representation of embedding of sub-word tokens in natural language processing (NLP). · Open in a new tab
Each dimension of an embedding space encodes some semantic meaning. As such, words with similar meanings are spatially adjacent to each other. · Open in a new tab
Since each dimension encodes some semantic meaning, vector addition/subtraction can add/extract meaning to tokens and relate them to other tokens. · Open in a new tab

Let $t_i \in T$ be tokens obtained from tokenisation of raw data.

Let $\mathbb{E}\equiv \mathbb{R}^n$ be a vector space.

Then vector embedding function

$$\begin{gathered} \operatorname{E}: T \to \mathbb{E}\\ \forall t_i \in T: t_i \mapsto \vec{e}_i \end{gathered}$$

$\mathbb{E}$ is then known as the n-dimensional embedding space of $\operatorname{E}$, which contains embedding vectors $\vec e_i$.

Matrix representation

Let $\mathbf{E} \in \mathbb{R}^{|\mathcal{V}| \times n}$ be an vector embedding matrix.

$$ \vec{e}_i = \mathbf{E}[t_i]. $$