NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

An Empirical Evaluation of Rule Extraction from Recurrent Neural Networks

Qinglong Wang, Kaixuan Zhang, Alexander G. Ororbia Ii, Xinyu Xing, Xue Liu, C. Lee Giles

TL;DR

This paper explores extracting understandable rules (in the form of Deterministic Finite Automata - DFAs) from complex, "black-box" Recurrent Neural Networks (RNNs). They demonstrate that these extracted rules can be reliably obtained and, surprisingly, sometimes even outperform the original RNNs in recognizing patterns, offering a path to more interpretable and potentially more robust sequence processing models.

What Problem Does This Paper Address?

Modern machine learning models, especially Recurrent Neural Networks (RNNs), achieve impressive performance on tasks involving sequential data (like text or time series). However, their internal workings are often opaque, making it difficult to understand why they make certain predictions. This lack of interpretability is a major hurdle in critical applications like credit scoring or medical diagnosis, where model validation and understanding are paramount. Extracting symbolic rules from these "black-box" models is a challenging problem, particularly for complex, recursive models like RNNs. This paper aims to address this by investigating the feasibility and effectiveness of extracting rules from second-order RNNs.

Methods

The core of this work revolves around extracting Deterministic Finite Automata (DFAs) from trained second-order RNNs. The general process involves:

  1. Collecting Hidden Activations: The RNN processes input strings, and its internal "hidden layer" activations at each time step are recorded.
  2. Clustering Hidden Activations: These high-dimensional activation vectors are clustered to represent discrete states of a potential DFA. The paper primarily uses k-means clustering for this step, exploring its sensitivity to the number of clusters (K).
  3. Constructing Transition Diagram: Based on the clustered states and the input symbols that caused transitions between them, a transition diagram is built.
  4. Minimizing the DFA: A standard algorithm (like Hopcroft's) is used to reduce the constructed DFA to its minimal form.

The paper also investigates various factors influencing this extraction process, including model capacity (size of the hidden layer), training time, initial conditions of the RNN, and the choice of clustering algorithm and its parameters.

Datasets

The authors use a well-established benchmark for grammar learning: the Tomita grammars. They specifically utilize a set of seven relatively simple regular grammars. For training and testing, they generate strings according to these grammars, treating strings generated by the grammar as positive examples and strings generated by a random oracle (and verified not to belong to the grammar) as negative examples. They create training sets and testing sets with varying string lengths, including a larger test set for evaluating performance on longer sequences.

Key Insights and Ideas

  • Stable Rule Extraction: Despite the inherent complexity of RNNs, the paper demonstrates that symbolic rules (DFAs) can be stably extracted. This suggests that the learned representations within RNNs, even if distributed, can be mapped to discrete states.
  • DFAs Outperforming RNNs: A surprising finding is that in some cases, the extracted DFAs can achieve higher accuracy than the original RNNs, especially when processing longer sequences. This highlights the potential of DFAs for robust long-term dependency handling.
  • Model Capacity vs. Extraction: While higher model capacity in RNNs generally leads to better training and fitting of data, the paper shows that DFA extraction is surprisingly less sensitive to model capacity than one might expect. This implies that even less capable RNNs, if trained sufficiently, can yield extractable rules.
  • Training Time Trade-off: The correct DFA can sometimes be extracted even from RNNs that are not fully trained to 100% accuracy. This suggests that the underlying state space separation, crucial for DFA extraction, can be achieved relatively early in the training process, potentially saving computational effort.
  • Clustering Parameter Sensitivity: The choice of the number of clusters (K) in the k-means algorithm is critical. Too few clusters can lead to poor separation, while too many can introduce noise. However, with well-trained RNNs, the extraction process becomes more flexible with respect to K.

Key Results

  • The paper shows that production rules can be stably extracted from trained second-order RNNs.
  • In certain cases, the extracted DFAs outperform the trained RNNs in recognition accuracy, particularly on longer sequences. For example, on grammar 3, an extracted DFA achieved 100% accuracy on a test set of longer strings, while the RNN struggled.
  • The study found that DFA extraction is relatively insensitive to the initial conditions of the RNN's hidden layer, addressing a concern raised in prior work.
  • Model capacity (hidden layer size) has a strong impact on RNN training convergence but a less pronounced effect on the stability of DFA extraction.
  • The success rate of extracting correct DFAs varied across grammars, with some achieving 100% success and others around 50%.

Limitations and Future Work

  • Ground Truth Assumption: The study relies on having ground truth DFAs for the Tomita grammars to evaluate the extracted ones. This is not always feasible for real-world datasets.
  • "Incorrect" DFA Performance: The paper explores cases where extracted DFAs might not perfectly represent the RNN but still perform well. Further investigation into why these "incorrect" DFAs can be effective is suggested.
  • Real-World Datasets: The authors explicitly state that future work will focus on comparing extracted DFAs and source RNN models on more complex or real-world datasets, such as currency exchange rates, to assess their performance in more challenging scenarios.
  • Exploiting DFA Strengths: The paper suggests that the DFA's natural ability to handle infinitely long sequences is a promising avenue for improving RNNs' long-term dependency capabilities, and future work could explore transfer learning in this area.

Summary updated

BibTeX
@article{wang2018empirical,
  author = {Qinglong Wang and Kaixuan Zhang and Alexander G. Ororbia II and Xinyu Xing and Xue Liu and C. Lee Giles},
  title = {{An Empirical Evaluation of Rule Extraction from Recurrent Neural Networks}},
  journal = {Neural Computation},
  year = {2018},
  url = {https://openreview.net/forum?id=rMVRhWd5CN},
}
Figure