AI Foundations & Math
The NLP Chronicles Part 4: The Vector Revolution and Word2vec Semantics
English version of AI World
2026. 11. 10. 23:11
반응형
The NLP Chronicles Part 4: The Vector Revolution and Word2vec Semantics
Statistical NLP broke the expert bottleneck by leveraging probability distribution over massive text corpora, but it still treated words as discrete symbols rather than continuous mathematical entities. When deep learning merged with computational linguistics, it triggered a profound mathematical transformation known as the Vector Revolution. This article evaluates the architectural limitations of sparse representations like One-Hot Encoding and details the inner mechanics of Word2vec, demonstrating how continuous vector spaces capture semantic logic and allow computers to calculate meaning.
1. Sparse Representation: One-Hot Encoding and the Curse of Dimensionality
To feed language data into a deep neural network, raw text must be converted into numerical values. The most basic and foundational framework developed for this task is One-Hot Encoding.
The mechanics of One-Hot Encoding are straightforward: a system builds a unique Vocabulary Set (V) containing every individual unique word extracted from a given corpus. The size of this vocabulary determines the exact dimension size of the vector space. For any target word, the system assigns a value of 1 at its unique indexed coordinate position within the vector, while filling all remaining index slots with a value of 0.
To see this operation in action, let us tokenize our foundational target phrase into a sequence of One-Hot Vectors:
Input String Ingestion
text
The autonomous agent determines its role...
One-Hot Encoding Vector Transformation Matrix
Since our target fragment contains exactly five unique morphological tokens, the system constructs a 5-dimensional vector space (\(\mathbb{R}^{5}\)), assigning a discrete spatial coordinate to each token:
text
[ Vocabulary Set (V) Allocation ]
"The" ──► Index 0 ──► [ 1, 0, 0, 0, 0 ]
"autonomous" ──► Index 1 ──► [ 0, 1, 0, 0, 0 ]
"agent" ──► Index 2 ──► [ 0, 0, 1, 0, 0 ]
"determines" ──► Index 3 ──► [ 0, 0, 0, 1, 0 ]
"its" ──► Index 4 ──► [ 0, 0, 0, 0, 1 ]
The Two Fatal Flaws of One-Hot Vectors
While mathematically clean for small samples, One-Hot Encoding suffers from two structural flaws that break real-world industrial pipelines:
- The Curse of Dimensionality (Massive Sparsity): Real-world enterprise corpora contain millions of unique words. Under a One-Hot paradigm, a simple three-word sentence like "the autonomous agent" would require generating a massive matrix where each single word is represented by a 1,000,000-dimensional vector containing one solitary 1 drowned in 999,999 empty 0s. This causes severe computational latency and storage exhaustion.
- Total Loss of Semantic Orthogonality (Zero Meaning): Mathematically, computing the dot product between any two distinct One-Hot vectors always yields exactly zero:
\(\\ \mathbf{v}_{\text{autonomous}}\cdot \mathbf{v}_{\text{agent}}=[0,1,0,0,0]\cdot [0,0,1,0,0]=0\\ \)
Because every vector is perfectly orthogonal (perpendicular) to every other vector in the grid, the computer perceives all words as equally distinct. The system cannot tell that "autonomous" and "agent" share a strong contextual bond, nor can it recognize that "giant" and "huge" mean nearly the same thing.
To bypass this mathematical bottleneck, engineers developed the Bag of Words (BoW) framework, which squashes separate One-Hot vectors into a single, unified phrase vector by summing up word frequencies across a document. While BoW succeeded in compressing sentence arrays into single feature vectors to capture basic document intent, it discarded the spatial sequence order of words entirely, leaving the system blind to syntax and structural flow.
2. Dense Representation: The Dawn of Word2vec
In 2013, a research team led by Tomas Mikolov at Google introduced Word2vec, a revolutionary framework that completely solved the limitations of One-Hot spaces. Word2vec operates on the Distributional Hypothesis, a famous linguistic principle coined by J.R. Firth: "You shall know a word by the company it keeps."
Instead of mapping words to giant, empty sparse vectors, Word2vec projects vocabulary into a compact, Dense Vector Space (Embedding Space), typically restricted to a fixed dimension size between 100 and 300. Every word is represented by an array of continuous, floating-point real numbers (e.g., [0.25, -0.47, 0.81, ...]).
text
One-Hot Space (Discrete Symbol): [ 0, 0, 0, 0, 1, 0, 0, ... 0 ] ──► Dim: 1,000,000 (Empty)
Word2vec Space (Dense Semantic): [ 0.124, -0.581, 0.912, ... ] ──► Dim: 300 (Continuous Meaning)
Through this dense compression, similar words are mapped to neighboring coordinates in the vector space. The framework achieves this by utilizing two alternative, complementary 3-layer artificial neural network designs:
Model A: Continuous Bag of Words (CBOW)
The CBOW architecture optimizes neural network parameters to predict a missing central target word based on its surrounding context words. The system ingests an array of context tokens inside a sliding window, pushes them through a shared hidden projection layer, and outputs the single most statistically probable center token.
text
[ Context Word: "autonomous" ] ──┐
├──► [ Hidden Projection Layer ] ──► [ Predict Center Word: "agent" ]
[ Context Word: "dynamically" ] ──┘
Model B: Skip-Gram
The Skip-Gram model flips the CBOW architecture entirely. It ingests a single central target word and optimizes its internal weights to predict the distributed context words that are most likely to appear around it within the sliding spatial window.
text
┌──► [ Predict Context Word: "autonomous" ]
[ Ingest Center Word: "agent" ] ──┼──► [ Hidden Projection Layer ]
└──► [ Predict Context Word: "dynamically" ]
3. The Power of Distributed Representation: Calculating Meaning
When the neural network completes its training loop over a massive text corpus, engineers discard the final output layer and extract the internal weight parameters of the hidden projection matrix. These optimized weights serve as the Distributed Representation (Word Embedding) for each token.
Because these vectors capture the true contextual behavior of language, they unlock a mind-boggling capability: Vector Arithmetic on Concepts. Because meaning is mapped to continuous numerical coordinates, semantic relationships become calculable via basic geometry:
text
[ High-Dimensional Vector Geometry ]
Vector("King") ──► Vector("Man")
│
+ Vector("Woman")
│
▼
Calculated Result ≈ Vector("Queen")
The mathematical distance between words can now be measured with high precision using Cosine Similarity:
\(\\ \text{Cosine\ Similarity}(\mathbf{A},\mathbf{B})=\frac{\mathbf{A}\cdot \mathbf{B}}{\|{}\mathbf{A}\|{}\|{}\mathbf{B}\|{}}\\ \)
In this dense vector matrix, synonyms score near 1.0, meaning they share nearly identical directional paths in the embedding grid. Antonyms or completely unrelated concepts diverge sharply toward zero or negative scores.
The Stepping Stone to Modern Generative AI
The invention of continuous word embeddings marked a massive leap forward for artificial intelligence. By transforming human language from rigid, cold dictionary strings into fluid, calculable vector spaces, Word2vec provided the exact mathematical framework needed for neural networks to truly digest language.
As these embedding matrices began to scale, they laid the foundation for processing sequential time-series text through recurrent networks, setting the stage for the next major milestone in language intelligence: the integration of auditory perception and 온디바이스(on-device) speech agents.
(Continued in Part 5: Vocal Convergence and Speech Agents)
반응형