Alcides Fonseca

40.197958, -8.408312

Finetuning Qwen for a new Programming Language

We have been working on aeon, a programming language with refinement types. Unliked add-on liquid types (LiquidHaskell, LiquidJava or Flux), it was designed to have them threaded throughout the program. Because of that, it has a very weird syntax that I have lately been changing to be as close to Lean as possible, so people don't have to learn yet another programming language.

Because aeon includes program synthesis capabilities, using a bunch of algorithms, my student Su decided to add support for LLM generation of aeon code inside the compiler. Back then, he used a system prompt that explained that the language was and how it related to existing languages.

However, this past year I have been using Sonnet, Opus, different GPTs and they have all been able to synthesize aeon code without a problem. The harness is good enough that it detects other .ae files in the repo and loads them into the context, and LLMs can easily learn languages from examples.

However, I wanted to understand how much fine-tuning alone could help models generate code in new programming languages. With my 3090 TI in hand, I set up the following experience:

I took 100 medium-sized aeon programs from the official repo, split into 80% training and 20% hold-out for evaluation. Each of the two models, Qwen 2.5 Coder 14B and Gwen 3.5-9B, was fine-tuned for 8 hours using LoRA within the limits of the GPU. Then, I assessed whether the generated programs (based on the 20% programs not used in fine-tuning) had a correct syntax.

Eval of aeon code, going from 0 to 70, and from 0 to 80%

The fine-tuned models were able to get it right more than half of times, while the original models were oblivious to this "new" programming language. Qwen 2.5 outperformed Qwen3.5, which is expected, given that smaller models are easier to fine-tune.

As a next step, we could perform fine-tuning, make the new weights available on HuggingFace and automatically download them inside the compiler, if the user has a compatible machine. But because the target user is only myself, I'll just use proper harnesses.

Read next