DSM: a specification mining tool using recurrent neural network based language model

Tien-Duy B. Le, Lingfeng Bao, David LoESEC/SIGSOFT FSE 2018 · DOI

TL;DR

This paper introduces DSM, a novel tool that leverages deep learning, specifically Recurrent Neural Networks (RNNs), to automatically mine finite-state automaton (FSA) based specifications from software execution traces. By learning patterns in method call sequences, DSM aims to reduce the manual effort and expertise required for software specification, leading to more reliable and maintainable systems.

What Problem Does This Paper Address?

Writing formal specifications for software is crucial for ensuring reliability and maintainability, but it's a time-consuming and skill-intensive task for developers. Furthermore, software systems evolve rapidly, making manually maintained specifications quickly outdated. Existing automated approaches for specification mining, particularly those inferring Finite-State Automata (FSAs) from execution traces, often struggle with complex method call sequences that exhibit frequent but not strictly required co-occurrences. This paper addresses the need for a more robust and automated method to infer accurate FSA-based specifications, especially for scenarios where traditional methods fall short.

Methods

DSM employs a multi-stage approach that integrates deep learning with traditional specification mining techniques:

  • RNNLM Learning: At its core, DSM trains a Recurrent Neural Network Language Model (RNNLM) on a dataset of execution traces (sequences of method calls). The RNNLM learns the probabilistic relationships between method calls, capturing sequential patterns. DSM supports standard RNN, LSTM, and GRU architectures.
  • Prefix Tree Acceptor (PTA) Construction: From the execution traces, DSM constructs a Prefix Tree Acceptor (PTA). A PTA is a deterministic finite automaton that represents all prefixes of the input sequences.
  • Feature Engineering: DSM extracts two types of features from the PTA nodes:
  • Type I: Captures the history of invoked methods leading to a state.
  • Type II: Leverages the trained RNNLM to predict the likelihood of subsequent method calls from a given state.
  • Clustering: The extracted features are then used to cluster similar states within the PTA. DSM utilizes k-means and hierarchical clustering algorithms, exploring a range of cluster numbers to find optimal groupings. This step aims to generalize the PTA into a simpler FSA.
  • Model Selection: Finally, DSM employs a heuristic to select the best FSA from the candidates generated by the clustering process. It estimates precision and recall for each candidate FSA and chooses the one with the highest F-measure (harmonic mean of precision and recall).

Datasets

The paper evaluates DSM on 11 target library classes, primarily from the Java Development Kit (JDK). These classes include ArrayList, HashMap, Hashtable, HashSet, LinkedList, Signature, Socket, StackAr, StringTokenizer, NFST, and ZipOutputStream. The execution traces for these classes were collected from various sources, including the execution of software systems utilizing these APIs and generated by tools like Randoop. The paper does not introduce new benchmark datasets but rather uses existing ones for evaluation.

Key Insights and Ideas

  • Deep Learning for Specification Mining: The core innovation is the application of deep learning (RNNLMs) to enhance specification mining. By learning complex sequential patterns, DSM can potentially infer more accurate specifications than traditional methods, especially for dynamic software behaviors.
  • Feature Richness: The combination of historical method call information (Type I features) and predicted future method calls from an RNNLM (Type II features) provides a rich representation of states, enabling more effective clustering and generalization.
  • Automated Generalization: The clustering step is crucial for transforming a potentially overly specific PTA into a more generalizable FSA that captures the essential behavior of the target library.
  • F-measure Optimization: Using F-measure as the primary metric for model selection ensures a balance between precision and recall, leading to more practically useful specifications.

Key Results

DSM demonstrates strong performance across the evaluated library classes, achieving an average F-measure of 71.97%. Notably, for StringTokenizer and Signature, DSM achieved a perfect F-measure of 100%, indicating that it could infer models that exactly match the ground truth. For six other library classes, the F-measure was 70% or higher. The paper also highlights that DSM outperforms other baseline approaches in terms of specification quality and its ability to detect malicious behaviors in Android apps (though this specific evaluation is referenced from a prior work).

Limitations and Future Work

The authors acknowledge that the quality of mined specifications is still not perfect and that further improvements are possible. While DSM provides options to tune its performance, the paper doesn't delve deeply into the trade-offs between different parameter settings or the computational cost associated with various configurations. Future work could involve exploring more advanced deep learning architectures, investigating techniques for handling more complex temporal properties, and further optimizing the efficiency of the specification mining process. The DSM tool is open-source, encouraging community contributions and further development.

Summary updated

BibTeX
@inproceedings{le2018dsm,
  author = {Tien-Duy B. Le and Lingfeng Bao and David Lo},
  title = {{DSM: a specification mining tool using recurrent neural network based language model}},
  booktitle = {ESEC/SIGSOFT FSE},
  year = {2018},
  doi = {10.1145/3236024.3264597},
}
Figure