Skip to main content
QUICK REVIEW

[Paper Review] A deep language model for software code

Hoa Khanh Dam, Truyen Tran|arXiv (Cornell University)|Aug 9, 2016
Software Engineering ResearchComputer Science12 references69 citations
TL;DR

This paper proposes a Long Short-Term Memory (LSTM)-based deep learning language model for software code to capture long-term dependencies that traditional n-gram models fail to address. Evaluated on a Java corpus, the LSTM model achieves up to 27.2% lower perplexity than RNNs on long sequences, demonstrating superior performance in modeling long-range code dependencies.

ABSTRACT

Existing language models such as n-grams for software code often fail to capture a long context where dependent code elements scatter far apart. In this paper, we propose a novel approach to build a language model for software code to address this particular issue. Our language model, partly inspired by human memory, is built upon the powerful deep learning-based Long Short Term Memory architecture that is capable of learning long-term dependencies which occur frequently in software code. Results from our intrinsic evaluation on a corpus of Java projects have demonstrated the effectiveness of our language model. This work contributes to realizing our vision for DeepSoft, an end-to-end, generic deep learning-based framework for modeling software and its development process.

Motivation & Objective

  • To address the limitation of n-gram models in capturing long-term dependencies in software code, where dependent tokens are far apart.
  • To develop a deep learning-based language model capable of learning long-range contextual patterns in source code.
  • To evaluate the effectiveness of LSTM architecture in modeling software code compared to standard RNNs.
  • To lay the foundation for DeepSoft, a generic deep learning framework for end-to-end software modeling and development process analysis.

Proposed method

  • The model uses a Long Short-Term Memory (LSTM) recurrent neural network to process code tokens sequentially and maintain long-term context through cell states.
  • The language model estimates the probability of a code sequence using autoregressive modeling: P(s) = P(w₁) × ∏ₜ₌₂ᵏ P(wₜ|w₁:ₜ₋₁).
  • Word embeddings of fixed dimension D are learned for each code token, with rare tokens mapped to <unk>.
  • The model is trained using RMSprop with tuned hyperparameters (η=0.02, ρ=0.99, ε=10⁻⁷) for optimal performance on code sequences.
  • A fixed vocabulary of size N=1,000 is constructed from the most frequent code tokens across a Java corpus.
  • Perplexity is used as the intrinsic evaluation metric, computed as exp(−∑log P(s)/#words), with lower values indicating better performance.

Experimental results

Research questions

  • RQ1Can an LSTM-based language model effectively capture long-term dependencies in software code that n-gram models fail to model?
  • RQ2How does the performance of an LSTM model compare to a standard RNN in modeling code sequences of varying lengths?
  • RQ3To what extent does model capacity (e.g., embedding dimensionality and sequence length) affect the performance of the language model?
  • RQ4Can the learned representations from the language model be used effectively for downstream software engineering tasks?

Key findings

  • The LSTM model achieves a 27.2% improvement in perplexity reduction over standard RNNs on sequences of length 500, demonstrating superior long-sequence modeling.
  • On short sequences (length 10), the LSTM model reduces perplexity by 4.7%, showing consistent improvement even on shorter contexts.
  • For sequences of length 100, the LSTM model achieves a 11.1% perplexity reduction compared to RNNs, with performance improving as sequence length increases.
  • When varying embedding dimensions with fixed sequence length, the LSTM model shows a 37.9% improvement at 200 dimensions, indicating better learning dynamics in larger models.
  • The model’s performance gain is most pronounced on long sequences, confirming its ability to handle long-range dependencies effectively.
  • The results validate the LSTM’s capacity to learn meaningful, contextually rich representations of code sequences, supporting its use in end-to-end software modeling frameworks like DeepSoft.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.