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

Diverse title generation for Stack Overflow posts with multiple-sampling-enhanced transformer

Fengji Zhang, Jin Liu, Yao Wan, Xiao Yu, Xiao Liu, Jacky Keung

Abstract

Summarizing technical posts on platforms like Stack Overflow is challenging due to the inherent ambiguity of code snippets. We present $M_3NSCT5$, a framework leveraging a CodeT5 backbone combined with Nucleus Sampling and Maximal Marginal Ranking (MMR) to generate a diverse set of high-quality title candidates. Evaluated on a large-scale dataset $D_{so}$, our approach significantly outperforms existing baselines in both automatic metrics and human evaluation, providing developers with relevant options that capture varied intents.

Introduction: The Ambiguity of Technical Summarization

On Stack Overflow (SO), a clear and descriptive title is essential for attracting expert answers. However, many developers struggle to summarize their technical problems effectively. A primary obstacle is the ambiguity issue: a single code snippet can serve multiple purposes depending on the user's specific context.

The ambiguity issue: the same code snippet can lead to different question intents and titles.

As shown in the figure above, a Python function for retrieving a client's IP address might be the basis for a question about implementation location in Django or a question about the accuracy of the IP itself. Traditional models that attempt to generate a single "correct" title often fail to capture this range of intent. This research shifts the focus toward generating a diverse set of plausible titles.

Methodology: The $M_3NSCT5$ Framework

The researchers developed the $M_3NSCT5$ (Multiple Sampling Enhanced Transformer) framework to address these challenges through three integrated components:

The $M_3NSCT5$ architecture, featuring CodeT5, Nucleus Sampling, and Maximal Marginal Ranking.
  1. CodeT5 Backbone: The model uses CodeT5, a state-of-the-art encoder-decoder Transformer pre-trained on massive code repositories, allowing it to deeply understand programming semantics.
  2. Nucleus Sampling (Top-p): To avoid the repetitive and generic outputs typical of "Beam Search," the framework employs Nucleus Sampling. This method samples from the most likely next tokens until a cumulative probability threshold ($p$) is reached, introducing controlled randomness and creative variety.
  3. Maximal Marginal Ranking (MMR): To ensure the final candidates are distinct, MMR is applied to select a subset that maximizes both quality (relevance to the code) and diversity (dissimilarity between candidates). A self-consistency metric based on bigram frequency is used to identify the most representative "best" title from the initial samples.

Dataset and Experimental Setup

The study introduced $D_{so}$, a new large-scale dataset derived from the SOTorrent archive.

  • Scale and Scope: It contains approximately 890,000 high-quality posts across eight programming languages (Python, C#, Java, JavaScript, PHP, C, Ruby, and Go).
  • Data Integrity: Unlike previous datasets, $D_{so}$ preserves structural information like white spaces and line breaks, which are vital for the model's comprehension of code structure.

Key Results and Insights

$M_3NSCT5$ was compared against six baselines, including BM25 and PLBART.

  • Performance Metrics: The model achieved a 9% improvement in BLEU and ROUGE scores over the next best model (PLBART).
  • Human Evaluation: Expert programmers rated $M_3NSCT5$ significantly higher in both correlation (how well the title matches the code) and diversity.
  • Cross-Language Generalization: The model maintained high performance even for low-resource languages like Ruby and Go, demonstrating the robust generalization capabilities of the CodeT5 backbone.

The research highlights that ambiguity is a feature of technical communication. By providing 3–5 diverse options, the model empowers users to select the title that best fits their specific intent, rather than forcing a single, potentially incorrect interpretation.

Conclusion and Future Work

While $M_3NSCT5$ excels at code-to-title generation, future iterations could incorporate additional context such as tags or partial descriptions. The authors also plan to explore integrated tag recommendation and deploy the framework as a real-world web service to assist the Stack Overflow community.

Summary updated

BibTeX
@article{zhang2022diverse,
  author = {Fengji Zhang and Jin Liu and Yao Wan and Xiao Yu and Xiao Liu and Jacky Keung},
  title = {{Diverse title generation for Stack Overflow posts with multiple-sampling-enhanced transformer}},
  journal = {J. Syst. Softw.},
  year = {2022},
}
Figure