Predicting Code Generation Failures from Language Model Attention

Abstract

Language models can generate plausible code that fails its tests. This thesis investigates whether internal attention patterns predict failure before generation finishes, allowing computation to shift toward more promising candidates. The student will build on the Prober repository to train and evaluate lightweight prediction models.

Supervision

Motivation

Generating several solutions increases the chance of finding working code but consumes computation. Early failure predictions could reduce this cost, provided they do not discard too many successful candidates. Prober already supports code generation, test execution, and attention feature extraction, providing a foundation for studying this tradeoff.

Goal

The student will evaluate whether attention-based predictions improve code generation under a fixed computation budget. Expected deliverables include:

Requirements

Strong Python and machine learning skills, with experience in PyTorch. Familiarity with transformers, software testing, and basic statistics is expected; GPU computing experience is helpful.

Pointers

Contact

Roman Machacek (roman.machacek@unibe.ch)