This thesis addresses the problem of type inference for the Elixir programming language in two complementary parts. The first part develops a formal translation from Elixir’s TypeSpecs, the language’s long-standing type annotation mechanism, to Elixir Types, Elixir’s new set-theoretic types recently introduced into the language. We provide a formalisation of this translation and a corresponding implementation, which is systematically tested, together with an explicit account of the constructs the two systems do not share and of the conservative approximations by which we translate them. This translation serves both as a contribution in its own right and as the enabling infrastructure for the second, empirical part of the work. The second part investigates the fine-tuning of large language models (LLMs) for inferring Elixir Types over legacy, unannotated Elixir code. Leveraging the translation developed in the first part, we construct a training dataset from a corpus of open-source Elixir repositories already annotated with TypeSpecs: each TypeSpec is converted into the corresponding Elixir Type, and a resulting (code, type) pair is retained only when Dialyzer accepts the original TypeSpec and Elixir’s native typechecker accepts the translated annotation, so that every supervision signal has been certified by both analyses. Model inference is evaluated not merely by exact match but against Elixir’s notion of type-compatibility—an extension of subtyping to the setting of gradual types—which provides a semantically meaningful measure of whether a predicted type is safe for the function it annotates. We fine-tune two models of contrasting design on identical data, a decoder-only architecture (Qwen2.5-Coder-7B) adapted parameter-efficiently and a much smaller encoder–decoder (CodeT5+-770M) fine-tuned in full, each under the regime suited to its scale, and compare them under this metric on held-out projects; since scoring a prediction requires a reference, the comparison measures agreement with a function’s declared type rather than the acceptance of an annotation compiled back into its project. The smaller encoder–decoder is the stronger model on both axes, compatible with the reference annotation on 56.3% of functions against 35.9%, and exactly equal to it on 29.5% against 7.7%, at roughly a tenth of the parameters.
Migrating Elixir TypeSpecs to Elixir Types for LLM inference of Elixir type annotations
KIM, JUYOUNG
2025/2026
Abstract
This thesis addresses the problem of type inference for the Elixir programming language in two complementary parts. The first part develops a formal translation from Elixir’s TypeSpecs, the language’s long-standing type annotation mechanism, to Elixir Types, Elixir’s new set-theoretic types recently introduced into the language. We provide a formalisation of this translation and a corresponding implementation, which is systematically tested, together with an explicit account of the constructs the two systems do not share and of the conservative approximations by which we translate them. This translation serves both as a contribution in its own right and as the enabling infrastructure for the second, empirical part of the work. The second part investigates the fine-tuning of large language models (LLMs) for inferring Elixir Types over legacy, unannotated Elixir code. Leveraging the translation developed in the first part, we construct a training dataset from a corpus of open-source Elixir repositories already annotated with TypeSpecs: each TypeSpec is converted into the corresponding Elixir Type, and a resulting (code, type) pair is retained only when Dialyzer accepts the original TypeSpec and Elixir’s native typechecker accepts the translated annotation, so that every supervision signal has been certified by both analyses. Model inference is evaluated not merely by exact match but against Elixir’s notion of type-compatibility—an extension of subtyping to the setting of gradual types—which provides a semantically meaningful measure of whether a predicted type is safe for the function it annotates. We fine-tune two models of contrasting design on identical data, a decoder-only architecture (Qwen2.5-Coder-7B) adapted parameter-efficiently and a much smaller encoder–decoder (CodeT5+-770M) fine-tuned in full, each under the regime suited to its scale, and compare them under this metric on held-out projects; since scoring a prediction requires a reference, the comparison measures agreement with a function’s declared type rather than the acceptance of an annotation compiled back into its project. The smaller encoder–decoder is the stronger model on both axes, compatible with the reference annotation on 56.3% of functions against 35.9%, and exactly equal to it on 29.5% against 7.7%, at roughly a tenth of the parameters.| File | Dimensione | Formato | |
|---|---|---|---|
|
KIM_JUYOUNG_903635.pdf
accesso aperto
Dimensione
725.48 kB
Formato
Adobe PDF
|
725.48 kB | Adobe PDF | Visualizza/Apri |
I documenti in UNITESI sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.
https://hdl.handle.net/20.500.14247/31341