NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

MATCH: Task-Driven Code Evaluation through Contrastive Learning

Marah Ghoummaid, Vladimir Tchuiev, Ofek Glick, Michal Moshkovitz, Dotan Di Castro

TL;DR

This paper introduces MATCH, a novel reference-free metric for evaluating AI-generated code. By using contrastive learning to create embeddings for code and task descriptions, MATCH better correlates with functional correctness and human preferences than existing metrics, especially when reference code is unavailable.

What Problem Does This Paper Address?

The rapid advancement of AI code generation tools like GitHub Copilot, which now accounts for a significant portion of code on GitHub, has created a critical need for effective evaluation methods. Traditional approaches like unit tests are often impractical due to scalability and cost issues. Existing metrics have limitations: syntactic similarity metrics (e.g., BLEU) fail to capture functionality, and reference-based metrics (e.g., CodeBERTScore) require ground-truth code, which isn't always available. While some reference-free methods exist (e.g., ICE-Score), they can be slow or computationally expensive. This paper addresses the gap for a practical, reference-free evaluation metric that accurately assesses code quality.

Methods

MATCH employs a contrastive learning approach to learn meaningful embeddings for both natural language task descriptions and code snippets. The core idea is to train a model that can bring embeddings of a task description and its corresponding correct code closer together in a shared space, while pushing apart embeddings of incorrect code or unrelated tasks.

The architecture involves:

  1. Initial Embeddings: Separate encoders (text encoder for task descriptions, code encoder for code snippets) generate initial embeddings. These encoders can be pre-trained or trained from scratch.
  2. Enhanced Embeddings Layer: This layer integrates information from both the task description and code snippet embeddings. Two specific implementations are explored:
  3. Cross-Attention: Uses cross-attention mechanisms to allow each input (text/code) to query the other, enriching their representations.
  4. Linear: A simpler approach that applies linear transformations to project the initial embeddings into a shared space.
  5. Similarity Score Calculation: Cosine similarity is used to compute the similarity between the enhanced embeddings. This similarity score forms the final MATCH score.

The model is optimized using contrastive loss objectives tailored for both binary (correct/incorrect) and continuous (quality score) labels.

Datasets

  • HumanEval: Used for evaluating functional correctness. This dataset provides natural language descriptions, input-output test cases, and human-written reference solutions for programming tasks. The paper uses an extension (HumanEval-X) translated into multiple languages (Java, C++, Python, JavaScript).
  • MBPP-Eval: A large-scale dataset used for evaluating functional correctness with pass-rate labels. It includes natural language descriptions, reference solutions, and multiple generated code candidates with automatically constructed test cases.
  • CoNaLa: Used for evaluating correlation with human preferences. This dataset consists of Python code snippets generated from natural language instructions, with human annotations grading code quality on a scale of 0-4.

Key Insights and Ideas

  • Reference-free evaluation is crucial: The paper highlights that many real-world scenarios lack readily available reference code, making reference-based metrics less practical. MATCH's reference-free nature is a significant advantage.
  • Contrastive learning for code semantics: By learning to distinguish between correct and incorrect code relative to a task description, MATCH captures functional and semantic correctness better than simple syntactic similarity.
  • Task description is key: The effectiveness of MATCH hinges on its ability to leverage the natural language task description to understand the intent behind the code, allowing it to tolerate minor syntactic errors if the core logic is sound.
  • Language-specific encoders offer benefits but have trade-offs: While language-specific encoders generally improve correlation with functional correctness, a base encoder can be more flexible and perform well, especially for human preference correlation.
  • Linear enhancement layers are often sufficient and efficient: For many scenarios, a simpler linear enhancement layer achieves strong results, offering a good balance between performance and computational cost.

Key Results

  • MATCH consistently achieves higher or comparable correlations with functional correctness (using Kendall's Tau, Spearman, and Pearson metrics) across multiple programming languages compared to baselines like BLEU, ROUGE, METEOR, CodeBERTScore, and ICE-Score.
  • In experiments with HumanEval, MATCH (specifically variants like MATCH (LS(F), Linear) and MATCH (Base(T), CA)) demonstrated superior alignment with functional correctness.
  • On the MBPP-Eval benchmark, MATCH (using the g+n variant for comparison) showed stronger alignment with functional correctness than CodeScore (g+n), without requiring reference code.
  • MATCH also showed strong correlation with human preferences on the CoNaLa benchmark, often outperforming other metrics.
  • The paper shows that MATCH can effectively differentiate between correct and incorrect code snippets, even when other metrics struggle (as illustrated in the examples).

Limitations and Future Work

  • Production-level code evaluation: MATCH is primarily designed for developer-facing tools and early-stage prototyping. For production-level code, it may not be sufficient on its own and should be supplemented with unit tests or compilation checks, as it tends to assign high scores to syntactically and semantically correct code even with minor typos.
  • Model fine-tuning: While MATCH performs better when the underlying model is fine-tuned on task-specific data, this process can be computationally expensive. However, the paper notes that MATCH still achieves competitive performance even without fine-tuning.
  • Out-of-distribution tasks: The effectiveness of MATCH on entirely new or out-of-distribution tasks remains uncertain, a challenge common to most evaluation metrics.
  • Future Work: The authors suggest extending MATCH to evaluate other aspects of code quality beyond functional correctness and human preference, such as efficiency, readability, maintainability, and security. Investigating robustness under imperfect or noisy inputs is also a promising direction.

Summary updated

BibTeX
@inproceedings{ghoummaid2025match,
  author = {Marah Ghoummaid and Vladimir Tchuiev and Ofek Glick and Michal Moshkovitz and Dotan Di Castro},
  title = {{MATCH: Task-Driven Code Evaluation through Contrastive Learning}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2025},
}
Figure