SQL-Commenter: Aligning Large Language Models for SQL Comment Generation with Direct Preference Optimization
Lei Yu, Peng Wang, Jingyuan Zhang, Xin Wang, Jia Xu, Li Yang, Changzhi Deng, Jiajia Ma, Fengjun Zhang

TL;DR
This paper introduces SQL-Commenter, a method that improves SQL comment generation by combining extensive dataset construction, continual pre-training, supervised fine-tuning, and preference optimization, significantly outperforming existing models.
Contribution
It presents a novel approach integrating preference optimization with large language models for more accurate and context-aware SQL comment generation.
Findings
SQL-Commenter outperforms baselines on BLEU-4, METEOR, and ROUGE-L metrics.
Human evaluation confirms higher quality comments in correctness, completeness, and naturalness.
Constructed a comprehensive dataset of complex SQL queries with expert-verified comments.
Abstract
SQL query comprehension is a significant challenge due to complex syntax, diverse join types, and deep nesting. Many queries lack adequate comments, severely hindering code readability, maintainability, and knowledge transfer. Automated SQL comment generation faces two main challenges: limited datasets that inadequately represent complex real-world queries, and Large Language Models' (LLMs) insufficient understanding of SQL-specific semantics. Our empirical analysis shows that even after continual pre-training and supervised fine-tuning, LLMs struggle with complex SQL semantics, yielding inaccurate comments. To address this, we propose SQL-Commenter, an advanced method based on LLaMA-3.1-8B. We first construct a comprehensive dataset of complex SQL queries with expert-verified comments. Next, we perform continual pre-training on a large SQL corpus to enhance the LLM's syntax and…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsNatural Language Processing Techniques · Topic Modeling · Semantic Web and Ontologies
