Construction of an AI Code Defect Detection and Repair Dataset Based on Chain of Thought
摘要
When detecting and repairing code defects, enhancing the generalization ability and detection accuracy of models is a key challenge. This paper proposes a data fine-tuning method based on Chain of Thought (CoT) fine-tuning to improve the capabilities of models on defect detection in AI code. We constructed a dataset that includes the CrossVul dataset and a manually created dataset of AI code defects and repairs, improving data quality through techniques like context free removal. In the experiments, we used the Codeshell-7B, Qwencoder2.5-7B and Llama3.1-7B as the base and trained them using LoRA fine-tuning techniques. We compared different datasets and training methods to verify the model's effectiveness in detecting and repairing AI code defects. The results show that the CoT fine-tuning model outperforms models without CoT fine-tuning in all aspects of handling code defect tasks. Additionally, the specialized dataset we created for AI code defects and repairs significantly enhances the model's accuracy and repair rate in AI code detection. Our experiments highlight the importance of constructing targeted datasets for AI code defects and employing CoT fine-tuning strategies in improving code defect detection.