Original: C ODE E DITING FROM F EW E XEMPLARS BY A DAPTIVE M ULTI -E XTENT C OMPOSITION
Revised: C ODE E DITING FROM F EW E XEMPLARS BY A DAPTIVE M ULTI -E XTENT C OMPOSITION

Original: Anonymous authors
Revised: Anonymous authors

Original: Paper under double-blind review
Revised: Paper under double-blind review

Original: A BSTRACT
Revised: A BSTRACT

Original: This paper considers the computer source code editing with few exemplars.
Revised: This paper considers the computer source code editing with few exemplars.

Original: The editing exemplar, containing the original and modiﬁed support code snippets, showcases a certain editorial style and implies the edit intention for a query code snippet.
Revised: The editing exemplar, containing the original and modified support code snippets, showcases a certain editorial pattern, and code editing adapts the common pattern derived from few support exemplars to a query code snippet.

Original: To achieve this, we propose a machine learning approach to adapt the editorial style derived from few exemplars to a query code snippet.
Revised: In this work, we propose a novel deep learning approach to solve this code editing problem automatically.

Original: Our learning approach combines edit representations extracted from editing exemplars and compositionally generalizes them to the query code snippet editing via multi-extent similarities ensemble.
Revised: Our learning approach combines edit representations extracted from support exemplars and compositionally generalizes them to the query code snippet editing via multi-extent similarities ensemble.

Original: Speciﬁcally, we parse the  code snippets using languagespeciﬁc grammar into abstract syntax trees.
Revised: Specifically, we parse the support and query code snippets using language-specific grammar into abstract syntax trees.

Original: We apply the similarities measurement in multiple extents from individual nodes to collective tree representations  and ensemble them through a similarity-ranking error estimator.
Revised: We apply the similarities measurement in multiple extents from individual nodes to collective tree representations for query and support sample matching, and ensemble the matching results through a similarity-ranking error estimator.

Original: We evaluate the proposed method ontwo datasets in C# and Python languages andrespectively show 8.0% and 10.9% absolute accuracy improvements compared to  baselines
Revised: We evaluate the proposed method on C# and Python datasets, and show up to 8.6% absolute accuracy improvements compared to non-composition baselines

Original:  I NTRODUCTION
Revised:  I NTRODUCTION

Original: In recent years, a surge of interest has been witnessed in applying machine learning techniques to code editing (Zhao et al., 2019; Chen et al., 2019; Dinella et al., 2020; Chakraborty et al., 2020;
Revised: In recent years, a surge of interest has been witnessed in applying machine learning techniques to code editing (Zhao et al., 2019; Chen et al., 2019; Dinella et al., 2020; Chakraborty et al., 2020;

Original: Yasunaga & Liang, 2020).
Revised: Yasunaga & Liang, 2020).

Original: Code editing in software engineering intends to revise the design, structure, functionality, or implementation of existing programming codes into a desirable style.
Revised: Code editing in software engineering intends to revise the design, structure, functionality, or implementation of existing programming codes into a desirable pattern.

Original: To maintain high-quality code projects or merge several repositories, the programmers typically ﬁx one or few code snippets, and expect the same revision automatically applied to everywhere in demand over the whole project.
Revised: To maintain high-quality code projects or merge several repositories, the programmers typically fix one or few code snippets, and expect the same revision automatically applied to other places in demand over the whole project.

Original: Automating this process can facilitate a broad range of programming applications such as code migration, refactoring, version update, and bug repair.
Revised: Automating this process can facilitate a broad range of programming applications such as code migration, refactoring, version update, and bug repair.

Revised: The problem of code editing with exemplar(s) aims to adopt the common editorial pattern from given exemplar(s) to a query code snippet.

Revised: The editorial pattern of an exemplar describes the type of change between two code snippets, and implies the underlying intent of making a kind of edit for a specific purpose, e.g., updating some keywords or reformatting redundant brackets.

Original: The problem of code editing with manually created exemplars has been studied by Yin et al.
Revised: Pink rectangles in Figure 1 provide an example of editorial patterns with the comparisons between previous and edited code snippets. We also present a list of editorial patterns that appear in our dataset in Appendix A for reader understanding. This problem is conceptually similar to programming by example in software engineering (Menon et al., 2013; Meng et al., 2013), and recently has been studied by Yin et al.

Original: ; Brody et al.
Revised: ; Brody et al.

Original: ; Yao et al.
Revised: ; Yao et al.

Original: Their works simulate a demand of automatically generalizing similar edits that a programmer has made somewhere to other applicable code snippets.
Revised: (2021) in a deep learning fashion.

Original: Technically, their methods parse the source code as an abstract syntax tree using language-speciﬁc grammar,and apply one-time or sequential edit actions over the tree, and always keep the modiﬁed code snippet satisfying grammatical rules.
Revised: Technically, their methods parse the source code as an abstract syntax tree using language-specific grammar, apply one-time or sequential edit actions over the tree, and always keep the modified code snippet satisfying grammatical rules.

Original: In particular, all these works focus on performing code editing with exact one editing exemplar, i.e., the one-shot setting.
Revised: In particular, all these works focus on performing code editing with exact one editing exemplar, i.e., the one-shot setting.

Original: The given exemplar showcases a certain editorial style, and implies the underlying intent of making a kind of edit, e.g., update some keywords or reformat redundant brackets.

Original: While the above studies have demonstrated promising results, simply adapting the editorial style from one single exemplar can lead to poor generalization or even incorrect code editing.
Revised: While the above studies have demonstrated promising results, simply adapting the editorial pattern from one single exemplar can lead to poor generalization or even incorrect code editing.

Original: Figure 1 presents two cases.
Revised: Figure 1 presents two cases.

Original: In Case (a), when a model observes only the Support #1 exemplar, it may intuitively interpret the code refactoring rule as replacing the conditional expression ( “ if (s==null)... ” ) by a coalesce one ( “ ...??...
Revised: In Case (a), when a model observes only the Support #1 exemplar, it may intuitively interpret the code refactoring rule as replacing the conditional expression ( “ if (s==null)... ” ) by a coalesce one ( “ ...??...

Original: ; ” ) only for a newly-declared variable ( “ string s=... ” ).
Revised: ; ” ) only for a newly-declared variable ( “ string s=... ” ).

Original: Consequently, applying the model to a query input could mistakenly transform the newly-declared variable ( “ string title=... ” ) rather than its re-assigned correspondence ( “ title=ReformatTitle(...) ”; see Solution #1).
Revised: Consequently, applying the model to a query input could mistakenly transform the newly-declared variable ( “ string title=... ” ) rather than its re-assigned correspondence ( “ title=ReformatTitle(...) ”; see Solution #1).

Original: However, Case (b) demonstrates a situation where two editing exemplars turn to be sufﬁcient for an editing model to capture the logical transformation over code tokens.
Revised: However, Case (b) demonstrates a situation where two editing exemplars turn to be sufficient for an editing model to capture the logical transformation over code tokens.

Original: The foregoing articulates the necessity of leveraging few but not one exemplar to adapt an editorial style to a new code snippet.
Revised: The foregoing articulates the necessity of leveraging few but not one exemplar to adapt an editorial pattern to a new code snippet.

Original: The few exemplars help the editing escape from the inductive bias learned from one exemplar, and enhance the generalized capacity for other snippets with various coding contexts.
Revised: The few exemplars help the editing escape from the inductive bias learned from one exemplar, and enhance the generalized capacity for other snippets with various coding contexts.

Original: In light of this, in this paper, we consider the computer source code editing with few exemplars.
Revised: In light of this, in this paper, we consider the computer source code editing with few exemplars.

Original: The editing of a query code snippet is triggered by few editing exemplars that containing the original and modiﬁed support code snippets.
Revised: The editing of a query code snippet is triggered by few editing exemplars that containing the original and modified support code snippets.

Original: Different from the above one-shot code editing scenario, few exemplars, even within the same editorial style, perform divergent coding contexts and edit actions.
Revised: Different from the above one-shot code editing scenario, few exemplars, even within the same editorial pattern, perform divergent coding contexts and edit actions.

Original: Therefore, it is not eligible to adapt the edit actions directly from an arbitrary exemplar.
Revised: Therefore, it is not eligible to adapt the edit actions directly from an arbitrary exemplar.

Original: For this scenario, the major challenge lies in how to identify and match helpful support exemplars for a query input and composite them to guide the editing .
Revised: For this scenario, the major challenge lies in how to identify and match helpful support exemplars for a query input and compose them to guide the editing .

Original: To address this challenge, we propose a novel approach that combines edit representations extracted from exemplars and compositionally generalizes them to the query code snippet editing via multi-extent similarities ensemble.
Revised: To address this challenge, we propose a novel approach that combines edit representations extracted from exemplars and compositionally generalizes them to the query code snippet editing via multiextent similarities ensemble.

Original: Speciﬁcally, we parse the support/query code snippets using language-speciﬁc grammar into abstract syntax trees, where editing actions are executed on nodes.
Revised: Specifically, we parse the support/query code snippets using languagespecific grammar into abstract syntax trees, where editing actions are executed on nodes.

Original: Based on this, we model the similarity between the representations of the support and query abstract syntax trees.
Revised: Based on this, we model the similarity between the representations of the support and query abstract syntax trees.

Original: We notice that among few exemplars, some editing action only happens in a local region, while concurrently some editing action relies on a general coding context.
Revised: We notice that among few exemplars, some editing action only happens in a local region, while concurrently some editing action relies on a general coding context.

Original: This inspires us to consider multi-extent similarities between the representations of the support and query abstract syntax trees.
Revised: This inspires us to consider multi-extent similarities between the representations of the support and query abstract syntax trees.

Original: We design a λ -softmax function by scaling the importance of nodes in an abstract syntax tree, i.e., λ → 0 means the support/query code snippet is denoted by tree representation, while λ → ∞ means the support/query code snippet is denoted by one single node representation in the abstract syntax tree.
Revised: We design a λ -softmax function by scaling the importance of nodes in an abstract syntax tree, i.e., λ → 0 means the support/query code snippet is denoted by tree representation, while λ → ∞ means the support/query code snippet is denoted by one single node representation in the abstract syntax tree.

Original: By controlling λ the intermediate positions between individual nodes and a collective tree, we provide multiple intermediate representational query-support matchings, then adaptively ensemble outcomes from these extents through a similarityranking error estimator for a robust composition.
Revised: By controlling λ the intermediate positions between individual nodes and a collective tree, we provide multiple intermediate representational query-support matchings, then adaptively ensemble outcomes from these extents through a similarity-ranking error estimator for a robust composition.

Original: We use the term multi-extent to describe the scope of query-support matching at various levels from nodes to a collective tree representation.
Revised: We use the term multi-extent to describe the scope of query-support matching at various levels from nodes to a collective tree representation.

Original: We evaluate the algorithmic performance on two code editing datasets, one in C#
Revised: We evaluate the algorithmic performance on two code editing datasets, one in C#

Original: (Yin et al., 2019) and one in Python (collected by us).
Revised: (Yin et al., 2019) and one in Python (collected by us).

Original: We implement the proposed multi-extent exemplar composition mechanism on top of the state-of-the-art Graph2Edit model (Yao et al., 2021).
Revised: We implement the proposed multi-extent exemplar composition mechanism on top of the state-of-the-art Graph2Edit model (Yao et al., 2021).

Original: On both datasets, our model outperforms baseline methods by 8.0-10.9% in terms of absolute accuracy.
Revised: On both datasets, our model outperforms baseline methods by 8.0-10.9% in terms of absolute accuracy.

Original: In addition, our experimental results show that (1) enabling few support exemplars can dramatically improve code editing; (2) compared with treating all support exemplars equally, precisely capturing the code snippet similarity and compositing support exemplars are crucial for code editing; and (3) the multi-extent approach offers better performance compared to its single-extent counterpart and other existing methods.
Revised: In addition, our experimental results show that (1) enabling few support exemplars can dramatically improve code editing; (2) compared with treating all support exemplars equally, precisely capturing the code snippet similarity and compositing support exemplars are crucial for code editing; and (3) the multi-extent approach offers better performance compared to its single-extent counterpart and other existing methods.

Original: Our collected PyFixer dataset and model implementation will be released.
Revised: Our collected PyFixer dataset and model implementation will be released.

Original:  P RELIMINARY
Revised:  P RELIMINARY

Original: In what follows we shall use C − and C + to represent the abstract syntax trees of the input (previous) and the output (edited) code snippets.
Revised: In what follows we shall use C − and C + to represent the abstract syntax trees of the input (previous) and the output (edited) code snippets.

Original: We address the problem of code editing learning with few exemplars.
Revised: We address the problem of code editing learning with few exemplars.

Original: Giving a set of K support exemplars with an identical editorial style { ( C s k − , C s k + ) } Kk =1 , the goal is to adapt the editing from support set to a query snippet C q − and obtain its desirable C q + .
Revised: Giving a set of K support exemplars with an identical editorial pattern { ( C s k − , C s k + ) } Kk =1 , the goal is to adapt the editing from support set to a query snippet C q − and obtain its desirable C q + .

Original: Here we introduce one of the state-of-the-arts edit learning models, Graph2Edit (Yao et al., 2021), that builds the one-shot code editing framework with three major components.
Revised: Here we introduce one of the state-of-the-arts edit learning models, Graph2Edit (Yao et al., 2021), that builds the one-shot code editing framework with three major components.

Original: (1) A tree encoder based on Gated Graph Neural Networks (Li et al., 2015) to embed the input abstract syntax tree C − into node representations Z ∈ R N × D , where N is the number of nodes in the tree and D is the latent feature dimension.
Revised: (1) A tree encoder based on Gated Graph Neural Networks (Li et al., 2015) to embed the input abstract syntax tree C − into node representations Z ∈ R N × D , where N is the number of nodes in the tree and D is the latent feature dimension.

Original: The whole tree embedding t can be obtained by a graph pooling operation over all node representations; (2) An editing encoder to embed input C − and corresponding output C + into a vector f ∆ ( C − ,
Revised: The whole tree embedding t can be obtained by a graph pooling operation over all node representations; (2) An editing encoder to embed input C − and corresponding output C + into a vector f ∆ ( C − ,

Original: C + ) ∈
Revised: C + ) ∈

Original: R D to represent the entire L sequential editing actions (four types of actions: add/delete a node, add a subtree, or stop editing) from C − to C
Revised: R D to represent the entire L sequential editing actions (four types of actions: add/delete a node, add a subtree, or stop editing) from C − to C

Original: + as well as the procedural editorial style; (3) A decoder for editing action prediction working conditionally on the tree embedding t and editing representation f ∆ ( C − , C + ) .
Revised: + as well as the procedural editorial pattern; (3) A decoder for editing action prediction working conditionally on the tree embedding t and editing representation f ∆ ( C − , C + ) .

Original: Predictions include the operational type, the executive location on abstract syntax tree, and associated action values, e.g., to be replaced by which node.
Revised: Predictions include the operational type, the executive location on abstract syntax tree, and associated action values, e.g., to be replaced by which node.

Original: Denote t 1: l = ( t 1 , . . .
Revised: Denote t 1: l = ( t 1 , . . .

Original: , t l ) as the tree embedding history along the sequential editing, and a 1: l = ( a 1 , . . .
Revised: , t l ) as the tree embedding history along the sequential editing, and a 1: l = ( a 1 , . . .

Original: , a l ) as the editing action history until step l .
Revised: , a l ) as the editing action history until step l .

Original: Formally, the whole predictions of actions can be represented as a conditional likelihood Pr ( a 1: L | f ∆ ( C − , C + ) , t 1 ) =
Revised: Formally, the whole predictions of actions can be represented as a conditional likelihood Pr ( a 1: L | f ∆ ( C − , C + ) , t 1 ) =

Original: (cid:81)
Revised: (cid:81)

Original: Ll =1 Pr ( a l | f ∆ ( C − , C + ) , t 1: l ) .
Revised: Ll =1 Pr ( a l | f ∆ ( C − , C + ) , t 1: l ) .

Original: An earlier model Graph2Tree (Yin et al., 2019), where Graph2Edit derives from, shares the same methodological concept but edits the input in one-pass, instead of sequentially predict and apply the edit actions.
Revised: An earlier model Graph2Tree (Yin et al., 2019), where Graph2Edit derives from, shares the same methodological concept but edits the input in one-pass, instead of sequentially predict and apply the edit actions.

Original: The Graph2Edit framework is trained in a self-reconstruction paradigm.
Revised: The Graph2Edit framework is trained in a self-reconstruction paradigm.

Original: The training feeds the tree encoder and the editing encoder with a pair of C − and C + , and maximizes the likelihood of the whole predictions of actions towards the shortest sequential actions produced by dynamic programming.
Revised: The training feeds the tree encoder and the editing encoder with a pair of C − and C + , and maximizes the likelihood of the whole predictions of actions towards the shortest sequential actions produced by dynamic programming.

Original: The training details with the dynamic programming algorithm can be found in Yao et al.
Revised: The training details with the dynamic programming algorithm can be found in Yao et al.

Original: The training only sends the vanilla editing encoder with the ground-truth from one exemplar, while { ( C s k − , C s k + ) } Kk =1 with an identical editorial style are hard to collect from a wild code dataset.
Revised: The training only sends the vanilla editing encoder with the ground-truth from one exemplar, while { ( C s k − , C s k + ) } Kk =1 with an identical editorial pattern are hard to collect from a wild code dataset.

Original: Based on the training, Graph2Edit is mainly designed for code editing with only one support exemplar.
Revised: Based on the training, Graph2Edit is mainly designed for code editing with only one support exemplar.

Original: It is struggled to directly tackle few supports since few exemplars, even within the same editorial style, perform divergent coding context and edit actions.
Revised: It is struggled to directly tackle few supports since few exemplars, even within the same editorial pattern, perform divergent coding context and edit actions.

Original: Unfortunately, we argue the one-exemplar case lacks the capacity of compositional generalization on editorial styles as we discussed within the introductory part.
Revised: Unfortunately, we argue the one-exemplar case lacks the capacity of compositional generalization on editorial patterns as we discussed within the introductory part.

Original: We also empirically evidence this claim in our experimental section.
Revised: We also empirically evidence this claim in our experimental section.

Original: Our method composites f ∆ ( C s k − , C s k + ) from support set based on a multi-extent query-support matching to form the query edit representation f q ∆ for decoding purpose which done by the code editing frameworks.
Revised: Our method composites f ∆ ( C s k − , C s k + ) from support set based on a multi-extent query-support matching to form the query edit representation f q ∆ for decoding purpose which done by the code editing frameworks.

Original: In the next section, we elaborate on our proposed adaptive multi-extent similarity ensemble on exemplar composition to address the foregoing challenges in computer code editing with few exemplars.
Revised: In the next section, we elaborate on our proposed adaptive multi-extent similarity ensemble on exemplar composition to address the foregoing challenges in computer code editing with few exemplars.

Original:  A DAPTIVE M ULTI -E XTENT C OMPOSITION
Revised:  A DAPTIVE M ULTI -E XTENT C OMPOSITION

Original: We assume that if the input tree of a support exemplar enjoys more similarity with the query input tree, the query snippet is more likely to adopt the support exemplar’s edit representation towards correct code editing.
Revised: We assume that if the input tree of a support exemplar enjoys more similarity with the query input tree, the query snippet is more likely to adopt the support exemplar’s edit representation towards correct code editing.

Original: Based on this, we address compositional learning from a query-support matching perspective.
Revised: Based on this, we address compositional learning from a query-support matching perspective.

Original: Deriving from the basis of code editing reference, some editing can be adapted depending on individual node representation and regardless of its neighbor nodes and context.
Revised: Deriving from the basis of code editing reference, some editing can be adapted depending on individual node representation and regardless of its neighbor nodes and context.

Original: For instance, the removal of a redundant bracket should partially be independent of the inside context, or the change of some outdated function calling mode in a previous language version should be invariant to the host object.
Revised: For instance, the removal of a redundant bracket should partially be independent of the inside context, or the change of some outdated function calling mode in a previous language version should be invariant to the host object.

Original: On the other hand, some editing highly relies on the contextual information among several objects and connections therein, leading the editing learning to be determined by a collective representation.
Revised: On the other hand, some editing highly relies on the contextual information among several objects and connections therein, leading the editing learning to be determined by a collective representation.

Original: Continuing with this analysis, we design a multi-extent measurement to perform multiple intermediate query-support matching between individual nodes and the collective tree.
Revised: Continuing with this analysis, we design a multi-extent measurement to perform multiple intermediate query-support matching between individual nodes and the collective tree.

Original: Speciﬁcally, we measure the multi-extent similarities between query and support snippets in the tree embedding space,  and learn a convex combination of the editing representations from the support set to maximize the adaptability for query snippet editing.
Revised: Specifically, we measure the multi-extent similarities between query and support snippets in the tree embedding space, where we can define the coverage of nodes in a tree we want to involve for matching (from a single node to every node), then ensemble and learn a convex combination of the editing representations from the support set to maximize the adaptability for query snippet editing.

Original: In the coming subsections, we introduce the query-support matching over abstract syntax tree, extend it with multi-extent representation in an ensemble mechanism, then illustrate the meta-learning paradigm and inference procedure.
Revised: In the coming subsections, we introduce the query-support matching over abstract syntax tree, extend it with multi-extent representation in an ensemble mechanism, then illustrate the meta-learning paradigm and inference procedure.

Original: 3. Q UERY -S UPPORT M ATCHING : F ROM C OLLECTIVE T REE TO I NDIVIDUAL N ODE
Revised: 3. Q UERY -S UPPORT M ATCHING : F ROM C OLLECTIVE T REE TO I NDIVIDUAL N ODE

Original: Instead of treating each node equally, our model softly emphasizes some nodes in the query snippet when meet a similar node in a support exemplar, and vice versa.
Revised: Instead of treating each node equally, our model softly emphasizes some nodes in the query snippet when meet a similar node in a support exemplar, and vice versa.

Original: Considering one query snippet and a set with K support exemplars, let z qn and z s k n denote the n -th node representation in the abstract syntax tree of the query and k -th support snippet, respectively.
Revised: Considering one query snippet and a set with K support exemplars, let z qn and z s k n denote the n -th node representation in the abstract syntax tree of the query and k -th support snippet, respectively.

Original: Let ϕ θ ( · , · ) :
Revised: Let φ θ ( · , · ) :

Original: Z × Z → R be a query-support node matching similarity function (e.g., a neural network) with a learnable parameter θ that takes the node representation from both sides as input.
Revised: Z × Z → R be a query-support node matching similarity function (e.g., a neural network) with a learnable parameter θ that takes the node representation from both sides as input.

Original: Note that ϕ θ ( · , · ) does not have to be non-negative or symmetrical since the measurement across query and support can be deemed as directional.
Revised: Note that φ θ ( · , · ) does not have to be non-negative or symmetrical since the measurement across query and support can be deemed as directional.

Original: We compute the initial query-support node matching activation m qs k n and m s k n as follows:
Revised: We compute the initial query-support node matching activation m qs k n and m s k n as follows:

Original: [Equation]
Revised: [Equation]

Original: where N q and N s are the numbers of nodes in the query and support abstract syntax trees.
Revised: where N q and N s are the numbers of nodes in the query and support abstract syntax trees.

Original: The maximum operation over the set of one-to-all node emphasizes the matching between individual nodes, and returns a high activation when there is at least one good match in the counterpart.
Revised: The maximum operation over the set of one-to-all node emphasizes the matching between individual nodes, and returns a high activation when there is at least one good match in the counterpart.

Original: The activation represents the likelihood that a query node appears in a support snippet and vice versa.
Revised: The activation represents the likelihood that a query node appears in a support snippet and vice versa.

Original: To capture the multi-extent matching, we design a λ -softmax function by scaling the importance of nodes in an abstract syntax tree, and seek the query-support matching at the intermediate position between individual nodes and a collective tree:
Revised: To capture the multi-extent matching, we design a λ -softmax function by scaling the importance of nodes in an abstract syntax tree, and seek the query-support matching at the intermediate position between individual nodes and a collective tree:

Original: [Equation]
Revised: [Equation]

Original: σ qs k n,λ denotes the parameterized node activation from the query snippet to the k -th support snippet, and a similar expression can denote as σ s k  n,λ .
Revised: σ q,s k n,λ denotes the parameterized node activation from the query snippet to the k -th support snippet, and a similar expression can denote as σ s k ,q n,λ .

Original: Based on the above normalized activation for individual node representation, the collective tree representation of the query and support snippets can be calculated using a weighted average pooling as follows:
Revised: Based on the above normalized activation for individual node representation, the collective tree representation of the query and support snippets can be calculated using a weighted average pooling as follows:

Original: [Equation]
Revised: [Equation]

Original: The representation of the query snippet has the summation of matching values on nodes from all support exemplars.
Revised: The representation of the query snippet has the summation of matching values on nodes from all support exemplars.

Original: Combining Eq.
Revised: Combining Eq.

Original: (2) and (3), an intuitive interpretation on variable λ raises: a larger λ denotes greater domination of matched individual nodes in the ﬁnal tree representation, i.e., the sharpness of the outcomes after λ -softmax normalization.
Revised: (2) and (3), an intuitive interpretation on variable λ raises: a larger λ denotes greater domination of matched individual nodes in the final tree representation, i.e., the sharpness of the outcomes after λ -softmax normalization.

Original: λ → 0 preserves the ﬁnal query/support representation as to their initial tree representation, and λ → ∞ represents the ﬁnal query/support representation approximately with only one single node representation at most of the time, where the node is selected upon the maximum activation from Eq. 
Revised: λ → 0 preserves the final query/support representation as to their initial tree representation, meaning it calculates a more smoothly weighted average of node representations over the entire tree. λ → ∞ represents the final query/support representation approximately with only one single node representation at most of the time, where the node is selected upon the maximum activation from Eq. Setting a large λ value implies a smaller coverage over the tree.

Original: This  property holds due to the monotonous increase of the ﬁrst-order gradient of the exponential function.
Revised: This coverage scaling property holds due to the monotonous increase of the first-order gradient of the exponential function.

Original: We will tackle the λ value selection problem in the next subsection.
Revised: We will tackle the λ value selection problem in the next subsection.

Original: We reach to the generation of edit representation for query sample editing and the updated tree representation yields the expression:
Revised: Currently, we reach to the generation of edit representation for query sample editing, and the updated tree representation yields the expression:

Original: [Equation]
Revised: [Equation]

Original:  where φ θ ( · , · ) is a similarity measure over query and support tree representations and should satisfy the convexity in the above combination.
Revised: [Equation] where ϕ θ ( · , · ) is a similarity measure over query and support tree representations and should satisfy the convexity in the above combination.

Original: Note that for a simpliﬁed expression, we do not distinguish the learnable parameter θ for each module but their parameters are isolated.
Revised: Note that for a simplified expression, we do not distinguish the learnable parameter θ for each module but their parameters are isolated.

Original: 3. M ULTI -E XTENT C OMPOSITION AND E NSEMBLE
Revised: 3. M ULTI -E XTENT C OMPOSITION AND E NSEMBLE

Original: The λ -softmax in Eq.
Revised: The λ -softmax in Eq.

Original: (2) controls the matching extent from individual node to collective tree.
Revised: (2) controls the matching extent from individual node to collective tree.

Original: However, it is hard to access the optimal intermediate position, since code editing samples suffer from a huge variance.
Revised: However, it is hard to access the optimal intermediate position, since code editing samples suffer from a huge variance.

Original: Therefore, a single extent may not be robust enough to help the model generalize in diverse editing scenarios.
Revised: Therefore, a single extent may not be robust enough to help the model generalize in diverse editing scenarios.

Original: We hereby propose a multi-extent measurement to complement the above weakness by setting λ with different continuous values, and ensemble all the results φ θ ( t qλ i , t s k λ i ) for { λ i } N λ
Revised: We hereby propose a multi-extent measurement to complement the above weakness by setting λ with different continuous values, and ensemble all the results ϕ θ ( t qλ i , t s k λ i ) for { λ i } N λ

Original: i
Revised: i

Original: =1 to enhance the generalization on complicated code snippets.
Revised: =1 to enhance the generalization on complicated code snippets.

Original: However, setting λ arbitrarily and ensemble all perspectives linearly without selection may corrupt the overall tree representation, and thus deteriorate the model.
Revised: However, setting λ arbitrarily and ensemble all perspectives linearly without selection may corrupt the overall tree representation, and thus deteriorate the model.

Original: For a robust ensemble and aggregation, we consider assessing the quality of φ θ ( t qλ i , t sλ i ) towards different λ i by using a marginal ranking error on edit representation.
Revised: For a robust ensemble and aggregation, we consider assessing the quality of ϕ θ ( t qλ i , t sλ i ) towards different λ i by using a marginal ranking error on edit representation.

Original: Since we have the accessible ground-truth C q + during training, we employ the ranking error
Revised: Since we have the accessible ground-truth C q + during training, we employ the ranking error

Original: e λ i to explicitly reﬂect how good φ θ ( t qλ , t s k λ ) is under a certain λ with respect to the similarity between query and K support exemplars.
Revised: e λ i to explicitly reflect how good ϕ θ ( t qλ , t s k λ ) is under a certain λ with respect to the similarity between query and K support exemplars.

Original: In the inference phase, due to the missing of C q + , we employ a similarity-ranking error estimator ˆ e λ i =
Revised: In the inference phase, due to the missing of C q + , we employ a similarity-ranking error estimator ˆ e λ i =

Original: R µ ( t qλ i , t s 1 λ i , t s 2 λ i , . . .
Revised: R µ ( t qλ i , t s 1 λ i , t s 2 λ i , . . .

Original: t s K λ
Revised: t s K λ

Original: i ; λ i ) :
Revised: i ; λ i ) :

Original: R ( K +1)
Revised: R ( K +1)

Original: × D → R to predict the quality of each λ i , where µ is the learnable parameter in R µ , and ensemble the outcomes.
Revised: × D → R to predict the quality of each λ i , where µ is the learnable parameter in R µ , and ensemble the outcomes.

Original: Training details of R µ will be elaborated in the next subsection.
Revised: Training details of R µ will be elaborated in the next subsection.

Original: To achieve multi-extent composition and ensemble, we ﬁrst measure the similarity between query and support edit representations via the editing encoder:
Revised: To achieve multi-extent composition and ensemble, we first measure the similarity between query and support edit representations via the editing encoder:

Original: [Equation]

Original: [Equation]
Revised: [Equation]

Original: Then we access the error for each λ by:
Revised: Then we access the error for each λ by:

Original: [Equation]
Revised: [Equation]

Original: [Equation]

Original: where Γ( · ) is the index mapping for K support exemplars that satisfy w Γ(1) ≥ w Γ(2) ≥ . .
Revised: where Γ( · ) is the index mapping for K support exemplars that satisfy w Γ(1) ≥ w Γ(2) ≥ . .

Original: ≥ w Γ( k ) , i.e., the mapping to sort s k in a descending order, and γ is the margin set as a hyperparameter.
Revised: ≥ w Γ( k ) , i.e., the mapping to sort s k in a descending order, and γ is the margin set as a hyperparameter.

Original: The formulation indicates how well the nearest support exemplars can outperform other support exemplars, and the factor ( w Γ(1) − w Γ( k ) ) reveals the error conﬁdence.
Revised: The formulation indicates how well the nearest support exemplars can outperform other support exemplars, and the factor ( w Γ(1) − w Γ( k ) ) reveals the error confidence.

Original: Note that the above error term depends on the edit model f ∆ , which is only an approximate estimation.
Revised: Note that the above error term depends on the edit model f ∆ , which is only an approximate estimation.

Original: Then we extend Eq.
Revised: Then we extend Eq.

Original: (4) by involving multiple extents and the reciprocal of its error for an adaptive ensemble:
Revised: (4) by involving multiple extents and the reciprocal of its error for an adaptive ensemble:

Original: [Equation]
Revised: [Equation]

Original: where (cid:15) is a constant in denominator for numerical stability.
Revised: where ϵ is a constant in denominator for numerical stability.

Original: We omit the normalization over φ θ ( t qλ i , t s k λ i ) /
Revised: We omit the normalization over ϕ θ ( t qλ i , t s k λ i ) /

Original: ( e λ i + (cid:15) ) in the equation.
Revised: ( e λ i + ϵ ) in the equation.

Original: In practice, we apply a softmax function on this term to keep the convexity of the combination.
Revised: In practice, we apply a softmax function on this term to keep the convexity of the combination.

Original: Note that in inference e λ i will be replaced by ˆ e λ i .
Revised: Note that in inference e λ i will be replaced by ˆ e λ i .

Original: 3. L EARNING AND I NFERENCE
Revised: 3. L EARNING AND I NFERENCE

Original: In the learning phase, we have a set of K support exemplars { ( C s k − , C s k + ) } Kk =1 and one complete query snippet { C q − , C q + } as inputs.
Revised: In the learning phase, we have a set of K support exemplars { ( C s k − , C s k + ) } Kk =1 and one complete query snippet { C q − , C q + } as inputs.

Original: Following the Graph2Edit framework (Yao et al., 2021), we obtain the z qn and z s k n of the n -th node representation of the query and k -th support snippet and the edit representation f ∆ ( C s k − , C s k + ) for each support exemplar.
Revised: Following the Graph2Edit framework (Yao et al., 2021), we obtain the z q n and z s k n of the n -th node representation of the query and k -th support snippet and the edit representation f ∆ ( C s k − , C s k + ) for each support exemplar.

Original: L q is the number of steps towards the shortest sequential actions from C q − to C q + , and a 1: L q denotes the corresponding action sequence.
Revised: L q is the number of steps towards the shortest sequential actions from C q − to C q + , and a 1: L q denotes the corresponding action sequence.

Original: Let e =
Revised: Let e =

Original: ( e λ 1 , e λ 2 , . . .
Revised: ( e λ 1 , e λ 2 , . . .

Original: , e λ N ) calculated by Eq.
Revised: , e λ N ) calculated by Eq.

Original: (6) and ˆ e =
Revised: (6) and ˆ e =

Original: (ˆ e λ 1 , ˆ e λ 2 , . . .
Revised: (ˆ e λ 1 , ˆ e λ 2 , . . .

Original: , ˆ e λ N ) is its estimation from the estimator R µ .
Revised: , ˆ e λ N ) is its estimation from the estimator R µ .

Original: With N λ extents, our objective function can be written as:
Revised: With N λ extents, our objective function can be written as:

Original: [Equation]
Revised: [Equation]

Original: where || · || 1 is the vector l 1 -norm to sum up the absolute values of all elements, D KL ( ·(cid:107)· ) is the
Revised: where || · || 1 is the vector l 1 -norm to sum up the absolute values of all elements, D KL ( ·∥· ) is the

Original: KL-divergence, f q ∆ is the composition of edit representations in Eq.
Revised: KL-divergence, f q ∆ is the composition of edit representations in Eq.

Original: (7), t q = (cid:80) N q n =1 z qn /N q is the initial tree representation of C q − , θ and µ are the learnable parameters in the similarity measurement φ θ , ϕ θ and the estimator R µ .
Revised: (7), t q = (cid:80) N q n =1 z qn /N q is the initial tree representation of C q − , θ and µ are the learnable parameters in the similarity measurement ϕ θ , φ θ and the estimator R µ .

Original: We omit the balanced factor for each term for a simpliﬁed expression.
Revised: We omit the balanced factor for each term for a simplified expression.

Original: The above objective function consists of three parts.
Revised: The above objective function consists of three parts.

Original: The ﬁrst term maximizes the likelihood between the learned convex combination of edit representations and optimal editing actions, while the rest two terms aim to minimize the ranking error between the query and support snippets at different extent levels and train an estimator to accurately estimate the error for inference usage.
Revised: The first term maximizes the likelihood between the learned convex combination of edit representations and optimal editing actions, while the rest two terms aim to minimize the ranking error between the query and support snippets at different extent levels and train an estimator to accurately estimate the error for inference usage.

Original: The parameters for tree encoder, editing encoder, and decoder are obtained via a pre-training stage on another data split following the self-reconstruction paradigm from Graph2Edit, while their parameters are not tuned in the meta-learning stage for optimization, since we observe a serve overﬁtting if doing so.[Table]
Revised: The parameters for tree encoder, editing encoder, and decoder are obtained via a pre-training stage on another data split following the self-reconstruction paradigm from Graph2Edit, while their parameters are not tuned in the meta-learning stage for optimization, since we observe a serve overfitting if doing so.

Original: We follow an episode training mechanism (Snell et al., 2017) that is widely used in few-shot learning to simulate the encounter of new editorial style in testing.
Revised: We follow an episode training mechanism (Snell et al., 2017) that is widely used in few-shot learning to simulate the encounter of new editorial pattern in testing.

Original: For each training forward, we sample a ﬁxed number of editorial styles with K support exemplars and one query snippet per class and backpropagate the loss.
Revised: For each training forward, we sample a fixed number of editorial patterns with K support exemplars and one query snippet per class and backpropagate the loss.

Original: In the inference phase, given a set of K support exemplars { ( C s k − , C s k + ) } Kk = and one input query snippet C q − , we replace e λ i with ˆ e λ i in Eq.
Revised: In the inference phase, given a set of K support exemplars { ( C s k − , C s k + ) } Kk = and one input query snippet C q − , we replace e λ i with ˆ e λ i in Eq.

Original: (7) and yields the formulation.
Revised: (7) and yields the formulation.

Original:  E XPERIMENT 4. E XPERIMENTAL S ETTING
Revised:  E XPERIMENT 4. E XPERIMENTAL S ETTING

Original: Dataset We include two code editing datasets for performance evaluation.
Revised: Dataset We include two code editing datasets for performance evaluation.

Original: (1) C#Fixer (Yin et al., 2019) is a dataset containing 2,878 editing pairs, generated by applying two C# ﬁxing tools Roslynand Roslynator 2 on six projects.
Revised: (1) C#Fixer (Yin et al., 2019) is a dataset containing 2,878 editing pairs, generated by applying two C# fixing tools Roslynand Roslynator 2 on six projects.

Original: A ﬁxer is building on top of the C# compiler used to perform refactoring and modernization on codes.
Revised: A fixer is building on top of the C# compiler used to perform refactoring and modernization on codes.

Original: One ﬁxer is designed for one type of refactoring andﬁxers are selected in this dataset.
Revised: One fixer is designed for one type of refactoring andfixers are selected in this dataset.

Original: A pre-trained model for C#Fixer is trained on GitHubEdits dataset using self-reconstruction.
Revised: A pre-trained model for C#Fixer is trained on GitHubEdits dataset using self-reconstruction.

Original: The dataset collects 54 C# projects on GitHub which extract the source code before and after the commits from users.
Revised: The dataset collects 54 C# projects on GitHub which extract the source code before and after the commits from users.

Original: We use the data of GitHubEdits only for pre-training and follow the training protocol in Yao et al.
Revised: We use the data of GitHubEdits only for pre-training and follow the training protocol in Yao et al.

Original: (2021) but not for few-shot experiments.
Revised: (2021) but not for few-shot experiments.

Original: (2) Beneﬁting from the ﬂexibility and generalized capacity of abstract syntax description language, beyond C#, we collect another dataset PyFixer written in Python 2.
Revised: (2) Benefiting from the flexibility and generalized capacity of abstract syntax description language, beyond C#, we collect another dataset PyFixer written in Python 2.

Original: We use Python-Future 3 , a tool that edits the codes over 5,959 projects written in Python 2 to satisfy the compatibility of Python 3.
Revised: We use Python-Future 3 , a tool that edits the codes over 5,959 projects written in Python 2 to satisfy the compatibility of Python 3.

Original: We obtain the code pairs by taking codes before and after applying the tool and inspecting the changes.
Revised: We obtain the code pairs by taking codes before and after applying the tool and inspecting the changes.

Original: To simulate the pre-training and few-shot learning as in GitHubEdits and C#Fixer , we select 12 types of ﬁxers and extract a ﬁxed number of each ﬁxer from the main data to form the dataset for few-shot learning, while the rest are preserved for pre-training.
Revised: To simulate the pre-training and few-shot learning as in GitHubEdits and C#Fixer , we select 12 types of fixers and extract a fixed number of each fixer from the main data to form the dataset for few-shot learning, while the rest are preserved for pre-training.

Original: After data cleaning, we have 14,941 code pairs for (pre) training, 1,664 for validation, and 2,319 for few-shot experiments.
Revised: After data cleaning, we have 14,941 code pairs for (pre) training, 1,664 for validation, and 2,319 for few-shot experiments.

Original: The two datasets only contain source code but without any author’s name, contact information, or offensive content.
Revised: The two datasets only contain source code but without any author’s name, contact information, or offensive content.

Original: Baseline We employ modiﬁcations on two abstract syntax tree-based code editing frameworks,
Revised: Baseline We employ modifications on two abstract syntax tree-based code editing frameworks,

Original: Graph2Tree (Yin et al., 2019) and Graph2Edit (Yao et al., 2021), to ﬁt them in the few exemplars editing setting and involve the following baselines.
Revised: Graph2Tree (Yin et al., 2019) and Graph2Edit (Yao et al., 2021), to fit them into the few exemplars editing setting and involve the following baselines.

Original:  RS (Random Selection): we randomly select one support exemplar from the support set and use its edit representation for standard decoding on query snippet; AE (Average Edit Representation): we infer the edit representation of K support
Revised: Note that all baselines are only different in calculating the similarity measure ϕ θ in Eq. RS (Random Selection) : we randomly select one support exemplar from the support set and use its edit representation for standard decoding on query snippet; NN (Nearest Neighbor) :

Original: [Table]
Revised: we identify the nearest neighbor in the support set based on the distance calculated by graph edit distance (Sanfeliu & Fu, 1983; Abu-Aisheh et al., 2015) over AST trees ( GED-NN ), and cosine similarity over input tree representation ( CS-NN ). AE (Average Edit

Original:  exemplars using editing encoder respectively, and take theweighted mean of the K representations for query decoding.
Revised: Representation) : we infer the edit representation of K support exemplars using editing encoder respectively, and take the mean of these K representations for query decoding.

Original: Moreover [Table]
Revised: This is equivalent to setting ϕ θ = 1 /K in Eq. 4.

Original:  we include two other baselines within our proposed composition framework.
Revised: Moreover, we include two other baselines within our proposed composition framework.

Original: Our (GDE) means that we employ the  distance metric Graph Edit Distance (Sanfeliu & Fu, 1983; Abu-Aisheh et al., 2015) among every query-support snippet pair, take the reciprocal proportion [Table]
Revised: GED-Comp (Composition via graph edit distance) employs the graph edit distance metric as ϕ θ when comparing the query and the support exemplar among every querysupport snippet pair; we take the reciprocal proportion of this metric and form a convex combination over K edit representations.

Original: and form a convex combination over K edit representations
Revised: CS-Comp (Composition via cosine similarity) means that we employ

Original: [Table]
Revised: [Table]

Original: and Ours (CS) means that we employ mean pooling over query and support trees, compute the similarity  by cosine similarity  for every query-support snippet pair, normalize, and form a convex combination over  entire available edit representations from support set based on the obtained similarity.
Revised: mean pooling over query and support trees, compute the similarity ϕ θ by cosine similarity on tree representations for every query-support snippet pair, normalize, and form a convex combination over the entire available edit representations from support set. Finally, Ours is the proposed model which learns the similarity measure ϕ θ as described in Section 3, where we additionally consider an ensemble of multi-extent similarity scores, as shown in Eq.

Original: Note that we ﬁnd Graph2Tree contains numerous C# speciﬁc implementations and  currently not applicable for Python, so we do not include this baseline on PyFixer .
Revised: Note that we find Graph2Tree contains numerous C# specific implementations and is currently not applicable for Python, so we do not include this baseline on PyFixer .

Original: All the baselines are under MIT license for public usage.
Revised: All the baselines are under MIT license for public usage.

Original: Protocol We randomly split ﬁxers for few-shot experiments into meta-train and meta-test sets.
Revised: Protocol We randomly split fixers for few-shot experiments into meta-train and meta-test sets.

Original: For
Revised: For

Original: C#Fixer , the meta-train set contains 12 types of ﬁxers and the meta-test set has the rest 4 ﬁxers.
Revised: C#Fixer , the meta-train set contains 12 types of fixers and the meta-test set has the rest 4 fixers.

Original: The meta-train set of PyFixer contains 8 ﬁxers and the meta-test set takes the rest 4.
Revised: The meta-train set of PyFixer contains 8 fixers and the meta-test set takes the rest 4.

Original: To perform a comprehensive empirical evaluation, we repeat the random split procedure and obtain 5 different splits denoted from Split #1 to Split #5.
Revised: To perform a comprehensive empirical evaluation, we repeat the random split procedure and obtain 5 different splits denoted from Split #1 to Split #5.

Original: For meta-training, to simulate the low-resource scenario and mitigate the imbalance on the number of samples per ﬁxer, we take 10 samples for each ﬁxer and follow a standard episode training strategy.
Revised: For meta-training, to simulate the low-resource scenario and mitigate the imbalance on the number of samples per fixer, we take 10 samples for each fixer and follow a standard episode training strategy.

Revised: Every time we construct the support set to train on one query sample, we randomly select the exemplars who are sharing the same fixing type with the query sample in the sampled data.

Original: For meta-testing, we iterate through all samples and each of them as a query snippet at a time, then randomly sample from the rest of its ﬁxer peer to build its support set.
Revised: For meta-testing, we iterate through all samples and each of them as a query snippet at a time, then randomly sample from the rest of its fixer peer to build its support set.

Original: All numerical results are run with 5 different random seeds.
Revised: All numerical results are run with 5 different random seeds.

Original: Mean and standard deviation are reported.
Revised: Mean and standard deviation are reported.

Original: Note that the variance not only stems from the training per se, but also is affected by the random sampling of support set in testing.
Revised: Note that the variance not only stems from the training per se, but also is affected by the random sampling of support set in testing.

Original: Since we ﬁx the random seed every time, all methods are guaranteed to encounter identical query-support combinations in the evaluation under the same seed.
Revised: Since we fix the random seed every time, all methods are guaranteed to encounter identical query-support combinations in the evaluation under the same seed.

Original: All conﬁgurable hyperparameters are tuned on a validation split outside the ﬁve evaluative splits.
Revised: All configurable hyperparameters are tuned on a validation split outside the five evaluative splits.

Original: We defer the model architecture and conﬁgurable hyperparameters to supplementary material.
Revised: We defer the model architecture and configurable hyperparameters to supplementary material.

Original: The accuracy per pair is a binary value obtained by whether the model edits C − to meet exact ground-truth
Revised: The accuracy per pair is a binary value obtained by whether the model edits C − to meet exact ground-truth

Original: C + .
Revised: C + .

Revised: Following Yao et al.

Original: We report both Macro and Micro accuracy since there is a signiﬁcant ﬁxer imbalance in C#Fixer .
Revised: (2021), we report both Macro and Micro accuracy since there is a significant fixer imbalance in C#Fixer .

Revised: K is set to 5 and λ is set to the ensemble over (1.0, 2.0, 4.0, 10.0) by default if no specification is noted.

Revised: We instantiate φ θ (in Eq.

Revised: as neural networks and ϕ θ (in

Revised: Eq.

Original:  Experiments are run on a single NVIDIA RTX 3090 graphical card using Pytorch.
Revised: as cosine similarity. Experiments are run on a single NVIDIA RTX 3090 graphical card.

Revised: We complement more technical details in Appendix B.

Original: 4. R ESULT AND A NALYSIS
Revised: 4. R ESULT AND A NALYSIS

Original: Main numerical results of code editing with 5 support exemplars on C#Fixer and PyFixer are presented in Table 1 and Table 2.
Revised: Main numerical results of code editing with 5 support exemplars on C#Fixer and PyFixer are presented in Table 1 and Table 2.

Original: Comparing to baseline methods, we nearly achieve the best results on all splits  of two datasets, across macro and micro accuracy.
Revised: Comparing to baseline methods, we nearly achieve the best results on all splits [Table] of two datasets, across macro and micro accuracy.

Original: We outperform the second-best baseline method by bringing a absolute improvement range from 8.0% (Macro accuracy on C#Fixer ) to 10.9% ( PyFixer ).
Revised: We outperform the second-best baseline method by bringing an absolute improvement range from 8.0% (Macro accuracy on C#Fixer ) to 10.9% ( PyFixer ).

Original: With the same base architecture (exclude Graph2Tree), comparing to GED and CS, our improvements show the signiﬁcance of multi-extent composition learning of edit representations from support set.
Revised: With the same base architecture (exclude Graph2Tree), comparing to GED and CS, our improvements show the significance of multi-extent composition learning of edit representations from support set.

Original: Quantitative results demonstrate the effectiveness of treating nodes in abstract syntax tree differently and ensemble learning by the meta-learning strategy.
Revised: Quantitative results demonstrate the effectiveness of treating nodes in abstract syntax tree differently and ensemble learning by the meta-learning strategy.

Original: In the following, we presenttwo extra experiments and a visualization case to further investigate our approach. 
Revised: We present extra experiments in this subsection as well as in Appendix C to further investigate our approach. We attach a failure case analysis and a visualization diagram in Appendix D and E, respectively.

Original: More Support Exemplars Figure 2 shows the performance trends when enlarging the size of support set, i.e., offering more resources for code editing.
Revised: More Support Exemplars Figure 2 shows the performance trends when enlarging the size of support set, i.e., offering more resources for code editing.

Original: An estimated regression with uncertainty is plotted from K = 3 to K = 7 .
Revised: An estimated regression with uncertainty is plotted from K = 3 to K = 7 .

Original: It is relatively straightforward that the performance on random selection is not affected by the scale of support set.
Revised: It is relatively straightforward that the performance on random selection is not affected by the scale of support set.

Original: The average edit representation performs differently on two datasets.
Revised: The average edit representation performs differently on two datasets.

Original: Adding more exemplars into support set can help to improve the robustness of the weighted mean representation, or lead it to deviate the representational manifold if high variances exist among exemplars.
Revised: Adding more exemplars into support set can help to improve the robustness of the weighted mean representation, or lead it to deviate the representational manifold if high variances exist among exemplars.

Original: Our approach consistently beneﬁts from more support exemplars and gradually enlarging the margin towards the two baselines.
Revised: Our approach consistently benefits from more support exemplars and gradually enlarging the margin towards the two baselines.

Original: This demonstrates our model is capable to ﬁnd a better composition when there are more options, therefore preserving the possibility of capability enhancement when more resources are available.
Revised: This demonstrates our model is capable to find a better composition when there are more options, therefore preserving the possibility of capability enhancement when more resources are available.

Original: Investigation of Multi-Extent Ensemble Figure 3 shows the functional analyses on multi-extent measurement and its ensemble, where we investigate seven possible options on extent parameter λ , four in a single extent, three in a double extent ensemble, and compare to the full model with four levels of extents plotting in red.
Revised: Investigation of Multi-Extent Ensemble Figure 3 shows the functional analyses on multi-extent measurement and its ensemble, where we investigate seven possible options on extent parameter λ , four in a single extent, three in a double extent ensemble, and compare to the full model with four levels of extents plotting in red.

Original: A single extent in the ﬁrst four rows underperforms the ensemble when using two or four extents.
Revised: A single extent in the first four rows underperforms the ensemble when using two or four extents.

Original: This conﬁrms our methodological hypothesis that a single extent may not be enough to express the similarity between the query-support snippet pair due to the high variances and that ensembling multiple extents helps the model robustness.
Revised: This confirms our methodological hypothesis that a single extent may not be enough to express the similarity between the query-support snippet pair due to the high variances and that ensembling multiple extents helps the model robustness.

Original: The full model with four extents also performs better than the double extent ensemble shown by the median line of the box plot.
Revised: The full model with four extents also performs better than the double extent ensemble shown by the median line of the box plot.

Original: However, adding more extents implies increasing computational costs and hence a trade-off.
Revised: However, adding more extents implies increasing computational costs and hence a trade-off.

Original: Visual Diagram for Node Activation on Query-Support Matching

Original: We visualize the node activation in Figure 4.

Original: The value of an activation is normalized within the query or support snippet to show the relative magnitude of the value.

Original: Matching on individual nodes facilitates query snippet to ﬁnd the valuable reference in Support #1 under ‘BinaryExpression’ regardless of the disturbing content under ‘ConditionalExpression.’

Original: Also, there is a faint activation on the multiple operators in

Original: Support #2 since the objects on this operation is under ‘MemberAccessExpression.’

Original:  R ELATED W ORK
Revised:  R ELATED W ORK

Original: Machine Learning for Code Editing Code editing using machine learning  is receiving increasing attention in recent years.
Revised: Machine Learning for Code Editing Code editing using machine learning has been developed for a long time and is receiving increasing attention in recent years (Menon et al., 2013; Zhang et al., 2019; Tian et al., 2020).

Original: Depending on how a code snippet is represented, the research can be  summarized into two categories, i.e., performing code editing over code token sequences or abstract syntax tree.
Revised: Depending on how a code snippet is represented, the research can be roughly summarized into two categories, i.e., performing code editing over code token sequences or abstract syntax tree.

Original: In the former category, Yin et al.
Revised: In the former category, Yin et al.

Original: ; Chen et al.
Revised: ; Chen et al.

Original: (2019); Yasunaga & Liang (2020) directly generate the expected edited code token sequence, while Shin et al.
Revised: (2019); Yasunaga & Liang (2020) directly generate the expected edited code token sequence, while Shin et al.

Original: ; Vu & Haffari (2018); Dong et al.
Revised: ; Vu & Haffari (2018); Dong et al.

Original: ; Zhao et al.
Revised: ; Zhao et al.

Original: (2019) predict the editing operational sequence, which has been demonstrated to bear more sample efﬁciency.
Revised: (2019) predict the editing operational sequence, which has been demonstrated to bear more sample efficiency.

Original: On the other hand, works in the second category (Yin et al., 2019; Chakraborty et al., 2020; Tarlow et al., 2020; Dinella et al., 2020; Brody et al., 2020; Yao et al., 2021) attempt to edit the trees of programs similarly by either directly generating the edited trees or predicting the tree edit operations.
Revised: On the other hand, works in the second category (Yin et al., 2019; Chakraborty et al., 2020; Tarlow et al., 2020; Dinella et al., 2020; Brody et al., 2020; Yao et al., 2021) attempt to edit the trees of programs similarly by either directly generating the edited trees or predicting the tree edit operations.

Original: Our work follows the scenario of Yin et al.
Revised: The problem addressed in this paper is conceptually related to ‘programming by example’ in software engineering that finds the sharing edit operations among different exemplars and applies it to query snippet (Menon et al., 2013; Osera & Zdancewic, 2015; Ferdowsifard et al., 2020; Meng et al., 2013). Recently, Yin et al.

Original:  Yao et al.
Revised: ; Yao et al.

Original:  Nonetheless, both of the two works have focused on code editing from one shot ofediting exemplar, which may not be sufﬁcient for learning generalizable editing, as we elaborated in Section 1.
Revised: (2021) tackle this problem using deep learning techniques. Nonetheless, both of the two works have focused on code editing from one shot of exemplar, which may not be sufficient for learning generalizable editing, as we elaborated in Section 1.

Original: This has inspired us to investigatethe few-shot code editing problem.
Revised: This inspires us to investigate few-shot code editing.

Original: Few-shot Learning Few-shot learning has been developed in many low-resource scenes (Vinyals et al., 2016;
Revised: Few-shot Learning Few-shot learning has been developed in many low-resource scenes (Vinyals et al., 2016;

Original: Snell et al., 2017; Finn et al., 2017), and with advance in meta seq2seq learning considering the concept of generalized composition (Gu et al., 2018; Lake, 2019; Nye et al., 2020).
Revised: Snell et al., 2017; Finn et al., 2017), and with advance in meta seq2seq learning considering the concept of generalized composition (Gu et al., 2018; Lake, 2019; Nye et al., 2020).

Original: Our work conceptually relates to the matching principle in few-shot learning (Vinyals et al., 2016;
Revised: Our work conceptually relates to the matching principle in few-shot learning (Vinyals et al., 2016;

Original: Snell et al., 2017) but with a different compositional task and a speciﬁc design for robust multiextent abstract syntax tree matching.
Revised: Snell et al., 2017) but with a different compositional task and a specific design for robust multiextent abstract syntax tree matching.

Original: To our best knowledge, we are the ﬁrst to consider few-shot compositional generalization in code editing, which we believe can inspiretechnological development in programming-related applications like code transfer, refactoring, and migration.
Revised: To our best knowledge, we are the first to consider fewshot compositional generalization in code editing, which we believe can inspire development in programming-related applications like code transfer, refactoring, and migration.

Original:  C ONCLUSION
Revised:  C ONCLUSION

Original: In this work, we considered a novel problem in software engineering: code editing with few exemplars.
Revised: In this work, we considered a novel problem in software engineering: code editing with few exemplars.

Original: Based on previous frameworks on code editing using abstract syntax tree to present the computer code snippets, we proposed an adaptive multi-extent composition method to perform varying intermediate representations between a collective tree and individual nodes.
Revised: Based on previous frameworks on code editing using abstract syntax tree to present the computer code snippets, we proposed an adaptive multi-extent composition method to perform varying intermediate representations between a collective tree and individual nodes.

Original: We leveraged an ensemble approach to gather the query-support matching from multiple extents and delivered a robust composition over support editing representations for the query snippet decoding.
Revised: We leveraged an ensemble approach to gather the query-support matching from multiple extents and delivered a robust composition over support editing representations for the query snippet decoding.

Original: Evaluations on two code editing datasets demonstrated the effectiveness of our method over baselines by a large margin.
Revised: Evaluations on two code editing datasets demonstrated the effectiveness of our method over baselines by a large margin.

Revised: To develop this framework into a product, we consider letting the user collect a few exemplars showing their own purpose.

Revised: The tool requests an interaction but also offers full flexibility to the user, and is more adapted to a personal development environment.

Original:  E THICS S TATEMENT
Revised:  E THICS S TATEMENT

Original: We discuss the potential ethical considerations in this section.
Revised: We discuss the potential ethical considerations in this section.

Original: We do not discover a noteworthy negative societal impact originate from our work.
Revised: We do not discover a noteworthy negative societal impact originate from our work.

Original: One minor concern is the research in machine learning for source code may encourage and facilitate the code data collection from open-source projects.
Revised: One minor concern is the research in machine learning for source code may encourage and facilitate the code data collection from open-source projects.

Original: The data may unintentionally involve user privacy like the author’s name, organization, or ﬁle date and the collection process may violate the usage license
Revised: The data may unintentionally involve user privacy like the author’s name, organization, or file date and the collection process may violate the usage license

Original: A E XPERIMENTAL D ETAILS

Original: We collect the PyFixer dataset by separately applying 51 ﬁxers in Python-Future 4 over 5,959 projects written in Python 2 to satisfy the compatibility of Python 3.

Original: We obtain the code pairs by inspecting the changed lines and get the source code before and after the refactoring.

Original: We select 12 types of ﬁxers and extract 200 samples for each ﬁxer from the main data to form the dataset for few-shot learning, while the rest are preserved for model pre-training.

Original: For training, we set the batch size to 16, epochs to 15, learning rate to 1e-4, with a gradient accumulation for every 2 optimized steps.

Original: The extent parameter λ for main experiments are set as an ensemble for 10 , 5 , 2 , and 1 .

Original: The architectural parameters are set the same as Graph2Edit (Yao et al., 2021).

Original: The predictor R is implemented with a multilayer perceptron.

Original: Other detailed implementation or conﬁgurations are in our source code since it is not possible to exhasutively include every detail with plain text.

Original: The PyFixer are working under Python 3.8, having the abstract syntax tree grammar from https://docs.python.org/3.8/library/ast.html.

Original: We list the choice of splits for the two datasets below.

Original: [Table]

Original: [Table]

Original: We use the ﬁxer’s name in Table 3 and the ﬁxer’s index in Table 4 corresponding to the order in the

Original: Python-Future package.

Original: For examples on ﬁxers, C# ﬁxers are included in (Yao et al., 2021)

Original: [Table]

Original: and we provide examples from PyFixer in what follows.

Original: B E DITING E XAMPLES FOR F IXERS IN PyFixer
Revised: A E DITING E XAMPLES FOR F IXERS IN PyFixer

Original: We list the 12 kinds of ﬁxers with names in  Table 5. Fixer 05: lib2to3.ﬁxes [Table] ﬁx
Revised: We list the 12 kinds of fixer names in PyFixer in Table 3.

Original: [Table]
Revised: [Table]

Original: ﬁlter

Original: [Table]ichunk [Table] [Table]
Revised: [Table]

Original: ichunk if

Original: [Table]

Original: [Table]

Original: Fixer 08: lib2to3.ﬁxes

Original: [Table]
Revised: [Table]

Original: ﬁx

Original: [Table]

Original: has_key

Original: [Table]

Original: Fixer 09: lib2to3.ﬁxes.

Original: [Table]

Original: _idioms

Original: [Table]

Original: return type(self)

Original: = = type(other) and self.__dict__ == other.__dict__
Revised: and press enter.

Original: [Table]

Original: return isinstance(self, type(other)) and self.__dict__ ==

Original: other.__dict__

Original: Fixer 15: lib2to3.ﬁxes.ﬁx

Original: [Table] map [Table] map(int, [a for a in kwargs.values() if a !=
Revised: ".format(str(parsed.ip), str(parsed.p)))

Original: kwargs[’releaselevel’]])

Original: [Table]

Original: list(map(int, [a for a in kwargs.values() if a != kwargs[’releaselevel’]]))

Original: Fixer 18: lib2to3.ﬁxes.ﬁx_next

Original: [Table]

Original: second

Original: [Table]

Original: chunk

Original: [Table]

Original: second

Original: [Table]

Original: [Table]

Original: Fixer 23: lib2to3.ﬁxes

Original: [Table]

Original: input

Original: [Table]

Original: raw

Original: [Table]

Original: input("Start the server on 0:1 and press enter.".format(str(parsed.ip), str(parsed.p)))

Original: [Table]

Original: input("Start the server on 0:1 and press enter.".format(str(parsed.ip), str(parsed.p)))

Original: Fixer 34: lib2to3.ﬁxes.ﬁx_zip
Revised: Fixer 34: lib2to3.fixes.fix_zip

Original: C − context.update(zip(inlines_names, kwargs.get(’inlines’, [])))
Revised: C − context.update(zip(inlines_names, kwargs.get(’inlines’, [])))

Original: C + context.update(list(zip(inlines_names, kwargs.get(’inlines’, []))))
Revised: C + context.update(list(zip(inlines_names, kwargs.get(’inlines’, []))))

Original: Fixer 34: lib2to3.ﬁxes.ﬁx_absolute_import
Revised: Fixer 34: lib2to3.fixes.fix_absolute_import

Original: C − from elks import Elks
Revised: C − from elks import Elks

Original: C + from .elks import Elks
Revised: C + from .elks import Elks

Original: Fixer 41: lib2to3.ﬁxes.ﬁx_future_standard_library
Revised: Fixer 41: lib2to3.fixes.fix_future_standard_library

Original: C − import urlparse
Revised: C − import urlparse

Original: C + import urllib.parse
Revised: C + import urllib.parse

Original: Fixer 42: lib2to3.ﬁxes.ﬁx_future_standard_library_urllib
Revised: Fixer 42: lib2to3.fixes.fix_future_standard_library_urllib

Original: C − from urllib2 import HTTPError, urlopen, Request
Revised: C − from urllib2 import HTTPError, urlopen, Request

Original: C + from urllib.request import urlopen, Request
Revised: C + from urllib.request import urlopen, Request

Original: Fixer 42: lib2to3.ﬁxes.ﬁx_print_with_import
Revised: Fixer 42: lib2to3.fixes.fix_print_with_import

Original: C − print(’site_data_dir’, app.locations.site_data_dir)
Revised: C − print(’site_data_dir’, app.locations.site_data_dir)

Original: C + print((’site_data_dir’, app.locations.site_data_dir))
Revised: C + print((’site_data_dir’, app.locations.site_data_dir))

Original: Fixer 49: lib2to3.ﬁxes.ﬁx_unicode_keep_u
Revised: Fixer 49: lib2to3.fixes.fix_unicode_keep_u

Original: C − username =
Revised: C − username =

Original: unicode(origin.getFrom()).split(’/’)[1].replace(" ","")
Revised: unicode(origin.getFrom()).split(’/’)[1].replace(" ","")

Original: C + username =
Revised: C + username =

Original: str(origin.getFrom()).split(’/’)[1].replace(" ","")
Revised: str(origin.getFrom()).split(’/’)[1].replace(" ","")

Revised: B E XPERIMENTAL D ETAILS

Revised: We collect the PyFixer dataset by separately applying 51 fixers in Python-Future 4 over 5,959 projects written in Python 2 to satisfy the compatibility of Python 3.

Revised: We obtain the code pairs by inspecting the changed lines and get the source code before and after the refactoring.

Revised: We select 12 types of fixers and extract 200 samples for each fixer from the main data to build the dataset for few-shot learning, while the rest are preserved for model pre-training.

Revised: For training, we set the batch size to 16, epochs to 15, learning rate to 1e-4, with a gradient accumulation for every 2 optimized steps.

Revised: The extent parameter λ for main experiments are set as an ensemble for 10 , 5 , 2 , and 1 .

Revised: The architectural parameters are set the same as Graph2Edit (Yao et al., 2021).

Revised: The predictor R is implemented with neural networks in two layers with Leaky ReLU.

Revised: The learnable function φ θ ( · , · ) is implemented with one linear layer followed by cosine similarity between the two input terms.

Revised: The function ϕ ( · , · ) is a cosine similarity function on edit representation.

Revised: Other detailed implementation or configurations are in our source code since it is not possible to exhasutively include every detail with plain text.

Revised: The following equation describes the calculation of macro and micro accuracy.

Revised: Consider a set of class C , T c is the number of correctly edited samples in class c , N c is the total number of samples in class c .

Revised: These two metrics can be expressed by

Revised: [Equation]

Revised: Note that, in our experiments, an edited code is considered “correct” only when it is exactly the same as the ground truth in both syntax and semantics.

Revised: The PyFixer are working under Python 3.8, having the abstract syntax tree grammar from https://docs.python.org/3.8/library/ast.html.

Revised: We list the choice of splits for the two datasets below.

Revised: [Table]

Revised: [Table]

Revised: We use the fixer’s name in Table 4 and the fixer’s index in Table 5 corresponding to the order in the

Revised: Python-Future package.

Revised: C A DDITIONAL E XPERIMENT

Revised: We extend our experiments by considering the ‘Hit-1-in-5’ and ‘Hit-5-in-5’ cases when editing with one exemplar from the given few exemplars.

Revised: In the ‘Hit-1-in-5’ case, we separately decode the query code snippet using the K exemplars and obtain K results.

Revised: We count the result of the query sample as correct if any of these K decoding results match with the ground truth.

Revised: Similarly, in the ‘Worst’ case, we count it as correct when all of these K results are correct.

Revised: Note that both the ‘Hit-1-in-5’ and ‘Hit-5-in-5’ cases are not real in practical usage since we only expect one output from the editing system.

Revised: Giving possible answers as many as it can is not user-oriented and not scalable.

Revised: The ‘Hit-1-in-5’ and ‘Hit-5-in-5’ cases can be understood as the upper and the lower bound of results if we randomly select one exemplar from the support set

Revised: but they are almost not achievable.

Revised: We include an experiment using every exemplar in Figure 4.

Revised: [Table]

Revised: [Table]

Revised: [Table]

Revised: [Table]

Revised: [Table]

Revised: D F AILURE C ASE

Revised: We analyze the failure case in this section.

Revised: A failure case on editing the ‘&&’ logical operation is presented in Table 8.

Revised: In this case, most of the exemplars showcase the editorial pattern with complicated context, thus it is hard for our algorithm to extract the sharing editing.

Revised: Meanwhile, two of these exemplars concurrently edit with the attribute ‘Any()’ and consequently mislead the query code editing.

Revised: E V ISUAL D IAGRAM FOR N ODE A CTIVATION ON Q UERY -S UPPORT M ATCHING

Revised: We visualize the node activation in Figure 5.

Revised: The value of an activation is normalized within the query or support snippet to show the relative magnitude of the value.

Revised: Matching on individual nodes facilitates query snippet to find the valuable reference in Support #1 under ‘BinaryExpression’ regardless of the disturbing content under ‘ConditionalExpression.’

Revised: Also, there is a faint activation on the multiple operators in Support #2 since the objects on this operation is under ‘MemberAccessExpression.’