SEAILGMay 15, 2025

Are Sparse Autoencoders Useful for Java Function Bug Detection?

arXiv:2505.10375v32 citationsh-index: 3Has Code
Originality Incremental advance
AI Analysis

This work addresses software vulnerability detection for developers and security analysts, offering a lightweight and interpretable alternative to traditional methods, though it is incremental as it builds on existing SAE and LLM techniques.

The paper tackled the problem of detecting bugs in Java functions by using Sparse Autoencoders (SAEs) on representations from pretrained LLMs like GPT-2 Small and Gemma 2B, achieving an F1 score of up to 89% without fine-tuning the LLMs.

Software vulnerabilities such as buffer overflows and SQL injections are a major source of security breaches. Traditional methods for vulnerability detection remain essential but are limited by high false positive rates, scalability issues, and reliance on manual effort. These constraints have driven interest in AI-based approaches to automated vulnerability detection and secure code generation. While Large Language Models (LLMs) have opened new avenues for classification tasks, their complexity and opacity pose challenges for interpretability and deployment. Sparse Autoencoder offer a promising solution to this problem. We explore whether SAEs can serve as a lightweight, interpretable alternative for bug detection in Java functions. We evaluate the effectiveness of SAEs when applied to representations from GPT-2 Small and Gemma 2B, examining their capacity to highlight buggy behaviour without fine-tuning the underlying LLMs. We found that SAE-derived features enable bug detection with an F1 score of up to 89%, consistently outperforming fine-tuned transformer encoder baselines. Our work provides the first empirical evidence that SAEs can be used to detect software bugs directly from the internal representations of pretrained LLMs, without any fine-tuning or task-specific supervision. Code available at https://github.com/rufimelo99/SAE-Java-Bug-Detection

Code Implementations1 repo
Foundations

The foundational work for this paper's niche, ranked by how specifically the neighbourhood builds on it — not by global fame.

Your Notes