
BinT5
Language1,466 ops222.9M params
A CodeT5-based model that fills in Python type annotations using context chosen by static analysis.
Language · 1,466 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
TypeT5 predicts missing type annotations in Python code by treating type prediction as a code infilling task. The network is a fine-tuned CodeT5, a Transformer sequence-to-sequence model. The paper notes that earlier methods were accurate on the most common types but often performed poorly on rare or complex ones.
Marker tokens are inserted where a type is wanted, and the model outputs the token sequence that encodes the types for the marked locations. Static analysis decides what else the model reads: it builds a usage graph, whose nodes are code elements and whose edges are direct usages, and TypeT5 uses that graph to construct the model's input. The paper limits the total input to 4096 subword tokens.
At inference TypeT5 decodes iteratively, traversing the usage graph twice and adding type signatures from its own predictions to the context, with the second pass in the reverse direction of the first. The paper reports higher overall accuracy than the systems it compares with, particularly on rare and complex types, and fewer type errors. The experiments use the BetterTypes4Py dataset, and the repository says training takes about 11 hours on a single Quadro RTX 8000 GPU.
Key idea. TypeT5 casts type inference as code infilling with CodeT5, uses static analysis to build each prediction's context, and decodes iteratively so earlier type predictions inform later ones.
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
@misc{wei2023typet5seq2seqtypeinference,
title={TypeT5: Seq2seq Type Inference using Static Analysis},
author={Jiayi Wei and Greg Durrett and Isil Dillig},
year={2023},
eprint={2303.09564},
archivePrefix={arXiv},
primaryClass={cs.SE},
url={https://arxiv.org/abs/2303.09564},
}