|
|
||
|
This interactive tutorial visualizes word embeddings in 2D using Principal Component Analysis (PCA). Word embeddings are high-dimensional vectors (512D from the Universal Sentence Encoder) that capture semantic meaning; similar words sit close in vector space. PCA reduces 512D to 2D so we can see semantic clusters and explore vector analogies (e.g., King - Man + Woman ≈ Queen). Pipeline: Enter words (comma-separated); USE produces 512D vectors. You can either Run PCA Projection (2D or 3D) or Manual projection onto chosen axes (0–511). A grid canvas shows points with hover tooltips. The Vector Analogy panel computes A - B + C in 512D, projects into the same space (PCA or manual), and highlights the nearest word (cosine similarity). Mathematical modelEmbeddings: Each word is mapped to 512D by the Universal Sentence Encoder. PCA via SVD: Center X to X_c, then SVD: X_c = U S V^T. Project to 2D/3D: Y = X_c × V[:, 0:k]. Same mean and V are used to project the analogy vector. Manual projection: Pick axis indices (0–511); each point is [vec[axis0], vec[axis1]] or [vec[axis0], vec[axis1], vec[axis2]]. Vector analogy: result_vec = embed(A) - embed(B) + embed(C); project with stored PCA or manual axes; nearest word in list (cosine similarity) is shown and highlighted.
Input words (comma separated):
Preset:
PCA:
Status: Waiting for model...
Manual:
Axis:
Initializing AI models...
If this hangs, open this page via http (e.g. local server), not file://. Vector Analogy (A - B + C)Explore semantic relationships (e.g. King - Man + Woman ≈ Queen)
Analogy preset:
-
+
Result ≈ --
The arrow from B to A represents a "direction" in meaning; adding it to C often points toward the analogous word. PCA or manual projection puts the 512D result into this 2D/3D view.
512D word vectors (before PCA)
Usage ExampleFollow these steps to explore word embeddings and PCA:
Parameters
Controls and Visualizations
Key Concepts
|
||