Large language models are good at producing code, but that code frequently fails on functional correctness because the intended behavior is implicit or ambiguous. A new arXiv paper introduces CG2, a contract-guided code generation approach that targets this problem by generating behavioral contracts as part of the coding pipeline.

The abstract describes CG2 as a method for contract-guided code generation, but provides few implementation details. The title indicates that the work involves fine-tuning LLMs specifically for behavioral contract generation, suggesting that the model is trained to produce formal or structured specifications before writing code.

The core idea is to make behavioral requirements explicit so that the generated code can be checked against them. The abstract does not include experimental results or comparisons with other methods, so the effectiveness of CG2 is not yet established from this summary alone.