展示HN:我构建了一个本地运行的RAG和知识图谱代理。
Claw-Coder 是一个在您的笔记本电脑上本地运行的 AI 代理,它可以访问强大的工具,而无需配置 Claude 或 Codex 来使用本地模型,只需使用 Claw-Coder。
为什么要创建 Claw-Coder?答案是:为了解决隐私和安全问题。当您使用配置了云模型(如 Codex、Cursor、Claude 等)的代理时,您不仅仅是在使用代理,还在将您的代码库交给训练大型语言模型(LLM),这让人感到有些担忧,并且降低了对 AI 技术的信任。然而,当您切换到一个不适合该工作流程的本地模型时,性能问题又会随之而来,您会失去性能和速度,这实际上是一种权衡。这就是 Claw-Coder 的用武之地,它不仅在您的机器上运行,而且所有代码、RAG、知识图谱等信息都保存在本地,从而解决了隐私问题,但性能又如何呢?
性能:本地 LLM 并不是为了执行云模型所能做的那些酷炫功能而构建的,因为模型的大小甚至无法构建像 8B、13B,甚至 1B 这样的真实应用。因此,我提出的解决方案是让这些小模型能够访问一些工具和功能,从而在编码性能上表现良好。
那么 Claw-Coder 具有什么访问权限呢?知识图谱:知识图谱是一个相互关联的现实世界实体网络——例如人、地点、概念或事件——以及它们之间的关系。它将信息组织成一个可读的意义网络,而不是静态列表,使人类和 AI 都能理解上下文。那么这对 AI 有什么帮助呢?它赋予 AI 能力,能够识别您代码库中代码之间的关系、克隆的未知代码库等等,这大大提高了本地 LLM 在编码任务和推理能力上的性能。RAG:我们在某个时候都听说过 RAG,但有一个问题,本地 LLM 的上下文窗口无法承载大型代码库和代码库,因此 RAG 不是可选的。通过将向量存储在向量存储中,您使 AI 实际上能够理解代码的含义以及每个部分对其他部分的作用,从而让您将数百万行代码加载到向量存储中,而不会超出上下文窗口的限制。
工具:我们讨论了许多小而强大的方法来提高本地 LLM 的性能,但要让代理真正发挥作用,它需要采取行动,这就是向本地 LLM 暴露工具的帮助所在。那么,Claw-Coder 实现了哪些工具呢?1. search_tool:这使得 AI 代理能够实际搜索最新信息,从而避免在不知情的信息上产生幻觉,这在本地 LLM 中是常见的。2. Docker 执行:该代理有一个特殊的文件夹,称为工作区,它在这里进行工作而不会破坏您的桌面,但这并不足以保护您的桌面不被低质量代码破坏,因此 Docker 就派上用场了。我实现了各种语言的 Docker 容器,代理可以在其中验证自己的代码。这是非常强大的,因为所有 LLM(不仅仅是本地的)生成的代码都无法确认是否有效,因为它们只是强大的预测器。因此,让它能够运行自己的代码,令人惊讶地提高了生成代码的实用性,因为它现在知道代码是否有效。即使是 HTML 和 CSS,AI 代理也被赋予了一个有用的视觉 LLM,能够实际解释在浏览器中呈现的内容。这就是给 LLM 提供 Docker 执行工具的惊人力量。
我们已经看到了 Claw-Coder 如何不同,使本地 LLM 能够真正进行实际工作。但您如何自己尝试呢?Claw-Coder 是闭源的,因为它正在进行严格的测试,但这并不影响透明度。由于我们正在测试,这并不妨碍人们在真实代码库上尝试并提供反馈。要开始使用,请执行以下命令:
```
brew tap gabriel-c70/claw
然后
brew install claw-coder
```
查看原文
Claw-Coder is an AI agent that runs locally on your laptop and has access to powerful tools instead of configuring claude or codex to use a local model just use claw-coder.
Why was claw-coder created? Answer: To solve the problem of privacy and security. When you use an agent that is configured with a cloud model like codex, cursor, Claude etc. You are not just getting the agent but you are giving up your codebase to train an llm which is a bit concerning and this reduces trust in the technology called AI but now another problem comes in performance when you switch to a local model that is not made for that workflow you lose performance, speed, and it becomes really a tradeoff so that's where claw-coder comes in it not only runs on your machine but all the code, rag, knowledge graph etc info is kept local making the privacy problem solved but now what about performance.<p>Performance: Local llms are not built to do the cool things cloud models do because the model sizes are not even capable of building real apps like the 8b models, 13b, even 1b so the solution I came up with was to give these small models access to tools and features that make it actually work well in coding performance.<p>So what does claw-coder have access to: A knowledge graph: A knowledge graph is an interconnected network of real-world entities—such as people, places, concepts, or events—and the relationships between them. It organizes information into a readable web of meaning rather than static lists, allowing both humans and AI to understand context. So how does this help an AI, it gives the AI the ability to tell relationships between code in your codebase, a cloned unknown repo and so forth this increases performance of local llms by far in coding tasks and reasoning abilities. Rag: We have ever had of RAG at some point but there is a catch the context window of local llms can't bear large codebases and repos so RAG isn't optional by storing vectors in a vector store you enable the AI to actually know what the code means and what each piece does to the other letting you load millions of lines into the vector store without blowing up the context window.<p>Tools: So we have discussed the tiny but powerful ways to improve local llm performance but an agent to be an agent it needs to take action this is where exposing tools to the local llm helps so what tools have been implemented into claw-coder. 1. search_tool This enables the ai agent to actually search up to date info so that it doesnt hallucinate on info it doesn't know which is common in local llms. 2. Docker execution This agent has a special folder called workspace where it does its work without destroying your desktop but this is not enough to protect your desktop from being destroyed by cheap code so this is where docker comes in I have implemented docker containers of various languages where the agent can validate its own code this is powerful because all llms not only local ones generate code they can't even confirm works because they are just powerful predictors so enabling it to run its code can surprisingly increase the usefulness of the generated code because it now knows it works or not even for html and css the ai agent has been given a helpful vision llm to actually explain what rendered in the browser. This is the surprising power of giving an llm a docker execution tool.<p>We have looked at a lot of how claw-coder is different enabling local llms to actually do real work. But how do you actually try it out yourself: Claw-coder is closed source because it is going through heavy testing but that doesnt kill transparency and since we are testing it doesn't stop people from trying it on real codebase and giving feedback to get started use:<p>brew tap gabriel-c70/claw then brew install claw-coder