Log-Linear RNNs: Towards Recurrent Neural Networks with Flexible Prior Knowledge

Marc Dymetman, Chunyang XiaoarXiv 2016 · OpenReview

Abstract

We introduce LL-RNNs (Log-Linear RNNs), an extension of Recurrent Neural Networks that replaces the standard softmax output layer with a log-linear output layer. This conceptually simple modification offers two primary advantages. First, it combats training data sparsity by modeling words as complex combinations of attributes, allowing the model to generalize to symbols not directly observed in training. Second, it permits the inclusion of flexible prior knowledge through modular features, where the neural network dynamically controls the weights of a log-linear distribution. Experiments in French language modeling using morphological prior knowledge demonstrate a significant decrease in perplexity relative to baseline RNNs, highlighting the complementary strengths of log-linear models and representation learning.

1. Introduction

In the field of Natural Language Processing (NLP), Recurrent Neural Networks (RNNs) are the standard for sequence modeling. However, they typically suffer from a "blind spot": they treat every word in a vocabulary as an isolated "island." If a model has not seen a specific word enough times during training, it cannot easily infer its grammatical or semantic properties. This leads to two major issues: data sparsity, where rare words are poorly modeled, and the "island" problem, where related words (e.g., "running" and "ran") are treated as entirely independent symbols.

Log-Linear RNNs (LL-RNNs) address these challenges by allowing neural networks to treat words as bundles of features—such as gender, number, or part-of-speech—incorporating human-specified prior knowledge directly into the architecture.

2. Methodology

2.1 Standard RNN Baseline

Standard RNNs use a softmax operation to predict the next word. In this architecture, the hidden state $h_t$ is mapped to a vector $a_{\theta,t}$ the size of the vocabulary, and softmax converts these scores into probabilities $p_{\theta,t}$. This approach treats the vocabulary as a set of independent symbols, requiring the model to learn all linguistic relationships from scratch through massive amounts of data.

Standard RNN architecture with a softmax output layer.

2.2 Log-Linear RNNs (LL-RNNs)

The core innovation of the LL-RNN is the replacement of the softmax layer with a Log-Linear output layer. In this framework, the RNN acts as a "controller" that dynamically decides which linguistic features are important at any given moment.

The LL-RNN architecture incorporating feature functions ($\phi$) and background functions ($b$).

As illustrated in Figure 2, the process involves several key components:

  • Feature Functions ($\phi$): Instead of predicting a word ID, the RNN predicts weights for specific features (e.g., "is a noun," "is plural").
  • Background Function ($b$): The model includes a "prior" distribution, which could be a simple unigram frequency count or a complex grammar that constrains the output space.
  • Log-Linear Equation: The probability of a word is determined by the background function multiplied by the exponentiated weighted sum of its features.

This design allows for generalization through overlap. Because features like "is feminine" are shared across many words, the model can learn the behavior of a category and apply it to rare or previously unseen symbols.

3. Experiments and Results

The authors evaluated the LL-RNN on a French language modeling task using the Universal Dependencies (French) corpus, which contains approximately 463,069 tokens. They extracted 52 morphological tags (e.g., Gender, Tense, Mood) to serve as prior knowledge features.

The LL-RNN significantly outperformed the baseline RNN:

  • Perplexity Reduction: The baseline RNN achieved a log-perplexity of 6.07. The best LL-RNN model (using 2,500 frequent word features plus morphological tags) dropped this to 5.08.
  • Impact: This represents a reduction in perplexity by a factor of roughly 2.7 (from 433 down to 161).
  • Qualitative Improvement: Analysis showed that the LL-RNN was notably better at maintaining gender and number agreement over long distances compared to the baseline.

4. Discussion and Conclusion

LL-RNNs provide a robust framework for combining the representation learning capabilities of neural networks with the structured prior knowledge of log-linear models. While the computational cost of calculating the partition function for large vocabularies remains a challenge, the model's ability to handle data sparsity and incorporate linguistic rules makes it a promising direction for low-resource or highly inflected languages. Future work may involve scaling these models using hierarchical softmax or integrating automated background functions from pre-trained n-gram models.

Summary updated

Abstract

We introduce LL-RNNs (Log-Linear RNNs), an extension of Recurrent Neural Networks that replaces the softmax output layer by a log-linear output layer, of which the softmax is a special case. This conceptually simple move has two main advantages. First, it allows the learner to combat training data sparsity by allowing it to model words (or more generally, output symbols) as complex combinations of attributes without requiring that each combination is directly observed in the training data (as the softmax does). Second, it permits the inclusion of flexible prior knowledge in the form of a priori specified modular features, where the neural network component learns to dynamically control the weights of a log-linear distribution exploiting these features. We conduct experiments in the domain of language modelling of French, that exploit morphological prior knowledge and show an important decrease in perplexity relative to a baseline RNN. We provide other motivating iillustrations, and finally argue that the log-linear and the neural-network components contribute complementary strengths to the LL-RNN: the LL aspect allows the model to incorporate rich prior knowledge, while the NN aspect, according to the "representation learning" paradigm, allows the model to discover novel combination of characteristics.
BibTeX
@misc{dymetman2016log,
  author = {Marc Dymetman and Chunyang Xiao},
  title = {{Log-Linear RNNs: Towards Recurrent Neural Networks with Flexible Prior Knowledge}},
  year = {2016},
  eprint = {1607.02467},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1607.02467},
}
Figure