[Paper Review] Extracting Automata from Recurrent Neural Networks Using Queries and Counterexamples
The paper presents an exact-learning-based method that uses Angluin's L* algorithm and RNNs as oracle to extract a deterministic finite automaton describing RNN state dynamics, with abstraction to answer equivalence queries.
We present a novel algorithm that uses exact learning and abstraction to extract a deterministic finite automaton describing the state dynamics of a given trained RNN. We do this using Angluin's L* algorithm as a learner and the trained RNN as an oracle. Our technique efficiently extracts accurate automata from trained RNNs, even when the state vectors are large and require fine differentiation.
Motivation & Objective
- Motivate and formalize the problem of extracting a DFA that mirrors the observable behavior of a trained RNN-acceptor over a finite alphabet.
- Propose a general framework combining exact learning (L* algorithm) with finite-state abstractions of RNNs to answer equivalence queries.
- Demonstrate that the method yields small, accurate DFAs and reveals adversarial inputs indicating generalization gaps in RNNs.
Proposed method
- Treat the trained RNN as a teacher for L* by answering membership queries with the RNN's classifications.
- Use finite abstractions A^{R,p} of the RNN state space to answer equivalence queries against the L*-generated DFA A, refining the partition p as needed.
- Refine abstractions via support-vector machine (SVM) based splits to separate R-states and generate new A-states, ensuring refinements are justified by concrete inputs.
- Return counterexamples when classification conflicts arise between the RNN and the current DFA or its abstraction, ensuring correctness of the extracted automaton.
- Leverage shortest counterexamples to keep DFAs compact and improve generalization of the extracted automata.
Experimental results
Research questions
- RQ1Can a DFA be learned to be observably equivalent to a trained RNN-acceptor using exact learning with the RNN as oracle?
- RQ2How can finite abstractions of high-dimensional RNN state spaces be used to answer equivalence queries without sacrificing correctness?
- RQ3Do the extracted DFAs generalize to long sequences, and can the process reveal adversarial inputs or misgeneralizations in the RNN?
- RQ4What refinement strategies (e.g., SVM-based partitioning) best balance DFA size and fidelity to the RNN?
- RQ5How does the proposed method compare to prior quantization or random-sampling approaches in synthesizing compact, accurate automata from RNNs?
Key findings
- The method extracts accurate, often small DFAs from GRU/LSTM networks trained on Tomita grammars and more complex languages within seconds.
- Quantization-based partitioning yields very large, often impractically sized DFAs, while the proposed L* based abstraction method produces compact and accurate automata.
- The approach reveals adversarial inputs and generalization gaps that random sampling can miss, including misclassified counterexamples for seemingly perfect models.
- The extracted DFAs generalize well to long sequences (up to length 1000 in experiments) despite training/test accuracies on par with the networks.
- The framework remains effective across multiple architectures and languages, highlighting robust applicability beyond specific network types.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.