Embedding 模型揪出隐蔽代码重复
推荐指数 56.0 NO. 013 · 2026.07.03
发布2026/07/02Score54Comments24
为什么值得看
一款轻量级 CLI 工具,用代码嵌入向量检测跨模块、远距离的非精确代码重复。传统工具抓不到的"改改变量名就复制"的坏味道,它能定位出来供人工确认。
编辑判断
代码重复检测这个老问题,传统方案如 SonarQube、PMD 的 copy-paste detection 主要做 token 序列匹配或 AST 比对,对改改命名、拆分函数后的"智能抄袭"基本盲视。这个工具的思路更接近代码搜索领域的 CodeBERT、GraphCodeBERT 路线,但做成了本地可跑的轻量 CLI,不需要搭整套 SAST 平台。
和 GitHub Copilot 的代码引用检测或 Semgrep 的语义规则不同,它不依赖预定义模式,而是靠向量近似召回潜在重复对,再由人做最终判断——这种"AI 召回+人工精排"的交互设计很务实,避免了纯自动化的高误报。如果你在维护 10 万行以上的遗留代码库,尤其是多语言混合的项目,值得用它做一次全量扫描,很可能挖出几个被复制了七八次的核心业务逻辑。
社区反馈
正面 24 条评论
核心争论:嵌入模型检测语义重复填补了传统工具空白,但需人工确认且粒度配置待完善
I built Slopo to solve one specific problem: finding similar code that is hardest to detect by other tools, coding AI agents, and humans. It finds similar-looking code with embeddings. This detects more than just copy-paste clones or even clones with minor changes. Similar code is often not a clone
If it did PHP I would love to run it over WordPress. What would it take to add that?
PHP support can be easily added, I will release a new version soon.