Elamur Research

Summarize and Generate to Back-translate: Unsupervised Translation of Programming Languages

Paper · 2023 · Wasi Uddin Ahmad, Saikat Chakraborty, Baishakhi Ray et al.

Summary

Translating software into another programming language requires preserving what the program does while changing how it expresses that behavior. Matching familiar words or producing plausible syntax is insufficient: a translated function must still return the right result. “Summarize and Generate to Back-translate” investigates how to learn this transformation without a training collection containing equivalent programs in both languages. Its central problem is a surprisingly stubborn starting point. A system already trained to read and produce several programming languages may nevertheless fail when asked to translate between them.

The authors study PLBART, a pretrained encoder–decoder system, and find that its previous training encourages reconstruction rather than translation. Given Java and a request for Python, it can produce another Java version instead. This behavior blocks ordinary back-translation, a technique from machine translation in which opposing translation directions generate synthetic training examples for one another. If the initial systems mostly copy their inputs, the resulting training process reinforces copying. Knowing how to generate each language separately does not establish the ability to move between them.

The proposed solution uses English documentation as a temporary bridge. First, PLBART learns both code summarization and the reverse task of generating code from a description. These supervised tasks use code paired with documentation, rather than Java paired with equivalent Python. During the beginning of translation training, a program is summarized in English, and that summary is used to generate a program in the other language. The generated program is often inaccurate, but it supplies a synthetic counterpart from which the translator can learn to reconstruct the original. Once direct translation becomes usable, the procedure switches to ordinary back-translation.

The experiments support this bootstrapping argument more strongly than they support any claim of universal superiority. Direct back-translation with PLBART achieves no functionally correct translations under the reported execution measure. With the proposed initialization and temporary summary bridge, computational accuracy reaches 40.4% for Java → Python and 31.9% for Python → Java using greedy decoding and GitHub training data. TransCoder, the main comparison system, obtains 46.9% and 32.6% under those conditions. Changing the translation-training corpus to CodeNet, whose programming exercises resemble the evaluation tasks more closely, raises PLBART’s computational accuracy to 50.9% and 46.5%.

The broader contribution is an account of how to start a learning process whose ordinary initialization fails. Summarization followed by generation is a poor final translator in these experiments, yet it becomes useful as a temporary producer of imperfect training pairs. The paper also demonstrates why evaluation must reach beyond textual resemblance. A system can receive substantial overlap scores while producing no translations that pass the execution tests. Conversely, a correct translation need not reproduce the reference text exactly. The results therefore concern both a training method and the evidence needed to decide whether that method has learned useful program behavior.

Interesting ideas

Use a bridge to unlock a blocked transformation. When a direct mapping is initially unavailable, an intermediate representation can provide a workable route. Here, English connects programming languages through existing documentation. The transferable idea is to look for a representation that already has useful connections to both sides, instead of assuming that the desired direct connection will emerge from reconstruction training alone.

Judge a component by its role in the pipeline. The summary–generation chain performs poorly as a finished translator but helps create a stronger translator. A component can be valuable because it supplies sufficiently useful training material, even when its own outputs are unsuitable for deployment. This distinction matters in synthetic-data generation, weak supervision, and systems that use approximate analyses to propose candidates for stricter downstream checks.

Make scaffolding temporary. The authors use the intermediate route only during the beginning of back-translation. Once direct generation has become possible, the additional transformation is removed. This suggests a general design principle: a mechanism that makes learning possible need not remain in the final inference path. Its duration should be treated as a tunable part of training.

Test the capability needed for initialization. Before relying on multilingual pretraining, the authors inspect cross-language function retrieval and attempt direct translation. These checks expose a mismatch between broad training coverage and the specific operation required next. Similar diagnostics can prevent an engineering pipeline from treating a system’s familiarity with several input types as proof that it can translate, align, or compare them.

Match training material to the behavior being evaluated. A broad software corpus supplies much more code than a collection of programming exercises, yet the exercise-oriented corpus produces stronger execution results here. The lesson is to investigate domain fit alongside scale. Error categories can make that investigation concrete by revealing whether a change helps with types, syntax, identifiers, or program logic.

Separate resemblance, validity, and behavior. Exact text matching, structural comparison, and unit-test execution answer different questions. The paper’s copying baseline and loop-direction example show why these questions cannot be collapsed into one score. This applies wherever an output must satisfy an operational contract, including generated queries, executable plans, symbolic transformations, and structured predictions.

Distinguish available solutions from selectable solutions. Beam search can contain a correct candidate even when the highest-scoring candidate is wrong. Reporting both outcomes reveals whether a system mainly needs better generation or better selection. The same distinction is useful for ambiguous parses, alternative proofs, competing program repairs, and any pipeline that generates several plausible answers before choosing one.

Deep dive: Summarize and Generate to Back-translate: Unsupervised Translation of Programming Languages

How summaries and code generation bootstrap Java–Python translation without parallel programs, and what execution tests reveal about the method. · about 34 minutes to read

How Mova uses it

Mova is a small, transparent language system implemented in Rust. Its native path turns text into dependency trees, frames, and a world representation; separate tools prepare reviewed teaching material and run bounded operational tasks. The connections below are proposed transfers from the paper, assessed against those documented mechanisms. They do not establish that Mova has implemented this paper’s training procedure. The status marks describe overlap with existing mechanisms, and any benefit specific to these proposals remains unverified.

Idea: Use an explicit intermediate representation when direct conversion fails. Where: Introduction, Approach, and Figure 3. Area: semantic representation. Mova: частково є (en → prag → world, and the experimental translation-through-a-meta-world tool described in the architecture). Mova could compare direct conversion with conversion through typed frames or a task world, retaining the information lost at each boundary. The paper motivates trying a bridge; it does not establish that natural-language summaries are sufficient for Mova’s tasks. Why Mova: this fits a system whose useful work already passes through explicit structures.

Idea: Reuse descriptions attached to artifacts as supervision. Where: Code Summarization and Generation, Section 3.1. Area: data. Mova: частково є (the source-bound enrichment packets and reviewed lesson preparation in tools/enrich). Code paired with documentation suggests an analogous use of licensed examples paired with grammatical explanations or dictionary descriptions. Such pairs would need exact source attribution and review before admission. Why Mova: the free dictionary and language core need grounded connections between examples and explanations, not merely more unlabelled text.

Idea: Train or validate both directions of a representation change. Where: Equation 1 and Section 3.1. Area: learning and validation. Mova: частково є (the architecture lists a round-trip tool, while native readers expose intermediate structures). Mova could examine text-to-frame extraction alongside controlled frame-to-text realization, keeping separate checks for each direction. The proposal is not that successful reconstruction proves understanding; it is that opposing directions can expose different missing information. Why Mova: explicit interfaces become easier to inspect when their forward and reverse losses are visible.

Idea: Treat approximate output as a proposal rather than an answer. Where: Section 3.1 and the S&G baseline in Table 2. Area: evidence and admission. Mova: вже є (tools/enrich stages drafts, and worker outputs do not automatically become admitted knowledge). A summary-derived structure could supply candidate examples or repair suggestions while remaining below the admission boundary. The paper provides a concrete case where weak final outputs still help a later learning process. Why Mova: this preserves useful exploratory material without confusing it with trusted linguistic knowledge.

Idea: Diagnose copying before starting a recursive learning loop. Where: Section 3.3 and the direct-BT comparison in Table 2. Area: evaluation. Mova: частково є (negative controls and regression gates are documented, but this particular copying diagnostic is not established). A round-trip learner could preserve its input through an identity shortcut while failing the intended transformation. Mova could include controls that accept reconstruction only when the required representation change actually occurred. Why Mova: deterministic self-use can repeatedly reinforce a mistaken shortcut unless the gate tests the intended operation.

Idea: Check whether an output obeys the requested representation. Where: Figure 1 and Appendix D. Area: syntax and operational contracts. Mova: частково є (typed interfaces, native adapters, and explicit failure states). Before treating an output as a successful conversion, Mova could check its language, schema, or declared capability. This is narrower than semantic correctness but would catch the paper’s Java-output-for-Python-request failure. Why Mova: configured execution depends on satisfying a concrete interface before any deeper interpretation of the result.

Idea: Use temporary scaffolding during learning. Where: Section 3.3 and Algorithm 1. Area: training design. Mova: нове (a proposal for Mova’s bounded learning workflows; no corresponding summary-bridge schedule is established by the digest). A reviewed auxiliary representation could support initial rule induction, then be removed when the native rule path becomes reliable. Its removal would require a held-out gate instead of an assumption that training time implies readiness. Why Mova: this could help native capabilities develop while keeping their eventual operation independent of a teacher.

Idea: Tune how long scaffolding remains active. Where: Implementation Details and Algorithm 1. Area: experimental design. Mova: нове (proposed scheduling control). Mova could compare bounded durations for an auxiliary proposal source, using the same held-out questions and the final native decision procedure. The paper tunes the initial bridge duration, but supplies no measurement transferable to Mova. Why Mova: a useful support mechanism can become an unnecessary bottleneck, and its duration should be measured rather than inherited as a permanent dependency.

Idea: Compare online proposals with a frozen synthetic corpus. Where: Analysis and Table 4. Area: data processing. Mova: частково є (versioned preparation, review, and staging in tools/enrich, plus corpus-cycle artifacts). Mova could compare generating proposals as a bounded study proceeds with preparing a source-bound batch in advance. Both conditions would need identical admission rules and preserved provenance. Why Mova: this would distinguish benefits of adaptive timing from benefits of simply having more reviewed examples.

Idea: Measure cross-representation alignment directly. Where: Motivation and Figure 2. Area: diagnostics. Mova: частково є (typed correspondences and explicitly formalized finite relations in the correspondence tooling). Rather than copying the paper’s embedding method, Mova could test whether equivalent examples from different surface forms map to compatible typed observations. The diagnostic should remain separate from final task accuracy. Why Mova: alignment checks can locate a representation problem before an entire reading or execution pipeline is blamed.

Idea: Keep alignment evidence separate from behavioral evidence. Where: Motivation, Figure 2, and the execution evaluation. Area: evaluation. Mova: частково є (groupants distinguish declared observations, compatibility, and evidence scope). Better correspondence between representations would not by itself establish correct answers or actions. Mova could record an alignment result as one observation and retain independent task checks. Why Mova: this guards against turning a promising structural diagnostic into a broader capability claim than it supports.

Idea: Compare domain fit with corpus size. Where: Training Datasets and Preprocessing, and Table 5. Area: data selection. Mova: частково є (tools/dictindex retains source-domain metadata, while enrichment retrieves related lessons). Mova could compare broad corpus evidence with narrower grammatical or subject-specific material under the same evaluation. A source’s declared domain would remain distinct from an inferred topic. Why Mova: focused examples may repair a particular reader or dictionary gap more effectively than a larger, less relevant collection.

Idea: Deduplicate at several structural levels. Where: Training Datasets and Preprocessing, Section 4.3. Area: data processing. Mova: частково є (tools/sources rejects duplicate manifest ownership, and dictionary queries preserve stable posting identities). The paper removes duplicates before and after function extraction. Mova could likewise distinguish duplicate documents from repeated extracted examples, rather than assuming either check subsumes the other. Why Mova: repeated material can distort frequency estimates and make apparent evidence diversity larger than it is.

Idea: Use language-specific preprocessing. Where: Section 4.3. Area: tokenization. Mova: вже є (English and French tokenization paths, including French elision and contraction handling). The paper’s separate Java and Python tokenizers reinforce the value of matching preprocessing to the language’s actual units. For Mova, proposed changes should be checked through the complete parsing route rather than judged only by token counts. Why Mova: downstream rules cannot reliably recover distinctions that preprocessing has already erased or missegmented.

Idea: Select bounded, independently usable units. Where: Section 4.3 and its definition of standalone functions. Area: task scope. Mova: частково є (bounded enrichment packets and configured deputy capabilities). A new logical or linguistic task could begin with examples whose required context is explicitly available, while recording exclusions for unresolved dependencies. This would be a controlled scope choice, not a claim of general comprehension. Why Mova: small transparent units make failures attributable and reduce hidden assumptions in native execution.

Idea: Treat resource limits as part of the experimental domain. Where: Section 4.3 and Implementation Details. Area: efficiency and evaluation. Mova: вже є (bounded calls, jobs with limits, and declared configuration identities). If Mova caps document size or work budgets, its reports should identify which inputs those limits exclude. The paper’s function-length filter illustrates how resource choices also determine what is measured. Why Mova: a bounded success is useful when its boundary remains visible.

Idea: Evaluate the final behavior alongside textual agreement. Where: Evaluation Metrics, Section 4.2. Area: evaluation. Mova: вже є (school answers, mathematical results, worker checks, and explicit justification paths). For new transformations, Mova could retain exact comparison and structural agreement while adding a task-specific operational check. The paper supports the need for these distinct observations, not any particular Mova score. Why Mova: a fluent explanation or well-shaped frame can still lead to the wrong answer or action.

Idea: Report top-choice success separately from candidate availability. Where: Table 3 and the decoding discussion. Area: search and selection. Mova: частково є (the maths solver has top-K judging, and the parser uses beam search). Mova could assess both the generation of a correct candidate and its selection by Mova’s native selector while keeping the reference answer out of the selection process. Why Mova: this identifies whether engineering effort belongs in candidate generation, scoring, or the final judge.

Idea: Separate invalid outputs from valid but incorrect outputs. Where: Appendices A and B, Tables 6 and 7. Area: error analysis. Mova: частково є (fast-reader misses are classified, and worker failures retain explicit outcomes). A reader or logical module could distinguish malformed structures, missing links, incorrect state updates, and wrong answers in spite of valid execution. Why Mova: repairs should address the stage that failed rather than treating every unsuccessful answer as the same learning problem.

Idea: Diagnose type mismatches explicitly. Where: Appendix B and Table 8. Area: typing and semantics. Mova: частково є (typed mathematical quantities, concept identifiers, and typed complementary observations). Mova could examine whether a failed inference came from confusing entity kinds, units, roles, or collections before proposing a lexical repair. The paper’s TypeError analysis motivates this diagnostic but supplies no Mova measurement. Why Mova: explicit types can turn an opaque downstream failure into a small, inspectable contradiction.

Idea: Use error changes to explain corpus effects. Where: Analysis, Table 5, and Appendix B. Area: experimental analysis. Mova: частково є (rule audits and fast-reader failure classification). When a new dictionary source or lesson collection improves performance, Mova could compare the affected error categories on the same items. A higher total alone would not show that the intended gap was repaired. Why Mova: this supports targeted changes and makes regression decisions easier to justify.

Idea: Build minimal contrasts around semantic traps. Where: Appendix C and Figure 4. Area: reasoning and syntax. Mova: частково є (documented contrast sets, negative controls, and rule gates). The mistaken loop direction suggests tests that preserve most surface material while changing a decisive relation. Mova could use analogous contrasts for transfer direction, negation, temporal order, or quantity change. Why Mova: these checks expose reliance on common surface patterns when the task depends on a less frequent structural distinction.

Idea: Check control direction instead of trusting familiar forms. Where: Figure 4 and Appendix C. Area: program semantics and logical transitions. Mova: частково є (world state changes and quantitative actions have explicit representations). A proposed transformation could retain a typed account of direction, ordering, or change and check it after realization. This extends the example as a hypothesis rather than claiming a general proof technique from the paper. Why Mova: many native tasks depend on whether something increases, decreases, precedes, follows, gives, or receives.

Idea: Compare architectures before assigning credit to a training method. Where: Appendix D and Table 9. Area: experimental fairness. Mova: вже є (CPU and GPU paths have separately declared exactness or approximation status). Mova comparisons should identify different knowledge resources, preprocessing, supervision, and search budgets alongside scores. The paper’s comparison shows why different systems do not isolate the effect of one proposed mechanism. Why Mova: this keeps a practical benchmark comparison from becoming an unsupported causal claim.

Idea: Test whether control information is actually used. Where: Appendix D. Area: interface diagnostics. Mova: частково є (native routing logs coverage and thresholds, while configured workers expose capability selection). An instruction field or mode flag should be checked through an observable consequence, rather than accepted because it exists in an interface. Why Mova: explicit configuration is only useful if the selected native path responds to it as intended.

Idea: Preserve the origin and uncertainty of synthetic examples. Where: Equations 2 and 3 and the discussion of noisy generated pairs. Area: provenance. Mova: вже є (source-bound packets, immutable source versions, and separate reviewed admission). A generated counterpart would retain its generator identity, source artifact, and review status rather than becoming equivalent to observed evidence. Why Mova: recursive use becomes safer and more diagnosable when transformations do not erase the distinction between evidence and proposal.

Idea: Repeat checks according to the kind of variability involved. Where: Limitations. Area: statistics and reproducibility. Mova: частково є (the documented deterministic policy requires repeated identical runs). Repeating a deterministic run checks reproducibility, whereas varying a learned configuration checks sensitivity. Mova could report these as different obligations whenever it evaluates learned parameters or stochastic external components. Why Mova: identical reruns alone cannot establish that an improvement survives a different training initialization.

Idea: Audit source rights separately from source content risks. Where: Limitations and Ethics Statement. Area: data governance. Mova: вже є (tools/sources, dictionary source credits, and explicit licence exclusions). The paper distinguishes licensed source selection from the continued possibility of personal or offensive material. Mova’s free dictionary workflow could preserve that distinction when admitting new corpora. Why Mova: permission to use a source does not establish that every extracted example belongs in a public lexical resource.

Idea: Separate a routing experiment from a permanent architectural commitment. Where: Section 3.3 and the switch to ordinary back-translation. Area: system design. Mova: частково є (groupants and the hybrid-system contract distinguish experimental composition from established capability). A bridge could be tested as one bounded option without redefining all native understanding around it. Why Mova: this permits useful experiments while preserving the project’s preference for explicit logic, rules, and measured statistical components.

The problem and its context

Programming languages differ in more than notation. They offer different libraries, APIs, conventions, and ways to express common operations. The paper begins from the practical observation that software development may need a change of language because requirements change or another language offers more suitable facilities. Translation must therefore preserve behavior while accommodating the target language’s available tools.

The authors contrast this goal with handwritten translation rules. They acknowledge that rules can transform programs, but describe the engineering burden of maintaining many special cases. A mechanical translation can also produce code that is difficult to read. More fundamentally, converting the source program’s library machinery is not necessarily the best way to express the same operation when the target environment already provides an equivalent facility.

This makes program translation attractive as a learning problem. Instead of specifying every transformation, a translation system could learn recurring correspondences from examples. Earlier approaches discussed in the paper include phrase-based statistical translation and tree-to-tree systems. The latter explicitly address syntactic alignment between source and target programs. More recent work uses pretrained representations of code to support translation.

The obstacle is supervision. For ordinary supervised training, the learner needs programs that implement the same behavior in different languages. Such examples must correspond semantically, not merely share a problem name or use similar identifiers. The authors describe the shortage of large parallel program collections as a major reason to investigate an unsupervised alternative.

“Unsupervised” has a specific scope here. The proposed translation training does not require paired Java and Python programs. It does, however, rely on supervised learning from programs and their documentation. Calling the whole procedure free of paired data would therefore hide the resource that makes it work. What disappears is direct cross-programming-language supervision.

Back-translation offers a way to learn from separate collections. Its central move is to take an observed target-language sequence, synthesize a source-language counterpart, and train the forward translator to recover the observed target. Reversing the process supplies training for the opposite direction. The observed side remains real even when its generated partner is noisy.

The paper places this method within earlier research on translation using monolingual material. It discusses integrating a language predictor into a decoder, bidirectional learning, and later unsupervised translation approaches. Improving Neural Machine Translation Models with Monolingual Data and Unsupervised Machine Translation Using Monolingual Corpora Only are among the cited foundations for this line of work. The authors also note applications of related unpaired-learning ideas outside translation, including style transfer and domain adaptation.

The difficulty is getting the reciprocal process started. A backward translator must produce something useful enough to train the forward translator, and vice versa. Existing parallel examples can provide that starting ability. Alternatively, the initial system can already have some cross-language generation capability. Without either condition, synthetic data may simply reproduce a failure.

The authors ask whether multilingual sequence-to-sequence pretraining supplies the missing capability. PLBART is appealing because it already handles code and natural language. Its original contribution is described in Unified Pre-training for Program Understanding and Generation. Yet the objective used during pretraining teaches it to restore damaged inputs. It does not directly teach it to translate a Java function into Python.

The paper’s motivating example makes that distinction visible. A Java function is presented with a request for Python output, but the generated sequence remains Java-like. The system has not failed to produce code in general. It has failed to apply the requested cross-language transformation. Back-translation built on that behavior risks learning an identity operation.

English documentation supplies another possible connection. Developers frequently describe what a function is intended to do, and collections of code with such descriptions already support summarization and generation tasks. The authors use those existing relationships to create an indirect Java–Python route. Their research question is whether this route can initiate direct translation learning even when it is too lossy to be a good translator by itself.

The method, step by step

Establishing the bridge

The procedure begins with a single pretrained sequence-to-sequence system and teaches it related transformations involving Java, Python, and English. In code summarization, code is the input and a natural-language description is the target. In code generation, the description becomes the input and code becomes the target.

This is a change in training objective instead of an addition of handwritten translation rules. The same broad architecture learns to connect each programming language with a shared descriptive language. The authors follow the multilingual adaptation approach associated with Multilingual Translation from Denoising Pre-Training.

The paper expresses summarization training as:

S = TRAIN_Code→Summary(P_c,s)

S denotes the learned summarizer. TRAIN_Code→Summary means supervised sequence-to-sequence training with code as input and a summary as output. P_c,s is the paired code-and-summary training resource used to estimate that transformation. The subscripts c and s identify the code and summary sides.

The reverse task is written separately:

G = TRAIN_Summary→Code(P_c,s)

G denotes the learned code generator. TRAIN_Summary→Code uses the same kind of paired resource with the direction reversed. P_c,s again supplies the observed code–description correspondence. The target programming language determines which kind of code the generator should produce.

The training pairs come from the Java and Python code-to-text benchmark in CodeXGlue, derived from CodeSearchNet. They are not equivalent Java–Python functions. This distinction explains how supervised bridge training can coexist with the paper’s unsupervised program-translation setting.

Understanding ordinary back-translation

Before modifying the training loop, the paper defines its ordinary reciprocal form. Let the forward direction translate from the source programming language into the target programming language. The backward direction performs the reverse mapping. Separate unpaired corpora supply observed programs on each side.

At a training step, the forward translator generates target-language counterparts for observed source-language programs:

P_k^(f) = {(x, f_(k−1)(x)) | x ∈ D_source}

P_k^(f) is the synthetic paired collection produced in the forward direction at step k. The superscript f identifies that generation direction. x is an observed source-language program, and D_source is the source-language corpus. f_(k−1) is the forward translator available from the preceding step.

The backward translator then learns from these pairs:

b_k = TRAIN_target→source(P_k^(f))

b_k is the backward translator after the update at step k. TRAIN_target→source trains it to reconstruct the observed source program from the generated target counterpart. P_k^(f) supplies those paired sequences. The generated side can be noisy because the reconstruction target remains observed code.

The updated backward translator generates counterparts for observed target-language programs:

P_k^(b) = {(b_k(y), y) | y ∈ D_target}

P_k^(b) is the synthetic collection produced by backward translation. y is an observed target-language program from D_target. b_k(y) is its generated source-language counterpart. The pair places the generated source before the observed target.

The forward translator is updated using that collection:

f_k = TRAIN_source→target(P_k^(b))

f_k is the forward translator after training at step k. TRAIN_source→target means ordinary sequence-to-sequence learning in the forward direction. P_k^(b) provides generated inputs paired with observed targets.

These equations describe a reciprocal learning process. The generated sequences change as the translators change, so the synthetic training material is produced during learning rather than fixed permanently in advance. The paper calls this online back-translation.

Why the ordinary initialization fails

PLBART’s reconstruction-oriented pretraining can undermine this process at its first step. If the forward translator returns something close to its input, the supposedly target-language side is not a useful translation. Training the backward direction on such pairs rewards recovering a sequence that has barely changed.

The same problem can occur in reverse. A process that should connect programming languages instead reinforces the ability to reconstruct each language from itself. Adding a language instruction does not guarantee that the decoder will obey it when the preceding training has not taught the required behavior.

The authors therefore initialize the translators with the summarization-and-generation-trained system. They also modify how synthetic partners are created during the beginning of back-translation. Initialization and early synthetic-data generation are both parts of the proposed framework; the main comparison does not independently isolate every contribution of those parts.

Creating early pairs through English

For an observed source program, the bridge first generates an English summary and then generates code in the target language:

P_k^(f) = {(x, G(S(x))) | x ∈ D_source}

P_k^(f) remains the forward-generated paired collection at step k. x and D_source retain their earlier meanings. S(x) is the generated summary of x. G(S(x)) is code generated from that summary in the opposite programming language.

The corresponding target-side construction is:

P_k^(b) = {(G(S(y)), y) | y ∈ D_target}

P_k^(b) contains generated source programs paired with observed target programs. y belongs to D_target. S(y) summarizes the observed target program, and G converts that summary into code in the source language. The notation suppresses the requested output language, which is supplied by the relevant generation task.

The bridge does not need to recover every implementation detail. Its role is to provide imperfect cross-language inputs from which the translator can learn to reconstruct observed programs. The paper explicitly describes these synthetic partners as noisy. Both summarization and generation can introduce errors, and composing them does not remove that uncertainty.

From documented code to direct translation

The steps in order.

From documented code to direct translationStep 1: Gather code paired with descriptions1. Gather code paired with descriptionsStep 2: Learn summarization and code generation2. Learn summarization and code generationStep 3: Initialize opposing translation directions3. Initialize opposing translation directionsStep 4: Generate early partners through English4. Generate early partners through EnglishStep 5: Reconstruct observed programs from partners5. Reconstruct observed programs from partnersStep 6: Switch to direct back-translation6. Switch to direct back-translationStep 7: Evaluate translated functions by execution7. Evaluate translated functions by execution

Switching away from the bridge

Algorithm 1 samples code from both unpaired corpora. During the initial period controlled by m, it creates synthetic counterparts through summarization and generation. After that period, the direct translators generate the counterparts. Training continues by maximizing the likelihood of the observed programs given their generated partners.

The reported implementation uses m = 200. The total-step setting is I = 10, 000. The authors searched m over [100, 1000] with 100-step spacing. The choice matters because the bridge is intended to start direct translation, not permanently replace it.

The paper’s reasoning is that direct cross-language ability develops during the early updates. Once it exists, ordinary back-translation can provide the continuing training signal. This is an empirical design choice supported by the reported experiment, instead of a proof that every dataset or pretrained system will need the same transition point.

Preparing the unpaired code

The main translation-training corpus comes from public GitHub data available through BigQuery. The authors remove duplicates at the program level, extract functions, and then deduplicate again at the function level. These are separate operations because repeated whole files and repeated functions need not have the same boundaries.

An alternative corpus comes from CodeNet. The authors use accepted programming-contest solutions after deduplication. Though that collection contains solutions to programming problems, the experiment treats Java and Python samples as unpaired translation-training material.

Preprocessing follows the syntax of each language. Java functions are tokenized with tree_sitter, while Python uses its standard-library tokenizer. The extracted units are standalone functions: Java static methods and Python functions outside classes. Functions exceeding the maximum length of 256 are filtered because of computational constraints.

These choices simplify the learning target. The system is not trained here to migrate an entire application with its class hierarchy, dependencies, build process, and external services. It learns transformations between bounded function sequences whose surrounding requirements have already been restricted by extraction.

Optimization and decoding

The effective training batch contains 1024 instances at both stages. Training uses 8 Nvidia GeForce RTX 2080 Ti GPUs. The optimizer is Adam, with the reported learning rate of 10e-4 and polynomial decay. Validation BLEU determines the selected checkpoint.

The implementation uses fairseq and float16 computation. The authors make their implementation available under the project name SumGenToBT.

Greedy decoding is the default for validation and evaluation. Additional experiments use beam search, which maintains several candidate translations instead of following only the locally selected continuation. Those experiments distinguish the success of the highest-scoring output from the presence of a successful output somewhere among the retained candidates.

Experiments and results

Data and evaluation conditions

The paper uses different resources for different stages. GitHub supplies unpaired functions for the main back-translation experiment. Its processed Java side contains 7.2 M functions and 752 M tokens; its Python side contains 8.3 M functions and 665 M tokens.

CodeNet is much smaller in the processed collection. The Java side contains 0.42 M functions and 47.3 M tokens, while Python contains 0.15 M functions and 17.0 M tokens. Its source material comes from accepted submissions to problems on AIZU Online Judge and AtCoder. The underlying collection covers 4053 problems.

The supervised bridge uses CodeXGlue’s code–summary pairs. The Java portion contains 164,923 functions and 21.2 M tokens. The Python portion contains 251,818 functions and 44.3 M tokens. These counts describe a different relationship from the unpaired translation corpora: each function is associated with a natural-language description.

Evaluation uses the program-translation benchmark introduced with TransCoder. There are 464 Java → Python examples and 482 Python → Java examples, with 10 unit-test cases associated with each example. The evaluation tasks emphasize data structures and algorithms.

What the metrics establish

BLEU measures overlap between generated text and reference translations using sequences of tokens. The metric originates in Bleu: a Method for Automatic Evaluation of Machine Translation. In this paper, BLEU provides a textual comparison, not a direct execution guarantee.

Exact Match asks whether generated code reproduces a reference translation exactly. This is a strict textual condition. A correct implementation can use another expression or structure and therefore fail Exact Match.

CodeBLEU broadens comparison by combining ordinary token-sequence overlap, weighted overlap, syntax matching through abstract syntax trees, and data-flow matching. Keywords receive special treatment in the weighted component. Still, CodeBLEU remains distinct from executing the translated function on test inputs.

Computational Accuracy, abbreviated CA, counts a function as correct when its translation passes the associated tests. It asks whether the generated function produces the expected behavior for the tested inputs. The paper uses this measure to address the gap between code that resembles a solution and code that works under evaluation.

The tests make CA more operationally informative, but they do not turn it into a proof over every possible input. Its scope remains the supplied cases. That distinction becomes important when interpreting the paper’s strongest claims about functional correctness.

Baselines and the main comparison

The comparison includes a handwritten Java-to-Python converter, j2py; direct translation through the summary–generation chain; and TransCoder. The paper also reports TransCoder with DOBF pretraining, which teaches recovery of original identifiers after their names have been obscured.

Direct PLBART back-translation is the decisive failure control. Its Java → Python BLEU is 31.2, and its CodeBLEU is 36.6, in spite of producing no correct functions under CA. For Python → Java, BLEU is 31.7 and CodeBLEU is 32.1, again with no execution success. Textual overlap therefore does not establish that the requested language conversion occurred.

The following chart compares greedy-decoding computational accuracy in the Java → Python direction.

Java → Python computational accuracy with greedy decoding

The proposed bridge makes PLBART trainable, while TransCoder remains stronger in this GitHub-trained comparison.

Java → Python computational accuracy with greedy decodingPLBART direct BT: 0.0PLBART direct BT0.0PLBART S&G-assisted BT (this paper): 40.4PLBART S&G-assisted BT (this paper)40.4TransCoder: 46.9TransCoder46.9TransCoder with DOBF: 49.2TransCoder with DOBF49.2
The numbers
System or settingCA %
PLBART direct BT0.0
PLBART S&G-assisted BT (this paper)40.4
TransCoder46.9
TransCoder with DOBF49.2

For Python → Java, the same intervention changes PLBART from an unsuccessful copying solution to a translator whose execution score is close to the main TransCoder baseline.

Python → Java computational accuracy with greedy decoding

S&G-assisted training enables useful translation, with DOBF retaining the strongest result among these settings.

Python → Java computational accuracy with greedy decodingPLBART direct BT: 0.0PLBART direct BT0.0PLBART S&G-assisted BT (this paper): 31.9PLBART S&G-assisted BT (this paper)31.9TransCoder: 32.6TransCoder32.6TransCoder with DOBF: 40.4TransCoder with DOBF40.4
The numbers
System or settingCA %
PLBART direct BT0.0
PLBART S&G-assisted BT (this paper)31.9
TransCoder32.6
TransCoder with DOBF40.4

The summary–generation chain on its own obtains CA of 0.2 in each direction. Its BLEU scores are 7.6 for Java → Python and 12.4 for Python → Java. The proposed method therefore cannot be understood as simply deploying that chain as the translator. Its value appears through the subsequent back-translation training.

For the proposed GitHub-trained system, Java → Python BLEU is 64.2, Exact Match is 2.8, and CodeBLEU is 63.4. Python → Java BLEU is 64.1, Exact Match is 2.1, and CodeBLEU is 65.9. These results accompany the execution scores, instead of replacing them.

The effect of domain-matched data

CodeNet changes the character of the training material. General GitHub software includes project-specific APIs and functionality, whereas CodeNet’s accepted solutions resemble the algorithmic exercises used for evaluation.

Java → Python computational accuracy by training corpus

Training on exercise-oriented CodeNet data produces stronger execution results on the algorithmic benchmark.

Java → Python computational accuracy by training corpusGitHub with proposed training: 40.4GitHub with proposed training40.4CodeNet with proposed training (this paper): 50.9CodeNet with proposed training (thispaper)50.9
The numbers
System or settingCA %
GitHub with proposed training40.4
CodeNet with proposed training (this paper)50.9

The CodeNet-trained Java → Python system also reaches BLEU of 65.6, Exact Match of 3.1, and CodeBLEU of 64.7. In the reverse direction, its CA is 46.5, with BLEU of 65.1, Exact Match of 2.5, and CodeBLEU of 68.5.

The improvement is especially informative because the processed CodeNet corpus is smaller than the GitHub corpus. This comparison does not prove that corpus size is unimportant. It shows that the training collection’s relationship to the evaluation domain can materially change the result.

Beam search provides a second view of translation quality. CA@1 B=10 tests the highest-log-probability translation from a beam of size 10. CA@10 B=10 counts a function as successful if an acceptable translation appears anywhere among those candidates.

For Java → Python, PLBART obtains 41.8 under CA@1 B=10 and 50.3 under CA@10 B=10. TransCoder obtains 48.8 and 64.4 for the corresponding settings. Candidate availability improves with the broader search, but the gap between the systems remains visible.

For Python → Java, PLBART obtains 34.5 under CA@1 B=10 and 50.0 under CA@10 B=10. TransCoder obtains 36.0 and 51.1. With CA@5 B=5, PLBART records 45.1 and TransCoder records 44.3.

These are different success conditions. A user receiving only the highest-scoring translation does not automatically benefit from a correct candidate elsewhere in the beam. The larger candidate-set measures reveal potential that a selector might exploit, not accuracy already delivered by the ordinary top-choice interface.

What the ablations show

The strongest control exposes a degenerate solution

The direct-BT comparison tests whether PLBART’s existing multilingual pretraining is sufficient to initiate program translation. Its failure is unusually revealing because conventional overlap scores remain substantial. The system has not become unable to emit familiar code tokens; it has settled into a behavior that misses the intended operation.

The S&G-assisted condition changes that outcome. It supplies a cross-language route during initialization and early training, after which direct back-translation becomes effective. This supports the practical claim that the proposed framework overcomes the observed startup failure.

It does not isolate a universal explanation for all encoder–decoder systems. The experiments use PLBART, and the successful condition includes both supervised S&G adaptation and the early indirect generation procedure. The paper does not provide a complete factorial analysis separating every interaction among those choices.

Alignment improves before final translation is measured

The motivation experiment examines function retrieval across languages. For each of 948 Python functions, the authors retrieve a Java counterpart by nearest-neighbor cosine similarity between function representations.

Unadapted PLBART has a retrieval error rate of 87.5%. After joint summarization-and-generation training, the error rate is 23.7%. This provides evidence that the supervised bridge changes how related programs are positioned relative to one another.

Figure 2 visualizes representations for 8 sample functions using T-SNE. Before adaptation, language membership dominates the illustrated grouping. After adaptation, corresponding programs from different languages appear closer.

The visualization is supportive rather than decisive. Its small illustrated set is not the execution benchmark, and a representation that makes retrieval easier does not necessarily generate a correct program. The retrieval result is best understood as a diagnostic explaining why the new initialization is promising.

Online and offline synthetic pairs are comparable

Table 4 compares the proposed online bridge with an alternative that generates synthetic parallel programs in advance and uses them to warm-start PLBART.

For Java → Python, the offline warm start obtains BLEU of 60.5, Exact Match of 2.8, CodeBLEU of 61.1, and CA of 41.9. The online approach has stronger reported BLEU and CodeBLEU in that direction, but its CA is 40.4.

For Python → Java, the offline condition obtains BLEU of 62.6, Exact Match of 2.4, CodeBLEU of 65.9, and CA of 32.0. The online condition’s CA is 31.9. These results do not establish that online generation is categorically more accurate.

The authors instead emphasize flexibility. The online version exposes m as a direct control over how long the bridge operates. An offline version requires deciding how much synthetic parallel material to generate before training. The comparison suggests that synthetic bootstrapping matters more clearly than the choice between those production schedules.

Error categories help interpret domain adaptation

The CodeNet comparison is accompanied by an error analysis, rather than only a change in the headline score. The authors report that the in-domain condition reduces TypeError and hypothesize that more similar patterns of data-type use explain part of the benefit.

Appendix B shows why this is a plausible target. In Java → Python translation, PLBART produces 61 TypeError cases, compared with 47 for TransCoder. By contrast, its SyntaxError count is 9, while TransCoder’s is 26. The systems therefore have different failure profiles even when their overall computational accuracy is relatively close.

The Python → Java direction shows another distinction. PLBART has 180 compilation errors and 27 runtime errors; TransCoder has 151 compilation errors and 50 runtime errors. A single accuracy figure would hide whether a system more frequently fails before execution or during it.

The detailed PLBART analysis examines its most frequent Java → Python error categories. These include unsuitable index types, unsupported assignments, incompatible operands, missing identifiers, unpacking problems, and references to variables before assignment. Such categories turn “translation failed” into a more actionable description of the missing behavior.

A small loop change can dominate execution

Figure 4 provides a qualitative example in which most of the translated function appears plausible, yet a loop has the wrong direction. The Java source iterates backward; the Python translation uses a range expression that iterates forward.

That translation passes 2 of the 10 tests. Changing range(c-1) to range(c-1,0,-1) would make it pass all the associated cases. The example shows how a compact expression can determine the behavior of an otherwise convincing translation.

The authors attribute the mistake to the greater frequency of the simpler range pattern. That is an interpretation of the example, not a controlled frequency intervention. Its strongest evidential role is to demonstrate that successful parsing and familiar syntax can coexist with a decisive control-flow error.

Limitations

Limits the authors explicitly acknowledge

The authors state that all experiments use one random seed. Results from other seeds may differ. This matters especially when interpreting small separations between conditions: the reported values do not establish how stable their ordering would be across repeated training runs.

They also acknowledge risks in the GitHub training data. The collection may contain personally identifying information or offensive material. Selecting projects by open-source licence does not remove those content risks.

The ethics discussion says that natural-language comments are removed from the translation-training code, which the authors expect to reduce some problematic content. It does not report a dedicated procedure that eliminates personal information or offensive material. Nor does it claim that code generation is free of risks such as vulnerable or biased output.

The selected project licences include Apache, MIT, GPL, and BSD variants identified in the paper. The authors describe their work as research use and discuss their interpretation of licensing conditions. That account should be read as their stated data-use rationale, not as an independently established conclusion about every downstream use.

The paper also leaves a human study of failed translations to future work. Its error analysis categorizes execution outcomes and error messages, but does not fully explain every semantic failure through expert inspection.

The scope of “unsupervised” is limited

A careful reading must preserve the difference between no parallel programs and no supervision. The method uses code–documentation pairs to learn summarization and generation. These pairs carry semantic information supplied by developers and curated into the benchmark resource.

This does not invalidate the paper’s setting. It identifies the resource being substituted for direct program pairs. A domain without useful documentation may not offer the same bridge, and noisy or incomplete descriptions could weaken it.

The method also presupposes a strong pretrained starting point. It is not an experiment in learning code translation from arbitrary raw files without prior code knowledge. Both pretraining and supervised bridge adaptation contribute to the available capabilities before reciprocal translation training becomes effective.

The benchmark is narrower than software migration

The evaluated units are standalone Java and Python functions. Their extraction excludes some dependencies by design, and the maximum-length filter restricts the material further. The results do not establish reliable translation of complete software projects.

The benchmark emphasizes algorithmic problems. It does not directly test the introduction’s broader challenge of choosing corresponding libraries and APIs across language ecosystems. Success on such functions is evidence about that function-level domain, not a demonstration that project-level dependency migration has been solved.

Only Java ↔ Python is evaluated in the proposed framework. The authors discuss other pretrained sequence-to-sequence systems as possible recipients of the method, but the experiments do not demonstrate the same effect across all those systems or additional language pairs.

The strong CodeNet result also has a bounded interpretation. CodeNet resembles the evaluation domain more closely than general GitHub software. The comparison supports domain-sensitive training, but it does not establish that the resulting translator is better on all software encountered outside programming exercises.

Execution tests provide evidence, not equivalence proofs

Computational Accuracy is the most behavior-oriented metric in the paper, yet its correctness judgment depends on the supplied unit tests. A function that passes them may still disagree with the intended program on an untested input.

The qualitative loop example makes the value of execution clear, but it also illustrates why test selection matters. Some inputs fail to expose the wrong direction, while others reveal it. The benchmark’s tests are therefore part of the measurement instrument.

Exact Match has the opposite limitation. It can reject translations that express the same behavior differently. As a result, disagreement between Exact Match and CA is not necessarily a contradiction. The metrics address different conditions, and neither alone provides a complete characterization of program equivalence.

Appendix A’s exact-match counts also should not be silently substituted for the main table’s EM percentages. The appendix discusses exact textual matches within its execution breakdown, while the main comparison reports a reference-matching metric. Their relationship is not fully clarified in the presentation. A cautious account preserves the reported contexts instead of treating all exact-match quantities as interchangeable.

Some explanations remain hypotheses

Appendix D proposes reasons why TransCoder avoids PLBART’s same-language generation problem. These include decoder initialization and the way language identity is supplied. The explanations are plausible accounts offered by the authors, but the paper does not isolate them with controlled architectural interventions.

Similarly, the claim that CodeNet helps through similar data-type usage is supported by the observed error pattern, not established as the exclusive causal mechanism. Domain, code style, vocabulary, and task distribution change together when the corpus changes.

The range example supports a concrete diagnosis of wrong loop direction. The proposed frequency explanation would require a separate intervention to establish causally. Keeping these levels distinct preserves the difference between an observed failure, an explanatory hypothesis, and a validated repair.

Cross-system comparisons are not controlled substitutions

TransCoder and PLBART differ in architecture and training history. Table 9 reports 312 M parameters for TransCoder and 140 M for PLBART. Their encoder and decoder stacks each contain 6 layers, but their attention configurations, representation dimensions, vocabularies, and tokenization schemes differ.

The reported pretraining volumes are 920 B tokens for TransCoder and 87 B for PLBART. Their later training also differs: TransCoder combines denoising and back-translation, whereas the reported PLBART stage uses back-translation.

These differences make the comparison useful as a practical benchmark but insufficient to assign every score difference to the proposed bridge. The paper’s clearest controlled message is that its framework changes PLBART from ineffective direct back-translation to useful translation under the tested conditions.

Reporting does not resolve every operational question

The paper reports its training hardware and resource choices, but it does not supply a comprehensive account of inference latency, project-scale deployment cost, or long-term maintenance. A smaller parameter count alone cannot answer those questions.

Its environmental estimate describes approximately 15kg of emissions and a training duration of 1-2 days under the stated assumptions. That estimate is contextual information about the reported experiment, instead of a universal cost for reproducing the method elsewhere.

There is also a textual inconsistency in the ethics discussion: it says no fine-tuning was performed, while the method explicitly describes adapting PLBART on summarization and generation. The training procedure elsewhere is detailed enough to establish that adaptation occurred. The isolated statement should not override that account.

Finally, the paper does not establish an error bound for the summary bridge. English summaries can omit implementation details, and generated code can add unsupported choices. The method succeeds experimentally because these imperfect partners help training begin; it does not make the intermediate description a lossless representation of program semantics.

What came after

No later citing study is identified here, so there is no supported basis for attributing a subsequent extension, replacement, or new result to this paper.

The work nevertheless leaves clear research questions. Its own discussion points towards human analysis of semantic failures, closer investigation of type-related errors, and a better account of why initialization and language-control mechanisms affect back-translation. Extending the method beyond the tested function-level setting would also require new evidence.

Its lasting methodological proposition is precise: an indirect transformation can be useful as temporary training support even when it is a weak final solution. Whether that proposition transfers to another system depends on the available bridge data, the failure of the direct initialization, and evaluation of the behavior that ultimately matters.

Cite

Cite as Wasi Uddin Ahmad, Saikat Chakraborty, Baishakhi Ray and Kai-Wei Chang. 2023. Summarize and Generate to Back-translate: Unsupervised Translation of Programming Languages. Proceedings of the 17th Conference of the European Chapter of the Association for Computational Linguistics.

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.18653/v1/2023.eacl-main.112

@inproceedings{ahmad2023summarize,
  title = {{Summarize and Generate to Back-translate: Unsupervised Translation of Programming Languages}},
  author = {Wasi Uddin Ahmad, Saikat Chakraborty, Baishakhi Ray and Kai-Wei Chang},
  booktitle = {Proceedings of the 17th Conference of the European Chapter of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.eacl-main.112},
  url = {https://doi.org/10.18653/v1/2023.eacl-main.112}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/ahmad-2023-summarize-generate-back-translate-unsupervised/