Repository logo
Log in(current)
Repository logoMIT Open ScholarshipDSpace@MIT
  1. Home
  2. MIT Libraries
  3. MIT Theses
  4. Graduate Theses
  5. Eliminating Hallucination-Induced Errors in Code
    Generation with Functional Clustering

Eliminating Hallucination-Induced Errors in Code
Generation with Functional Clustering

Thumbnail Image
Download
Name

ravuri-cravuri-meng-eecs-2025-thesis.pdf

Description
Thesis PDF
Size

2.13 MB

Format

Adobe PDF

Checksum (MD5)

3afca66980d4b634de3303ad2b783d30

Author(s)
Ravuri, Chaitanya
Advisor(s)
Amarasinghe, Saman
Date Issued
May 2025
Publisher
Massachusetts Institute of Technology
Abstract
Modern code–generation LLMs can already solve a large fraction of programming problems, yet they still hallucinate subtle bugs that make their outputs unsafe for autonomous deployment. We present functional clustering, a black-box wrapper that eliminates nearly all hallucination-induced errors while providing a tunable confidence score. The wrapper samples many candidate programs, executes each on a self-generated test suite, and clusters candidates whose I/O behavior is identical; the empirical mass of the largest cluster serves as an exact confidence estimate. A single scalar threshold on this estimate lets users trade coverage for reliability with exponential guarantees. On LiveCodeBench our verifier preserves baseline pass@1 on solvable tasks yet slashes the error rate of returned answers from ∼65% to 2%, and drives it to 0% at a conservative threshold while still answering 15.6% of prompts. Manual audits show that the few residual mistakes stem from prompt misinterpretation, not random generation noise, narrowing future work to specification clarity. Because the method requires only sampling and sandbox execution, it applies unchanged to closed-source APIs and future models, offering a practical path toward dependable, autonomous code generation.
MIT Department
Massachusetts Institute of Technology. Department of Electrical Engineering and Computer Science
Terms of Use
In Copyright - Educational Use Permitted
https://rightsstatements.org/page/InC-EDU/1.0/
Copyright retained by author(s)
Persistent DSpace Link
https://hdl.handle.net/1721.1/162941
Repository logo
PrivacyPermissionsAccessibilityContact us
Repository logo
Notify us about copyright concerns.