Embedding
An embedding maps a discrete object or structured input into a continuous vector space. Tokens, residues, atoms, graph nodes, and retrieved chunks can all be embedded before model processing.
For a vocabulary item , an embedding lookup is:
where is an embedding table, is vocabulary size, and is embedding dimension.
For token sequences:
where is a positional or structural encoding.
Embeddings are often compared with dot product, cosine similarity, or Euclidean distance, depending on whether magnitude should affect the score.
For a batch of token ids , lookup produces:
An output classifier may tie weights to the input embedding table:
This reduces parameters and keeps input/output token spaces aligned.
Common Embedding Types
- Token embeddings: wordpieces, residues, atoms, k-mers, patches, or graph nodes.
- Positional embeddings: sequence index, relative offset, chain id, or spatial bucket.
- Type embeddings: segment, modality, atom type, residue type, or role.
- Pretrained embeddings: frozen or fine-tuned representations from a larger model.
Embedding quality is not only dimensionality. It also depends on tokenization, normalization, pooling, masking, and whether the downstream metric matches the embedding geometry.
Checks
- What does one token represent: wordpiece, residue, atom, k-mer, patch, or node?
- Are position, chain, segment, atom type, or edge features added separately?
- Is the embedding learned, fixed, pretrained, or tied to the output classifier?
- Does tokenization discard information needed by the task?