TypeProbe: Recovering Type Representations from Hidden States of Pre-trained Code Models

Giuliano Gorgone, Fausto Carcassi
7/9/2026
cs.CLcs.AIcs.PL

No official code found. Best implementation: anticleiades/TypeProbe (1 star, last commit 2026-07-03).

Abstract

State-of-the-art code models achieve impressive performance, yet the extent to which they internally encode type information remains poorly understood. We probe the residual streams of pretrained code models for internal type representations using a parallel dataset of Java and Python code examples. Our results show that cross-lingual type representations emerge even from untyped code. Moreover, we test whether hidden states linearly encode the result type implied by typed function application by training probes on one language to infer argument and result types in the other. Finally, we find that this structure is partly robust to lexical perturbations and cross-language syntactic variations. To the best of our knowledge, prior work on interpretability of code models has not directly targeted formal type semantics or cross-lingual type representations. We release our code and datasets.

View on arXivView PDF

Code Implementations(1)

TypeProbe: Recovering Type Representations from Hidden States of Pre-trained Code Models

10Mar 14, 20263 months ago

Cite this paper

@article{gorgone2026typeprobe,
  title  = {TypeProbe: Recovering Type Representations from Hidden States of Pre-trained Code Models},
  author = {Giuliano Gorgone and Fausto Carcassi},
  year   = {2026},
  eprint = {2607.08339},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2607.08339v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2607.08339.svg)](https://codeofpaper.com/paper/2607.08339)

Discussion