arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2502.18467cs.SEcs.AI

ChatGPT 与 DeepSeek:基于 AI 的代码生成比较研究

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

Rensselaer Polytechnic Institute (RPI)(伦斯勒理工学院)

Md Motaleb Hossen Manik

AI总结:

本研究比较 ChatGPT 和 DeepSeek 在 Python 代码生成中的表现,发现 DeepSeek 正确性更高,而 ChatGPT 效率相当且代码更简洁。

摘要:

背景:由大型语言模型(LLMs)驱动的 AI 代码生成正在彻底改变软件开发。OpenAI 的 Codex 和 GPT-4 等模型,以及 DeepSeek,利用大量的代码和自然语言数据集。然而,确保代码质量、正确性以及管理复杂任务仍然具有挑战性,因此需要进行彻底的评估。方法:本研究使用在线判题编码挑战,比较了 ChatGPT(o1 版本)和 DeepSeek(R1 版本)在 Python 代码生成方面的表现。评估内容包括正确性(在线判题结果,最多尝试三次)、代码质量(Pylint/Flake8)和效率(执行时间/内存使用)。结果:DeepSeek 表现出更高的正确性,尤其是在算法任务上,通常能在第一次尝试时就获得“通过”。ChatGPT 有时需要多次尝试或失败。ChatGPT 遇到的问题较少,内存使用相当或略少,执行时间更短,编写的代码行数也更少。结论:DeepSeek 在 Python 代码生成方面表现出更优的正确性,通常需要更少的尝试次数,这表明其在算法问题解决方面具有优势。两个模型在执行时间和内存使用方面的效率几乎相同。最后,本研究为开发人员选择 AI 编码助手提供了见解,并为未来 AI 驱动的软件开发研究提供了信息。

英文摘要:

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分析而来,可能存在错误,请以论文正文为准。

↑