Skip to content
Open access

DuaLoc: Dual-Encoder Bug Localization with Bug-Report-Conditioned Attention and Contrastive Learning

Unknown authors
Sep 2026 · Electronics · 0 citations · 28 references

Abstract

Bug localization is the task of automatically identifying the source files responsible for a reported defect. It is a critical step in software maintenance that accelerates defect resolution. Information retrieval (IR) methods are simple and effective at exploiting historical signals such as bug-fixing recency and frequency, but they struggle to bridge the lexical gap between natural-language bug reports and programming-language identifiers. Recent work increasingly leverages pre-trained language models (PLMs) for code to close this gap. However, current PLM-based approaches still rely on a single code encoder that ignores program structure and aggregates function-level signals into file-level representations via uniform pooling. We propose a dual-encoder bug localization (DuaLoc) framework that jointly addresses these limitations. DuaLoc combines two pre-trained language models: UniXcoder for the semantic understanding of source code and GraphCodeBERT for awareness of data-flow structure. Both encoders are fine-tuned with a contrastive objective that shapes the embedding space around the localization task. A bug-report-conditioned attention mechanism then aggregates function embeddings into query-dependent file representations. The resulting neural similarity scores are then fused with classical IR features in a learning-to-rank model. DuaLoc outperforms representative classical and PLM-based baselines across most evaluation settings on a widely used benchmark of six open-source Java projects.

Read PDF

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.