This repository contains the implementation and experimental code for our paper.
The framework evaluates models across five key dimensions of code quality:
pip install torch transformers vllm datasets tqdm python-dotenv
Create a .env file in the root directory with your model access configurations if needed.
Train models using different optimization approaches:
python src/sft.py --model Qwen --task smell
python src/dpo.py --model Qwen --task smell
python src/sft+dpo.py --model Qwen --task smell
python src/apo.py --model Qwen --task smell
Generate code samples using trained models:
python generate_code.py --model Qwen --task smell --sample 5 --type SFT
Parameters:
--model: Model to use (Qwen, DeepSeek, Llama, etc.)--task: Evaluation task (correctness, security, smell, efficiency, complexity, conciseness)--sample: Number of samples to generate per problem (default: 5)--type: Model type (Ori, SFT, DPO, SFT+DPO, APO)Evaluate generated code solutions:
python eval/apps/eval/test_one_solution.py --save ./results/smell/Qwen-SFT --print_results
For tasks other than "correctness", run additional validation:
python valid.py --save ./results/smell/Qwen-SFT --task smell
APO-Replication/
├── src/ # Training scripts
│ ├── sft.py # Supervised Fine-Tuning
│ ├── dpo.py # Direct Preference Optimization
│ ├── sft+dpo.py # Combined SFT+DPO
│ └── apo.py # Adaptive Preference Optimization
├── eval/ # Evaluation scripts
│ └── apps/ # APPS benchmark evaluation
├── datasets/ # Training and evaluation datasets
├── results/ # Generated results and outputs
├── saved_models/ # Trained model checkpoints
├── generate_code.py # Code generation script
├── model.py # Model wrapper and configuration
├── valid.py # Validation script
├── testing_util.py # Testing utilities
Results are saved in the ./results/{task}/{model}-{type}/ directory structure:
all_codes.json: Generated code samplesall_results.json: Evaluation resultsall_results_{task}.json: Task-specific evaluation results1 commits
Python
100.0%
This repository contains the implementation and experimental code for our paper.
The framework evaluates models across five key dimensions of code quality:
pip install torch transformers vllm datasets tqdm python-dotenv
Create a .env file in the root directory with your model access configurations if needed.
Train models using different optimization approaches:
python src/sft.py --model Qwen --task smell
python src/dpo.py --model Qwen --task smell
python src/sft+dpo.py --model Qwen --task smell
python src/apo.py --model Qwen --task smell
Generate code samples using trained models:
python generate_code.py --model Qwen --task smell --sample 5 --type SFT
Parameters:
--model: Model to use (Qwen, DeepSeek, Llama, etc.)--task: Evaluation task (correctness, security, smell, efficiency, complexity, conciseness)--sample: Number of samples to generate per problem (default: 5)--type: Model type (Ori, SFT, DPO, SFT+DPO, APO)Evaluate generated code solutions:
python eval/apps/eval/test_one_solution.py --save ./results/smell/Qwen-SFT --print_results
For tasks other than "correctness", run additional validation:
python valid.py --save ./results/smell/Qwen-SFT --task smell
APO-Replication/
├── src/ # Training scripts
│ ├── sft.py # Supervised Fine-Tuning
│ ├── dpo.py # Direct Preference Optimization
│ ├── sft+dpo.py # Combined SFT+DPO
│ └── apo.py # Adaptive Preference Optimization
├── eval/ # Evaluation scripts
│ └── apps/ # APPS benchmark evaluation
├── datasets/ # Training and evaluation datasets
├── results/ # Generated results and outputs
├── saved_models/ # Trained model checkpoints
├── generate_code.py # Code generation script
├── model.py # Model wrapper and configuration
├── valid.py # Validation script
├── testing_util.py # Testing utilities
Results are saved in the ./results/{task}/{model}-{type}/ directory structure:
all_codes.json: Generated code samplesall_results.json: Evaluation resultsall_results_{task}.json: Task-specific evaluation results1 commits
Python
100.0%