Type-Stability-Aware Hallucination Detection for Domain-Specific Code Generation LLMs

Code generation by large language models (LLMs) has advanced rapidly toward practical deployment, yet the detection and suppression of code hallucinations—generated code that appears syntactically valid but is semantically incorrect—remains an open challenge. This paper proposes a method that leverages type stability signals intrinsic to Julia's type system as an endogenous indicator of hallucination. The approach comprises: (1) a four-axis evaluation framework (stability, boundary compliance, hallucination, coherence) driven by an internal type-stability prediction head; (2) a Quality Gate rendering ternary COMMIT/REPAIR/HALT verdicts with a self-repair loop; (3) a phased generation protocol constraining generation to struct definitions → function signatures → implementations; and (4) a definition-aware attention mechanism maintaining distance-independent attention to definition sites. Integrated into a 66M-parameter domain-specific Transformer, a tendency toward positive correlation between type-stability scores and hallucination rates is observed. These preliminary findings raise the possibility that directly injecting domain knowledge of the target language's type system into the model architecture may contribute to Compute-Efficient Reliability without relying on massive model scale.

Authors

Publication Details

Journal
Zenodo (CERN European Organization for Nuclear Research)
Published
2026-04-07
DOI
https://doi.org/10.5281/zenodo.19448154
Primary Topic
Topic Modeling
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Type-Stability-Aware Hallucination Detection for Domain-Specific Code Generation LLMs

Mitsuro Matsuta
Zenodo (CERN European Organization for Nuclear Research)
Topic Modeling
article

Type-Stability-Aware Hallucination Detection for Domain-Specific Code Generation LLMs

Mitsuro Matsuta
article en

Abstract

Code generation by large language models (LLMs) has advanced rapidly toward practical deployment, yet the detection and suppression of code hallucinations—generated code that appears syntactically valid but is semantically incorrect—remains an open challenge. This paper proposes a method that leverages type stability signals intrinsic to Julia's type system as an endogenous indicator of hallucination. The approach comprises: (1) a four-axis evaluation framework (stability, boundary compliance, hallucination, coherence) driven by an internal type-stability prediction head; (2) a Quality Gate rendering ternary COMMIT/REPAIR/HALT verdicts with a self-repair loop; (3) a phased generation protocol constraining generation to struct definitions → function signatures → implementations; and (4) a definition-aware attention mechanism maintaining distance-independent attention to definition sites. Integrated into a 66M-parameter domain-specific Transformer, a tendency toward positive correlation between type-stability scores and hallucination rates is observed. These preliminary findings raise the possibility that directly injecting domain knowledge of the target language's type system into the model architecture may contribute to Compute-Efficient Reliability without relying on massive model scale.

Zenodo (CERN European Organization for Nuclear Research)
Openalex Percentile: Top 21%
Topic Modeling
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Type-Stability-Aware Hallucination Detection for Domain-Specific Code Generation LLMs — Mitsuro Matsuta · Zenodo (CERN European Organization for Nuclear Research) (2026) | TGRS Research Map | TGRS