Abstract
Large language models have demonstrated promising performance across various software engineering tasks. While fine-tuning is a common practice to adapt these models for downstream tasks, it becomes challenging in resource-constrained environments due to increased memory requirements from growing trainable parameters in increasingly large language models. We introduce Transducer Tuning, a technique to adapt large models for downstream code tasks using Code Property Graphs (CPGs). Our approach introduces a modular component called Transducer that enriches code embeddings with structural and dependency information from CPGs. The Transducer comprises two key components: Graph Vectorization Engine (GVE) and Attention-Based Fusion Layer (ABFL). GVE extracts CPGs from input source code and transforms them into graph feature vectors. ABFL then fuses those graphs feature vectors with initial code embeddings from a large language model. By optimizing these transducers for different downstream tasks, our approach enhances the models without the need to fine-tune them for specific tasks. We have evaluated Transducer Tuning on three downstream tasks: code summarization, assert generation, and code translation. Our results demonstrate competitive performance compared to full parameter fine-tuning while reducing up to 99% trainable parameters to save memory. Transducer Tuning also remains competitive against other fine-tuning approaches (e.g., LoRA, Prompt-Tuning, Prefix-Tuning) while using only 1.5%-80% of their trainable parameters. Our findings show that integrating structural and dependency information through Transducer Tuning enables more efficient model adaptation, making it easier for users to adapt large models in resource-constrained settings.
Introduction
As large language models (LLMs) continue to scale, the computational cost of fine-tuning—updating all internal weights for a specific task—has become prohibitively expensive. For instance, a 770-million parameter model can require nearly 40GB of GPU memory for basic tuning, placing it out of reach for many researchers and developers.
While parameter-efficient fine-tuning (PEFT) methods like LoRA or Prompt-Tuning reduce this overhead, they often treat code as plain text. However, code possesses a rigid structure defined by syntax trees, control flows, and data dependencies. Standard LLMs frequently struggle to capture these long-range structural relationships, leading to a trade-off where efficiency comes at the cost of accuracy. Transducer Tuning addresses this by leveraging the structural "DNA" of code to enrich model embeddings.
Methodology
The core of our approach is the Transducer, a modular component inserted into a frozen backbone LLM (such as CodeT5+). By keeping the backbone weights fixed and only training the small Transducer, we significantly reduce the memory footprint.
The Transducer architecture consists of two primary engines:
- Graph Vectorization Engine (GVE): This component extracts a Code Property Graph (CPG) from the source code. A CPG combines the code's structure, logic flow, and variable usage into a single representation. The GVE then uses a Graph Neural Network (specifically GATv2) to transform this complex graph into a dense feature vector.
- Attention-Based Fusion Layer (ABFL): This layer utilizes a cross-attention mechanism to fuse the structural information from the GVE with the standard text-based embeddings generated by the LLM. This allows the model to understand not just the text of the code, but the map of how logic actually flows.
Experimental Setup
We evaluated Transducer Tuning on three distinct software engineering tasks using established benchmarks:
- Code Summarization: Utilizing the Java subset of CodeSearchNet (82K samples) to generate natural language descriptions.
- Assert Generation: Predicting correct "assert" statements for unit tests using a dataset by Watson et al. (50K samples).
- Code Translation: Translating code between Java and C# using the CodeXGLUE benchmark (10K samples).
To ensure the integrity of our results, we performed rigorous data decontamination using Locality Sensitive Hashing (LSH), preventing the model from simply memorizing training examples.
Results and Discussion
Our evaluation yielded several key insights into the efficacy of structural information in model adaptation:
- Extreme Parameter Efficiency: Transducer Tuning reduced trainable parameters by up to 99% compared to full fine-tuning. Despite this reduction, performance remained highly competitive. For example, on CodeT5+ 220M, it achieved a BLEU score of 99.84 in summarization, nearly identical to the 99.91 achieved by full fine-tuning.
- Superiority over Existing PEFT Methods: Transducer Tuning consistently outperformed popular methods like LoRA, Prefix-Tuning, and Prompt-Tuning while using only 1.5% to 80% of the parameters those methods require.
- The Value of Structure: Ablation studies confirmed that the graph information is critical. Removing the GVE component led to significant performance drops, particularly in complex tasks like code translation, suggesting that LLMs benefit greatly from explicit structural maps rather than trying to infer structure from text alone.
- Modularity: Because the backbone remains frozen, a single LLM can be "hot-swapped" with different Transducers for different tasks without reloading the entire model, facilitating deployment in resource-constrained environments.
Conclusion
Transducer Tuning demonstrates that integrating structural and dependency information through Code Property Graphs enables highly efficient model adaptation. While the approach requires a preprocessing step to extract CPGs (using tools like Joern), the gains in memory efficiency and performance are substantial. Future work will explore a broader range of graph representations and the scalability of this approach to large-scale code generation tasks.
Summary updated