inferwire
/
AI·5 min read

FASE: Cheap Uncertainty Checks for AI-Generated Code

Waterloo researchers replace costly LLM equivalence checks with code embeddings to estimate whether generated code works, at roughly 0.3% of the runtime.

TL;DR

  • University of Waterloo researchers propose FASE, which estimates whether AI-generated code works by clustering ten samples with embedding models instead of LLM judges [^1].
  • On HumanEval and BigCodeBench, its scores tracked test results better on average than LLM-based semantic entropy, at about 0.3% of the runtime [^1].

Background

Ask a model the same coding task several times and it may return different programs. Semantic entropy turns that spread into an uncertainty signal: group the samples that do the same thing and measure how scattered the groups are [^1]. One large group suggests the model is consistent; many small ones suggest it is guessing. For code, the usual method asks an LLM whether each pair of samples is equivalent, which is slow and depends on the judging model [^1].

What happened

Shizhe Lin and Ladan Tahvildari of the University of Waterloo describe Fast Adaptive Semantic Entropy (FASE), which drops the LLM judge [^1]. An embedding model turns each code sample into a vector, and the cosine distances between all pairs form a distance matrix. From that matrix FASE extracts a minimum spanning tree, the set of shortest links that still connects every sample. The threshold for grouping samples is then set per task from the most common link length in that tree, and the resulting groups feed the entropy formula [^1]. The idea rests on an observation: links between a passing and a failing program were about 1.7–1.8 times the task average in the full matrix, but 3.4–3.6 times in the tree, so the tree separates the groups more clearly [^1].

The authors tested FASE on HumanEval, 164 basic Python problems, and the hard subset of BigCodeBench, 148 problems closer to real-world programming [^1]. Four open 7-billion-parameter models wrote the code: Mistral-7B, CodeLlama-7B, DeepSeek-Coder-7B and Qwen2.5-Coder-7B, with ten samples per task [^1]. They ran two workflows, the coder alone and the coder after an analyst agent that describes the task's data and control flow. FASE was compared with LLM-based semantic entropy, structural entropy built on abstract syntax trees, P(True) self-evaluation and majority voting [^1].

With the Qwen3-Embedding-8B model, FASE improved Spearman correlation with the test pass rate by 25% on average over LLM-based semantic entropy, and the ROC-AUC score by 19% [^1]. It did not win every setting. For CodeLlama without an analyst, classic semantic entropy did better, and for Qwen2.5-Coder with an analyst it reached the best scores, a correlation of 0.70 and an AUC of 0.90 [^1]. The strongest variant overall combined FASE's groups with the structural ones [^1]. The cost gap was large: LLM equivalence checks on ten samples took between 17.63 and 110.98 seconds depending on the model, while building the distance matrix took about 0.02–0.3 seconds [^1].

Why it matters

The authors' motivation is error propagation: in multi-agent coding systems, a mistake made early can travel through every later agent, and many existing checks rely on further, costly LLM calls [^1]. A signal that costs a fraction of a second and needs no test cases could run at every handoff between agents. The paper does not show that yet. It measures how well the score tracks test results, and lists building FASE into agent decisions, such as choosing how deeply to verify, as future work [^1].

The limits matter for anyone tempted to use it as a correctness check. Low entropy means the samples agree, not that they are right: if all of them drift from the intended behavior in the same way, FASE does not flag it [^1]. Embeddings can also miss a single changed operator that reverses what a program does, which is why the syntax-tree combination performed best [^1]. The study covers only 7B open models with simple prompts [^1]. Its own baseline is a warning too: adding the analyst agent had mixed effects on pass rates, and the authors conclude that adding an agent without adapting it to the task does not necessarily help [^1].

Practical example

Say Jonas runs a two-agent pipeline at a small logistics software company: an analyst agent writes notes on what a function needs to do, and a coder agent writes it in Python. Many of the tasks have no tests yet, so Jonas cannot simply run them to find out which code works.

For each task, the coder produces ten candidate solutions. Asking an LLM to compare every pair would cost Jonas, by the paper's measurements, somewhere between 17.63 and 110.98 seconds per batch [^1]. With FASE, an embedding model turns the ten programs into vectors in a fraction of a second, and the spanning tree shows how they group [^1].

On one task, eight programs sit in one tight group and two drift off. Entropy is low, so the function moves on. On another, the ten programs split into five groups. Entropy is high, and Jonas routes that task to a human reviewer and writes tests for it first.

Two traps remain. If the analyst misreads the requirement, all ten programs may implement the same wrong behavior, cluster tightly and pass FASE unnoticed [^1]. And two programs that differ only in one operator can look almost identical to the embedding model [^1]. So Jonas also groups the samples by syntax tree, the combination that did best in the paper, and uses the score to decide where review time goes, never as proof that the code works [^1].

Related gear

We recommend this book because it explains how to evaluate the output of foundation models, including using one model to judge another, the kind of check FASE tries to make cheaper.

AdvertisementAmazon

AI Engineering: Building Applications with Foundation Models

Sources

  1. [1]arXiv — FASE: Fast Adaptive Semantic Entropy for Code Quality