AdaptivePaste: Code Adaptation through Learning Semantics-aware Variable
Usage Representations
- URL: http://arxiv.org/abs/2205.11023v3
- Date: Fri, 6 Oct 2023 17:24:12 GMT
- Title: AdaptivePaste: Code Adaptation through Learning Semantics-aware Variable
Usage Representations
- Abstract summary: We introduce AdaptivePaste, a learning-based approach to source code adaptation.
We evaluate AdaptivePaste on a dataset of code snippets in Python.
Results suggest that our model can learn to adapt source code with 79.8% accuracy.
- Score: 22.52158623717161
- License: http://arxiv.org/licenses/nonexclusive-distrib/1.0/
- Abstract: In software development, it is common for programmers to copy-paste or port
code snippets and then adapt them to their use case. This scenario motivates
the code adaptation task -- a variant of program repair which aims to adapt
variable identifiers in a pasted snippet of code to the surrounding,
preexisting source code. However, no existing approach has been shown to
effectively address this task. In this paper, we introduce AdaptivePaste, a
learning-based approach to source code adaptation, based on transformers and a
dedicated dataflow-aware deobfuscation pre-training task to learn meaningful
representations of variable usage patterns. We evaluate AdaptivePaste on a
dataset of code snippets in Python. Results suggest that our model can learn to
adapt source code with 79.8% accuracy. To evaluate how valuable is
AdaptivePaste in practice, we perform a user study with 10 Python developers on
a hundred real-world copy-paste instances. The results show that AdaptivePaste
reduces the dwell time to nearly half the time it takes for manual code
adaptation, and helps to avoid bugs. In addition, we utilize the participant
feedback to identify potential avenues for improvement of AdaptivePaste.
Related papers
- ASAP: Unsupervised Post-training with Label Distribution Shift Adaptive Learning Rate [3.187381965457262]
ASAP adjusts the learning rate by computing the cosine distance between current and previous unlabeled outputs and mapping it within a bounded range.<n>Experiments show ASAP consistently improves accuracy and efficiency, making it practical for unsupervised model adaptation.
arXiv Detail & Related papers (2025-08-19T01:59:24Z) - VisCoder: Fine-Tuning LLMs for Executable Python Visualization Code Generation [69.35779796364413]
We present VisCode-200K, a large-scale instruction tuning dataset for Python-based visualization and self-correction.<n>It contains over 200K examples from two sources: (1) validated plotting code from open-source repositories, paired with natural language instructions and rendered plots; and (2) 45K multi-turn correction dialogues from Code-Feedback.
arXiv Detail & Related papers (2025-06-04T13:24:44Z) - Testora: Using Natural Language Intent to Detect Behavioral Regressions [19.51339228102997]
This paper presents Testora, the first automated approach that detects regressions by comparing the intentions of a code change against behavioral differences caused by the code change.<n>We find 19 regression bugs and 11 PRs that, despite having another intention, coincidentally fix a bug.<n>We envision our approach to be used before or shortly after a code change gets merged into a code base, providing a way to early on detect regressions that are not caught by traditional approaches.
arXiv Detail & Related papers (2025-03-24T11:55:35Z) - Less is More: Adaptive Program Repair with Bug Localization and Preference Learning [9.639104286650845]
We propose a two-stage approach to enhance program repair while maintaining consistency.
In the first stage, we utilize a Bug Locator with self-aware learning to accurately pinpoint bug locations.
In the second stage, we train a Program to ensure consistency between the post-modified fixed code and the pre-modified buggy code.
arXiv Detail & Related papers (2025-03-09T08:32:38Z) - Navigating Semantic Drift in Task-Agnostic Class-Incremental Learning [51.177789437682954]
Class-incremental learning (CIL) seeks to enable a model to sequentially learn new classes while retaining knowledge of previously learned ones.
Balancing flexibility and stability remains a significant challenge, particularly when the task ID is unknown.
We propose a novel semantic drift calibration method that incorporates mean shift compensation and covariance calibration.
arXiv Detail & Related papers (2025-02-11T13:57:30Z) - Task-recency bias strikes back: Adapting covariances in Exemplar-Free Class Incremental Learning [0.3281128493853064]
We tackle the problem of training a model on a sequence of tasks without access to past data.
Existing methods represent classes as Gaussian distributions in the feature extractor's latent space.
We propose AdaGauss -- a novel method that adapts covariance matrices from task to task.
arXiv Detail & Related papers (2024-09-26T20:18:14Z) - Adaptive Adapter Routing for Long-Tailed Class-Incremental Learning [55.384428765798496]
New data exhibits a long-tailed distribution, such as e-commerce platform reviews.
This necessitates continuous model learning imbalanced data without forgetting.
We introduce AdaPtive Adapter RouTing (APART) as an exemplar-free solution for LTCIL.
arXiv Detail & Related papers (2024-09-11T17:52:00Z) - Contrastive Difference Predictive Coding [79.74052624853303]
We introduce a temporal difference version of contrastive predictive coding that stitches together pieces of different time series data to decrease the amount of data required to learn predictions of future events.
We apply this representation learning method to derive an off-policy algorithm for goal-conditioned RL.
arXiv Detail & Related papers (2023-10-31T03:16:32Z) - CAFA: Class-Aware Feature Alignment for Test-Time Adaptation [50.26963784271912]
Test-time adaptation (TTA) aims to address this challenge by adapting a model to unlabeled data at test time.
We propose a simple yet effective feature alignment loss, termed as Class-Aware Feature Alignment (CAFA), which simultaneously encourages a model to learn target representations in a class-discriminative manner.
arXiv Detail & Related papers (2022-06-01T03:02:07Z) - ReACC: A Retrieval-Augmented Code Completion Framework [53.49707123661763]
We propose a retrieval-augmented code completion framework, leveraging both lexical copying and referring to code with similar semantics by retrieval.
We evaluate our approach in the code completion task in Python and Java programming languages, achieving a state-of-the-art performance on CodeXGLUE benchmark.
arXiv Detail & Related papers (2022-03-15T08:25:08Z) - Break-It-Fix-It: Unsupervised Learning for Program Repair [90.55497679266442]
We propose a new training approach, Break-It-Fix-It (BIFI), which has two key ideas.
We use the critic to check a fixer's output on real bad inputs and add good (fixed) outputs to the training data.
Based on these ideas, we iteratively update the breaker and the fixer while using them in conjunction to generate more paired data.
BIFI outperforms existing methods, obtaining 90.5% repair accuracy on GitHub-Python and 71.7% on DeepFix.
arXiv Detail & Related papers (2021-06-11T20:31:04Z) - Unsupervised Learning of General-Purpose Embeddings for Code Changes [6.652641137999891]
We propose an approach for obtaining embeddings of code changes during pre-training.
We evaluate them on two different downstream tasks - applying changes to code and commit message generation.
Our model outperforms the model that uses full edit sequences by 5.9 percentage points in accuracy.
arXiv Detail & Related papers (2021-06-03T19:08:53Z) - Evaluating Prediction-Time Batch Normalization for Robustness under
Covariate Shift [81.74795324629712]
We call prediction-time batch normalization, which significantly improves model accuracy and calibration under covariate shift.
We show that prediction-time batch normalization provides complementary benefits to existing state-of-the-art approaches for improving robustness.
The method has mixed results when used alongside pre-training, and does not seem to perform as well under more natural types of dataset shift.
arXiv Detail & Related papers (2020-06-19T05:08:43Z) - On-the-Fly Adaptation of Source Code Models using Meta-Learning [28.98699307030983]
We frame the problem of context adaptation as a meta-learning problem.
We train a base source code model that is best able to learn from information in a file to deliver improved predictions of missing tokens.
We demonstrate improved performance in experiments on a large scale Java GitHub corpus.
arXiv Detail & Related papers (2020-03-26T07:11:08Z)
This list is automatically generated from the titles and abstracts of the papers in this site.
This site does not guarantee the quality of this site (including all information) and is not responsible for any consequences.