Embedding
Embedding: An embedding is a learned numerical vector that represents an item such as a word, sentence, image or product. Models place items in a shared space so that geometric relations can support comparison and retrieval. Training shapes distances and directions according to a task or co-occurrence objective.
In italiano: EmbeddingLegge I · Embedding, feature e spazi vettorialiTraining shapes distances and directions according to a task or co-occurrence objective. Semantically similar items often lie close together, allowing nearest-neighbor search, clustering and retrieval-augmented generation to operate on vectors instead of discrete identifiers.
Formula
cos(u, v) = (u · v) / (‖u‖₂ ‖v‖₂)
Numerical example
import numpy as np
cat = np.array([1.0, 1.0])
dog = np.array([0.9, 1.1])
car = np.array([-1.0, 0.0])
cosine = lambda u, v: np.dot(u, v) / (np.linalg.norm(u) * np.linalg.norm(v))
print(round(cosine(cat, dog), 3)) # 0.997
print(round(cosine(cat, car), 3)) # -0.707When to use it
Use embeddings for semantic search, recommendations, clustering, deduplication and retrieval-augmented generation, or as dense inputs to downstream models.
Limitations
Proximity reflects the training data and objective, not a guarantee of factual or causal similarity. Embeddings can inherit bias, lose fine-grained distinctions and require consistent models and preprocessing across indexed items.
Examples
- Word2Vec for word representation
- Product embeddings for recommendations
- Sentence embeddings for semantic similarity
Autovalutazione
Tre domande per verificare la comprensione della voce. Le spiegazioni restano disponibili anche senza JavaScript.