Hierarchical Softmax › The Training Objective
Language AI HandbookAll chapters Hierarchical Softmax › The Training ObjectiveOne section · Sections in this chapter6 / 16 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
The hierarchical softmax objective follows directly from maximum likelihood. We want to maximize the probability of the observed (center, context) pairs in the training corpus. Taking the log converts products into sums, which is numerically more stable and mathematically easier to differentiate:
where:
- : the center word
- : the observed context word
- : the input embedding of center word
- : computed as the product of path probabilities
Substituting the path probability formula and applying the logarithm:
where:
- : log-probability of context word
- : direction code at step along the path to
- : the learned node vector at step
The product of probabilities becomes a sum of log-probabilities, which eliminates the risk of underflow for long paths. Converting the maximization to minimization (for gradient descent), we minimize the negative log-likelihood:
This loss has a pleasant interpretation that makes the training dynamics intuitive. Each term is the binary cross-entropy loss for a single binary classifier at node . The "correct label" at each node is determined by the direction : if we should go left, the correct output is , which corresponds to a positive dot product. If we should go right, the correct output is , corresponding to a negative dot product. The loss penalizes the model whenever any of these binary classifiers makes a wrong or uncertain decision.
Training pushes the model to make each binary decision more confidently correct. Concretely, for each node on the path to the target word, the node vector and the context embedding are adjusted so that their dot product has the correct sign and magnitude. After sufficient training, the model should be able to traverse the tree decisively, assigning high probability to each correct turn and arriving at the target leaf with high confidence.