SUT: Active Defects Probing for Transcompiler Models

Mengnan Qi, Yufan Huang, Maoquan Wang, Yongqiang Yao, Zihan Liu, Bin Gu, Colin B. Clement, Neel Sundaresan

Introduction

Transcompilers—models designed to translate code between programming languages—face a unique challenge: unlike natural language, code requires absolute precision. A single character error can render a program non-functional. Current evaluation metrics like BLEU prioritize textual similarity over functional correctness, often failing to capture whether a translated program actually works. Furthermore, standard "Computational Accuracy" (CA) metrics provide only a binary pass/fail result, offering little insight into why a model failed.

To address these gaps, researchers presented SUT (Syntactic Unit Tests) at EMNLP 2023. SUT is a diagnostic benchmark that uses unit tests to pinpoint specific syntactic failures. Alongside this, the authors introduced S-Tuning, a fine-tuning method that helps models master complex language-specific structures by simplifying them during training.

Methodology: The SUT Framework and S-Tuning

The proposed solution consists of a diagnostic harness and a specialized training strategy designed to move beyond simple text comparison.

The SUT Harness

The SUT harness wraps translated functions in a Python unittest environment to measure functional success. It introduces two primary metrics:

  1. SUT Acc (Accuracy): Measures the pass rate on specific unit tests.
  2. SETS (Syntax Element Test Score): This "active probing" metric uses Lasso regression to statistically disentangle which specific syntax element (e.g., a switch statement vs. an if statement) is causing a failure when multiple elements are present in a test case.
Overview of the SUT evaluation framework and diagnostic process.

S-Tuning (Syntax Fine-Tuning)

To remediate the defects identified by SUT, the authors developed S-Tuning, an unsupervised data augmentation method. It involves three steps:

  • Modification: Complex source code (e.g., C++ prefix increment ++i) is rewritten into a logically equivalent but simpler form closer to the target language (e.g., i += 1; x = i).
  • Translation: An existing model translates this simplified version.
  • Reinforcement: The model is fine-tuned to map the original complex code to the successful translation of the simplified version, effectively teaching it the underlying logic of complex syntax.

Key Results and Insights

The evaluation revealed an "Elementary Error Paradox": even state-of-the-art models like gpt-3.5-turbo struggle with basic syntax. While these models can solve complex algorithms, they often hallucinate non-existent structures (like do-while loops in Python) or fail on basic operators.

Performance comparison of various transcompiler models across different language pairs and evaluation metrics.

As shown in the results, gpt-3.5-turbo achieved an average SUT Accuracy of 66.41%, indicating significant room for improvement in basic syntactic handling. S-Tuning proved highly effective; applying it to the TransCoder-ST model resulted in an 18.4% improvement in SUT accuracy and a 2.1% boost in overall computational accuracy for C++ to Python translation.

Conclusion

SUT provides a much-needed granular view of transcompiler failures, moving the field toward functional rather than just textual accuracy. While currently limited to four languages and requiring some manual rule crafting for S-Tuning, it establishes a framework for more robust code translation. Future work aims to automate rule discovery and expand support to legacy languages where transcompilation is most critical.

Summary updated

BibTeX
@inproceedings{qi2023sut,
  author = {Mengnan Qi and Yufan Huang and Maoquan Wang and Yongqiang Yao and Zihan Liu and Bin Gu and Colin B. Clement and Neel Sundaresan},
  title = {{SUT: Active Defects Probing for Transcompiler Models}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.emnlp-main.866},
}
Figure