arXiv:2502.18467cs.SEcs.AI2025-02被引 21

对比ChatGPT与DeepSeek生成代码的准确率与效率,发现DeepSeek在算法题上更可靠。

ChatGPT vs. DeepSeek: A Comparative Study on AI-Based Code Generation

  • 用在线评测题库对比两模型生成Python代码的正确性
  • DeepSeek首次提交即通过率更高,错误更少
  • 适合关注代码准确性的开发者选型参考

AI驱动的代码生成正改变软件开发。本研究对比ChatGPT(o1版)与DeepSeek(R1版)在Python代码生成上的表现,基于在线评测系统挑战题进行评估。考察内容包括正确性(以在线判题结果为准,最多三次尝试)、代码质量(使用Pylint/Flake8)、以及执行效率(运行时间与内存占用)。结果显示,DeepSeek在算法类任务中表现出更高正确性,常于首次提交即获得'Accepted';而ChatGPT有时需多次尝试或失败。尽管如此,ChatGPT问题更少,内存使用相当甚至略低,执行时间更短,且生成代码行数更少。结论表明,DeepSeek在代码准确性方面具优势,尤其在算法求解上,但两者在执行效率上接近。研究为开发者选择编码助手提供依据,并推动未来AI辅助开发研究。

原文摘要 · Abstract (English)

Background: AI-powered code generation, fueled by Large Language Models (LLMs), is revolutionizing software development. Models like OpenAI's Codex and GPT-4, alongside DeepSeek, leverage vast code and natural language datasets. However, ensuring code quality, correctness, and managing complex tasks remains challenging, necessitating thorough evaluation. Methodology: This research compares ChatGPT (version o1) and DeepSeek (version R1) for Python code generation using online judge coding challenges. It evaluates correctness (online judge verdicts, up to three attempts), code quality (Pylint/Flake8), and efficiency (execution time/memory usage). Results: DeepSeek demonstrated higher correctness, particularly on algorithmic tasks, often achieving 'Accepted' on the first attempt. ChatGPT sometimes requires multiple attempts or failures. ChatGPT encountered fewer issues, used comparable or slightly less memory, consumed less execution times and wrote fewer lines of code. Conclusion: DeepSeek exhibited superior correctness in Python code generation, often requiring fewer attempts, suggesting an advantage in algorithmic problem-solving. Both models showed almost similar efficiency in execution time and memory use. Finally, this research provides insights for developers choosing AI coding assistants and informs future AI-driven software development research.

代码生成大模型算法评测AI编程

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。