问同一个问题 DeepSeek-r1 / Grok-3 / Gemini 2.0 / ChatGPT 的结果出乎意料...

人工智能
DeepSeek-r1 的大部分时间在思考如何写算法。而最后,其才临门一脚想到了 ignore 。感觉本次实验取样不足,没有置信度。

最近在写 TS ,希望实现一个类似 .gitignore 的功能,已有代码如下:

/**
 * Check if a file should be ignored based on patterns
 */
export function shouldIgnore(filePath: string, ignorePatterns: string[]): boolean {
  // Simple implementation of glob pattern matching
  return ignorePatterns.some(pattern => {
    if (pattern.endsWith('/**')) {
      const dirPattern = pattern.slice(0, -3);
      return filePath.startsWith(dirPattern);
    } else if (pattern.startsWith('**/*.')) {
      const ext = pattern.slice(3);
      return filePath.endsWith(ext);
    } else if (pattern.includes('*')) {
      const regex = new RegExp('^' + pattern.replace(/\*/g, '.*') + '$');
      return regex.test(path.basename(filePath));
    }
    return filePath.includes(pattern);
  });
}

在 JS 层面使用正则匹配,显然不是什么好方案。单元测试也过不了。

于是整理代码和报错信息,找了四个免费的模型,问问思路。

先说结论:DeepSeek-r1 思考了 298 秒,我一度以为其陷入了死循环,但最后其在第一轮给出的方案,被 Grok-3 、 Gemini 2.0 、 ChatGPT 统统认可是最优方案之一。且后三者都没有在第一轮对话给出这个方案。

下面来看具体过程。

第一轮

第一轮提问第一轮提问


请帮我排查错误原因并修正代码。我希望实现和 .gitignore 一样的效果。如有必要可以引入第三方匹配 lib (比如可以获取更高的性能、更全的功能)

先看最快的三个回答:

Grok-3Grok-3

Grok-3 推荐了 minimatch 工具。

Gemini 2.0 Flash ThinkingGemini 2.0 Flash Thinking

Gemini 2.0 推荐了 micromatch 。

ChatGPTChatGPT

ChatGPT-推理 最原生,推荐了 glob 。

在等了很久后, DeepSeek-r1 终于给出答案。我本来已经对其不抱希望。

DeepSeek-r1DeepSeek-r1

其推荐了 ignore 工具。这大大引起我的兴趣,因为从名字而言,这是和我的 .gitignore 需求最接近的。

到底哪个工具好


于是我又问:minimatch 和 glob 和 ignore 这三个 lib 有什么区别?更推荐哪个?

ChatGPTChatGPTGeminiGeminiGeminiGeminiGrokGrokGrokGrok

显然,最终 Grok 和 Gemini 明显更加推荐 DeepSeek-r1 一开始就推荐的 ignore 工具。

这里很疑惑:

  1. 明明 ignore 最合适,为什么这三家没有想到?(我的首轮提问中明明已经有了 .gitignore 这样的关键词?)
  2. 为什么 DeepSeek-r1 思考了这么久,想到了 ignore ?思考时间与答案质量成正比吗?

但是看起来, DeepSeek-r1 的大部分时间在思考如何写算法。而最后,其才临门一脚想到了 ignore 。感觉本次实验取样不足,没有置信度。

图片

对了,关于第二轮的问题“minimatch 和 glob 和 ignore 这三个 lib 有什么区别?更推荐哪个?”,DeepSeek-r1 是怎么回答的呢?

责任编辑:武晓燕 来源: Piper蛋窝
相关推荐

2020-07-29 17:15:19

Java人脸识别人工智能

2014-06-18 09:32:30

编程语言Caml

2011-05-31 13:41:00

C语言

2011-06-29 09:38:13

电子书平板电脑Kindle

2016-12-15 08:54:52

线程sessionopenSession

2025-02-19 08:00:00

2012-06-04 11:51:31

飞视美视频会议

2025-02-06 12:10:00

2025-02-19 08:33:18

2025-02-13 13:00:00

2016-12-20 13:55:52

2015-10-16 13:41:52

程序对象设计

2009-06-09 12:38:12

NetBeanseclipse

2025-02-18 14:59:16

2025-02-26 11:25:26

2025-02-08 09:44:11

DeepSeekAI模型
点赞
收藏

51CTO技术栈公众号