Abstract
Large Language Models (LLMs) for code often struggle with finite context windows, which limit their ability to process large source files. We present eWASH (Extended Window Access by Syntax Hierarchy), an architecture-agnostic method that leverages the syntactic structure of code to prioritize relevant information within a fixed context window. By prioritizing imports, class signatures, and docstrings over distant method bodies, eWASH significantly improves performance on code completion and summarization tasks, achieving state-of-the-art results on benchmarks like CodeXGLUE.
Introduction
Modern Transformer-based models for code, such as those used in GitHub Copilot, face a significant challenge: the "finite context window." While real-world software projects consist of large files where dependencies are often defined hundreds of lines away from the point of interest, Transformers are constrained by memory and compute requirements that scale quadratically with input length. Simply expanding the window is often computationally prohibitive. eWASH addresses this by intelligently compressing a file's context into a fixed-size window based on syntactic relevance rather than mere physical proximity.
Methodology: Syntax-Based Prioritization
The core of eWASH is the use of a Concrete Syntax Tree (CST) to create a prioritized view of the source file. Instead of a standard sliding window, eWASH identifies a "focal method" and fills the remaining context window according to a predefined hierarchy of importance.
The prioritization follows these steps:
- Focal Method: The signature and docstring of the method currently being processed.
- Global Context: Import statements and global variable assignments.
- Class Context: Class attributes and the signatures/docstrings of peer methods.
- Distant Details: Method bodies of peer methods, included only if space remains.
This hierarchical filtering acts as a "denoiser," allowing the model to focus on structural signals. Furthermore, the approach is architecture-independent, making it compatible with various model types like GPT (decoder-only) or T5 (encoder-decoder).
Experimental Setup
The models were pre-trained on a dataset of 4.3 million Python files from GitHub. Evaluation was conducted on:
- Py150: For standard code completion.
- CodeSearchNet: For method body completion and summarization (docstring generation).
- CodeXGLUE Extensions: New benchmarks focusing on user-experience scenarios, such as literal-normalized code completion.
Results and Discussion
The authors evaluated two primary models: XGPT-C (decoder-only) and XPyMT5 (encoder-decoder).
Code Completion
XGPT-C demonstrated superior performance, achieving a Perplexity (PPL) of 1.35, outperforming standard GPT-C (1.83) and memory-efficient variants like Reformer and Performer. On the CodeXGLUE completion task, XGPT-C improved the Top-1 exact match rate by over 12%.
Summarization
For code summarization, XPyMT5 achieved a BLEU-4 score of 0.47, nearly doubling the performance of the standard PyMT5 baseline (0.28). These results suggest that syntactic hierarchy is a more effective signal for code understanding than simple token proximity.
Conclusion and Future Work
eWASH provides a robust framework for handling long-range dependencies in source code. While currently implemented for Python, the concept is extensible to other languages by adapting the syntax-based priority heuristics. Future research directions include developing "learned" eWASH models that dynamically determine context priority and extending the hierarchy to encompass cross-file dependencies in large-scale software projects.
Summary updated