This post is a continuation of Unimodal Representation – Part 1. While the previous post introduced common image representation techniques, this post explores word representation for language and then the evolution of language representation and language models.
Specifically, how individual words in a corpus are represented via the Skip-gram algorithm, how sequences of words are modeled with Recurrent Neural Networks (RNNs), and how the underlying syntax and language structure of a sentence are encoded.
The simplest way to represent a word is a one-hot encoding: a vector with a single $1$ at the word's index in dictionary and zeros everywhere else. This is easy to construct but carries no information about the word's meaning at all.
The distributional hypothesis offers a way to pass this limitation: it assumes a word's meaning can be approximated by the words surrounding it, so that words used in similar contexts will have similar meanings and be close in representation space too.
By building a co-occurrence matrix, where each row records how often that word appears with other words in the corpus, each row can then be treated as the coordinates of that word in a high-dimensional space, turning similarity into a geometric question. Vectors that are "close", measured either by Euclidean distance (after normalizing them to unit length) or by the angle between them, correspond to similar words.

It's one of the two model architectures used in word2vec tool.
Instead of counting co-occurrences for words in the corpus directly, the skip-gram model trains a small network (linear-linear-softmax) that, given a target word, predicts the words surrounding it . This turns a sparse, high-dimensional one-hot vector into a compact, dense vector that actually reflects similarity. Two similar words like "walking" and "running," which share nothing when encoded as one-hot vectors, end up close together when encoded via word2vec.
This works because, while the model is learning word representations, it is also constructing a vector space where words are positioned according to their relationships. Both syntactic and semantic information are encoded in this space, allowing us to perform vector arithmetic on the learned representations.
However, they also encode gender-biases in the training data, such as gender stereotypes tied to specific occupations. For example:
representation(programmer) - representation(man) + representation(woman) is close to representation(homemaker) in the learned vector space.

After training is complete, we can use $W_1$ (shown in the figure above) to obtain word representations.
Recurrent Neural Networks (RNNs) are designed to process sequential data, where the order of words is crucial for the tasks. RNNs maintain a hidden state that updates at every time step as it processes one word after another, letting information from earlier words influence how later words are interpreted.
This structure supports several kinds of predictions: a label at every position (such as part-of-speech tags or per-word sentiment), a single label for the whole sequence, or a prediction of the next word at each position.

The last hidden state of an RNN captures the accumulated context of the entire sequence and can be used as the representation for the input sequence.

To capture contextual information from both sides of a sequence, Bidirectional RNN architecture can be utilized. This approach processes the input sequence in both forward and backward directions to construct combined sequence representations.

Moving beyond isolated words requires modeling the hierarchical structure of full sentences.
By parsing a sentence based on grammar, the sentence can be modeled as a hierarchical tree, grouping words into progressively larger structural constituents.
Instead of grouping phrases, this method maps direct, functional relationships between individual words. For example:

However, human language inherently contains structural ambiguity where individual words can hold ambiguous, multiple syntactic roles depending on the context. Take, for instance, the sentence:
"Salesmen sold the dog biscuits."
A flat reading leaves room for two completely different interpretations:
Tree-based RNNs can be employed to look beyond flat sequences of text, modeling the complex hierarchical structures of languages, which helps grasp the truly intended meaning.

With distributional hypothesis, word representation can be transitioned from massive, sparse one-hot vectors to dense continuous vector spaces.
Recurrent Neural Networks (RNNs) process sequential data by maintaining a hidden state at each timestep, which acts as a built-in memory to retain information from previous inputs in sequential data.
Tree-based RNNs effectively capture the inherent hierarchical structure of natural language by processing tree-structured representations rather than treating sentences as flat sequences of words.