Would it better if we move the feedback loops into RL-stage of LLM training? Are there some related works?
we were thinking about doing exactly this, the closest current work is probably the amazing "Learning Formal Mathematics from Intrinsic Motivation" by Poesia et al (they use constraints too increase the likelihood of generating correct theorems/proofs during RL) https://arxiv.org/abs/2407.00695
Type-constrained code generation with language models
71–80 of 134 posts
Re: Type-constrained code generation with language models
#72Re: Type-constrained code generation with language models
#73Earlier quoted context omitted.
what do you dislike about it?
TypeScript is arguably one of the weaker statically typed languages, with how it allows `any` to quietly violate the type checked assumptions. It makes it harder to do a lot of the basic typing mistakes in JS, but it doesn't prevent them by any means, especially if you have to interface with (typeless) JS code. So for these reasons alone I would be against using TS as a lingua franca for LLM codegen (as is GP I assum…
But the devil is in the details - some libraries are typed quite crappily, some have unnecessary complex types, and the code that the LLMs was trained on is probably not the best in the world
Re: Type-constrained code generation with language models
#74I think TypeScript is uniquely positioned to be the optimal language for LLMs. Tons of training data (benefiting from all the JS examples as well) plus the structure of types for LLMs to follow and tools to enforce.
[1]: https://microsoft.github.io/TypeChat/blog/introducing-typech...
Re: Type-constrained code generation with language models
#75Also, TypeScript error messages can be a pain. When LLMs encounter something like "SomeType is not assignable," instead of handling it properly, they often just cast it to any. This happens way too often.
Re: Type-constrained code generation with language models
#76I think TypeScript is uniquely positioned to be the optimal language for LLMs. Tons of training data (benefiting from all the JS examples as well) plus the structure of types for LLMs to follow and tools to enforce.
Those who agree might be interested in "Introducing TypeChat" by Anders Hejlsberg + others (2023) [1] [1]: https://microsoft.github.io/TypeChat/blog/introducing-typech...
Re: Type-constrained code generation with language models
#77Also worth checking out MultiLSPy, effectively a python wrapper around multiple LSPs: https://github.com/microsoft/multilspy Used in multiple similar publications, including "Guiding Language Models of Code with Global Context using Monitors" ( https://arxiv.org/abs/2306.10763 ), which uses static analysis beyond the type system to filter out e.g. invalid variable names, invalid control flow etc.
Re: Type-constrained code generation with language models
#78I think TypeScript is uniquely positioned to be the optimal language for LLMs. Tons of training data (benefiting from all the JS examples as well) plus the structure of types for LLMs to follow and tools to enforce.
There are languages that constrain types a lot more tightly than TypeScript, e.g. Kotlin, Rust, and Haskell. The more constrained the types, the more correct the program could be.
Re: Type-constrained code generation with language models
#79Google somewhat did this with javascript in their latest Gemini-2.5 Pro release. But what about doing it for a smaller language? Google isn't going to do that, but there is still a lot of demand.