CodeUltraFeedback: An LLM-as-a-Judge Dataset for Aligning Large Language Models to Coding Preferences

TL;DR

CodeUltraFeedback uses LLM-as-a-Judge to evaluate LLM alignment with coding preferences, enhancing model alignment.

cs.SE 🔴 Advanced 2024-03-14 5 views
Martin Weyssow Aton Kamanda Xin Zhou Houari Sahraoui
large language models code generation automated software engineering reinforcement learning from AI feedback direct preference optimization

Key Findings

Methodology

CodeUltraFeedback employs the LLM-as-a-Judge approach, using GPT-3.5 to score and provide detailed feedback on 40,000 responses from 14 LLMs. The dataset includes 10,000 coding instructions, each annotated based on five coding preferences. CodeLlama-7B-Instruct is optimized using supervised fine-tuning and AI feedback reinforcement learning.

Key Results

  • Responses from GPT-3.5 and GPT-4 show superior alignment with coding preferences compared to open-weight models.
  • CodeLlama-7B-Instruct outperforms the original model on the HumanEval+ benchmark, improving functional correctness.
  • Using DPO and SFT, CodeLlama-7B-Instruct surpasses larger LLMs across all coding preferences.

Significance

This study fills a gap in LLM alignment with coding preferences through the CodeUltraFeedback dataset, advancing model alignment and AI feedback reinforcement learning in automated software engineering. It enhances both functional correctness and alignment with developer expectations.

Technical Contribution

The study introduces a novel LLM-as-a-Judge approach, combining DPO and SFT techniques, significantly enhancing LLM alignment with coding preferences. It provides a more refined preference tuning mechanism compared to existing methods.

Novelty

This is the first to use LLM-as-a-Judge for evaluating and aligning LLMs with coding preferences, providing a large-scale preference dataset for model tuning.

Limitations

  • The dataset generation relies on GPT-3.5's scoring, which may introduce subjectivity and consistency issues.
  • Model alignment may be uneven across different coding preferences.
  • Applicability to larger LLMs remains unverified.

Future Work

Future work could explore larger-scale LLM alignment, further optimize DPO and SFT methods, and extend to more coding scenarios.

AI Executive Summary

Recent advances in large language models have shown remarkable progress in code generation, but evaluating their alignment with developer coding preferences remains challenging. Existing methods primarily rely on automated metrics and static analysis tools, which often fail to capture the nuances of user instructions. CodeUltraFeedback addresses this gap by using the LLM-as-a-Judge approach, employing GPT-3.5 to score and provide detailed feedback on 40,000 responses from 14 LLMs.

The CodeUltraFeedback dataset comprises 10,000 coding instructions, each annotated based on five coding preferences. Through supervised fine-tuning and AI feedback reinforcement learning, the CodeLlama-7B-Instruct model is optimized, outperforming the original model on the HumanEval+ benchmark with improved functional correctness.

The study demonstrates that responses from GPT-3.5 and GPT-4 show superior alignment with coding preferences compared to open-weight models. Future work could explore larger-scale LLM alignment, further optimize DPO and SFT methods, and extend to more coding scenarios.

Deep Analysis

Background

Large language models have excelled in tasks like code generation, translation, and bug fixing. However, their alignment with non-functional requirements such as code readability, efficiency, and best practices needs improvement. Existing evaluation methods mainly rely on automated metrics, failing to capture the nuances of user instructions.

Core Problem

Evaluating and improving the alignment of large language models with developer coding preferences is a key challenge. Existing methods lack large-scale datasets for preference tuning, and evaluation methods struggle to capture the subtleties of natural and programming languages.

Innovation

CodeUltraFeedback uses the LLM-as-a-Judge approach, employing GPT-3.5 to score and provide feedback on responses from 14 LLMs, offering a large-scale preference dataset. Combined with DPO and SFT techniques, it significantly enhances model alignment with coding preferences.

Methodology

  • �� Use Magicoder Evol-Instruct dataset to generate initial instruction set.
  • �� Randomly select 4 LLMs from 14 to generate responses.
  • �� Use GPT-3.5 to score and provide feedback on responses.
  • �� Optimize CodeLlama-7B-Instruct using DPO and SFT methods.

Experiments

Experiments use the CodeUltraFeedback dataset, comprising 10,000 instructions and 40,000 responses. Evaluation metrics include coding preference alignment and functional correctness. Benchmark testing uses HumanEval+, comparing different LLM performances.

Results

Responses from GPT-3.5 and GPT-4 show superior alignment with coding preferences. CodeLlama-7B-Instruct improves functional correctness on the HumanEval+ benchmark. DPO and SFT methods significantly enhance model alignment with coding preferences.

Applications

CodeUltraFeedback can optimize LLM performance in code generation, suitable for scenarios requiring high code quality and preference alignment, such as software development and automated testing.

Limitations & Outlook

The dataset relies on GPT-3.5's scoring, which may introduce subjectivity. Model alignment may be uneven across preferences. Applicability to larger LLMs remains unverified.

Plain Language Accessible to non-experts

Imagine you're in a kitchen cooking. A large language model is like a chef who needs to make dishes according to your taste. CodeUltraFeedback is like a cookbook that helps the chef understand your preferences, such as saltiness, spiciness, and presentation. With this cookbook, the chef can better adjust the dishes to meet your expectations. This process is similar to how models are fine-tuned using preference datasets to better meet developer coding preferences.

ELI14 Explained like you're 14

Imagine you're playing a game where your task is to teach a robot how to write code. This robot is like a large language model that needs to write code according to your instructions. CodeUltraFeedback is like a guide that helps the robot understand your coding preferences, like readability, efficiency, and style. With this guide, the robot can better adjust its code output to make sure it writes code you like every time. Just like in a game, you need to keep adjusting your strategy to win!

Glossary

Large Language Model

A large-scale neural network model capable of generating and understanding natural language.

Used for generating and evaluating coding responses.

Coding Preferences

Specific requirements developers have for code generation, such as readability and efficiency.

Used to evaluate LLM alignment.

LLM-as-a-Judge

Using a large language model as an evaluation tool to score and provide feedback on other models' outputs.

Used in generating the CodeUltraFeedback dataset.

Direct Preference Optimization

A technique for optimizing model outputs using preference datasets.

Used to optimize the CodeLlama-7B-Instruct model.

Reinforcement Learning from AI Feedback

A technique that uses AI-generated feedback to reinforce learning models.

Used for model preference alignment.

Open Questions Unanswered questions from this research

  • 1 How to achieve similar preference alignment on larger LLMs?
  • 2 How to reduce subjectivity and consistency issues in GPT-3.5 scoring?

Applications

Immediate Applications

Software Development

Developers can use optimized LLMs to generate code that better aligns with coding preferences, improving development efficiency.

Long-term Vision

Automated Testing

Aligned LLMs can generate higher-quality test cases for automated testing tools, reducing manual intervention.

Abstract

Evaluating the alignment of large language models (LLMs) with user-defined coding preferences is a challenging endeavour that requires a deep assessment of LLMs' outputs. Existing methods and benchmarks rely primarily on automated metrics and static analysis tools, which often fail to capture the nuances of user instructions and LLM outputs. To address this gap, we propose using the LLM-as-a-Judge methodology to evaluate the alignment of LLMs with coding preferences. Based on this approach, we present CodeUltraFeedback, a comprehensive dataset designed to facilitate the evaluation and improvement of LLM alignment. CodeUltraFeedback consists of 10,000 coding instructions, each annotated with four responses generated from a diverse pool of 14 LLMs. These responses are ranked based on five distinct coding preferences using GPT-3.5 as a judge, providing both numerical scores and detailed textual feedback. Our analysis of CodeUltraFeedback reveals that responses from GPT-3.5 and GPT-4 are generally preferred over those from open-weight LLMs, highlighting significant differences in alignment between closed and open-weight models. In turn, we explore the usage of CodeUltraFeedback as feedback data to fine-tune and align CodeLlama-7B-Instruct using supervised fine-tuning (SFT) and reinforcement learning from AI feedback (RLAIF) with direct preference optimization (DPO). The resulting aligned CodeLlama-7B-Instruct model outperforms larger LLMs in terms of alignment with coding preferences and shows improved functional correctness on the HumanEval+ benchmark compared to the original instruct model. Therefore, our contributions bridge the gap in preference tuning of LLMs for code and set the stage for further advancements in model alignment and RLAIF in automated software engineering.

cs.SE cs.CL cs.LG