TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: How we leapfrogged traditional vector based RAG with a 'language map'

162 点作者 oshams10 个月前
TL;DR: Vector-based RAG performs poorly for many real-world applications like codebase chats, and you should consider &#x27;language maps&#x27;.<p>Part of our mission at Mutable.ai is to make it much easier for developers to build and understand software. One of the natural ways to do this is to create a codebase chat, that answer questions about your repo and help you build features.<p>It might seem simple to plug in your codebase into a state-of-the-art LLM, but LLMs have two limitations that make human-level assistance with code difficult:<p>1. They currently have context windows that are too small to accommodate most codebases, let alone your entire organization&#x27;s codebases.<p>2. They need to reason immediately to answer any questions without thinking through the answer &quot;step-by-step.&quot;<p>We built a chat sometime a year ago based on keyword retrieval and vector embeddings. No matter how hard we tried, including training our own dedicated embedding model, we could not get the chat to get us good performance.<p>Here is a typical example: <a href="https:&#x2F;&#x2F;x.com&#x2F;mutableai&#x2F;article&#x2F;1813815706783490055&#x2F;media&#x2F;1813813912472870913" rel="nofollow">https:&#x2F;&#x2F;x.com&#x2F;mutableai&#x2F;article&#x2F;1813815706783490055&#x2F;media&#x2F;18...</a><p>If you ask how to do quantization in llama.cpp the answers were oddly specific and seemed to pull in the wrong context consistently, especially from tests. We could, of course, take countermeasures, but it felt like a losing battle.<p>So we went back to step 1, let’s understand the code, let’s do our homework, and for us, that meant actually putting an understanding of the codebase down in a document — a Wikipedia-style article — called Auto Wiki. The wiki features diagrams and citations to your codebase. Example: <a href="https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;ggerganov&#x2F;llama.cpp">https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;ggerganov&#x2F;llama.cpp</a><p>This wiki is useful in and of itself for onboarding and understanding the business logic of a codebase, but one of the hopes for constructing such a document was that we’d be able to circumvent traditional keyword and vector-based RAG approaches.<p>It turns out using a wiki to find context for an LLM overcomes many of the weaknesses of our previous approach, while still scaling to arbitrarily large codebases:<p>1. Instead of context retrieval through vectors or keywords, the context is retrieved by looking at the sources that the wiki cites. 2. The answers are based both on the section(s) of the wiki that are relevant AND the content of the actual code that we put into memory — this functions as a “language map” of the codebase.<p>See it in action below for the same query as our old codebase chat:<p><a href="https:&#x2F;&#x2F;x.com&#x2F;mutableai&#x2F;article&#x2F;1813815706783490055&#x2F;media&#x2F;1813814321144844288" rel="nofollow">https:&#x2F;&#x2F;x.com&#x2F;mutableai&#x2F;article&#x2F;1813815706783490055&#x2F;media&#x2F;18...</a><p><a href="https:&#x2F;&#x2F;x.com&#x2F;mutableai&#x2F;article&#x2F;1813815706783490055&#x2F;media&#x2F;1813814363939315712" rel="nofollow">https:&#x2F;&#x2F;x.com&#x2F;mutableai&#x2F;article&#x2F;1813815706783490055&#x2F;media&#x2F;18...</a><p>The answer cites it sources in both the wiki and the actual code and gives a step by step guide to doing quantization with example code.<p>The quality of the answer is dramatically improved - it is more accurate, relevant, and comprehensive.<p>It turns out language models love being given language and not a bunch of text snippets that are nearby in vector space or that have certain keywords! We find strong performance consistently across codebases of all sizes. The results from the chat are so good they even surprised us a little bit - you should check it out on a codebase of your own, at <a href="https:&#x2F;&#x2F;wiki.mutable.ai">https:&#x2F;&#x2F;wiki.mutable.ai</a>, which we are happy to do for free for open source code, and starts at just $2&#x2F;mo&#x2F;repo for private repos.<p>We are introducing evals demonstrating how much better our chat is with this approach, but were so happy with the results we wanted to share with the whole community.<p>Thank you!

16 条评论

anotherpaulg10 个月前
I agree that many AI coding tools have rushed to adopt naive RAG on code.<p>Have you done any quantitative evaluation of your wiki style code summaries? My first impression is that they might be too wordy and not deliver valuable context in a token efficient way.<p>Aider uses a repository map [0] to deliver code context. Relevant code is identified using a graph optimization on the repository&#x27;s AST &amp; call graph, not vector similarity as is typical with RAG. The repo map shows the selected code within its AST context.<p>Aider currently holds the 2nd highest score on the main SWE Bench [1], without doing any code RAG. So there is some evidence that the repo map is effective at helping the LLM understand large code bases.<p>[0] <a href="https:&#x2F;&#x2F;aider.chat&#x2F;docs&#x2F;repomap.html" rel="nofollow">https:&#x2F;&#x2F;aider.chat&#x2F;docs&#x2F;repomap.html</a><p>[1] <a href="https:&#x2F;&#x2F;aider.chat&#x2F;2024&#x2F;06&#x2F;02&#x2F;main-swe-bench.html" rel="nofollow">https:&#x2F;&#x2F;aider.chat&#x2F;2024&#x2F;06&#x2F;02&#x2F;main-swe-bench.html</a>
评论 #41002895 未加载
评论 #41005637 未加载
评论 #41007018 未加载
lmeyerov10 个月前
I&#x27;ve been curious about this use case, so cool to see, and more so, to know it worked!<p>This is essentially a realization of how graph RAG flavor systems work under the hood. Basically you create hierarchical summary indexes, such as topical cross-document ones, and tune the summaries to your domain. At retrieval time, one question will be able to leverage richer multi-hop concepts that span ideas that are individually distinct &amp; lexically, but get used together. Smarter retrievers can choose to dynamically expand on this (agentic: &#x27;follow links&#x27;) or work more in bulk on the digests (&#x27;map&#x2F;reduce over summaries&#x27;) without having to run every chunk through the LLM.<p>Once you understand what is going on in core graph rag, you can even add non-vector relationships to the indexing and retrieval steps, such as from a static code analysis, which afaict is the idea here. For a given domain, likewise, you can do custom templates to tune what is in each summary, like different wiki page styles for different topics. (Note: despite the name &amp; vendor advertising, no graph DB nor knowledge graph is needed for graph RAG, which makes its relationship to autowiki etc concepts less obvious.)<p>We are building out some tech here to deal with core production issues like to update&#x2F;add items without reindexing everything and making larger ingests faster+cheaper. Eg, imagine monitoring a heavy feed or quickly changing repo. If of interest to any, please ping - we are putting together design partner cohorts for the RAG phase of louie.ai .
评论 #41007256 未加载
kordlessagain10 个月前
I&#x27;ve been working on Webwright[1] for a month after having prototyped a few different terminal solutions for a coding agents. Webwright manifests in a psuedo terminal in Powershell or terminal on MacOS.<p>Using Claude.AI, I determined the `ast` package would be suitable (for Python scanning), so had Webwright author a new function module to scan the project and assemble a list of functions, function calls, imports, and decorators. I then installed the function module and relaunched the app.<p>It produced the following as a request to explain how the system works for y&#x27;all:<p>WebWright uses modular function calls to handle various tasks such as user input processing, file operations, git management, and AI interactions. The main application routes commands to specific functions, which in turn perform discrete tasks like reading files, managing containers, and querying AI APIs. This architecture ensures clear separation of concerns, maintainability, and scalability while efficiently handling complex operations asynchronously.<p>The heavy lifting in WebWright is primarily done in the AI handlers and utility modules:<p>1. AI Handlers (`lib.aifunc`):<p><pre><code> - The core AI functionality, like processing user queries and interacting with AI APIs (OpenAI, Anthropic), performs the most computationally intensive tasks. - Managing asynchronous API calls, error handling, and processing large datasets. </code></pre> 2. Utility Modules:<p><pre><code> - Modules like lib.functions.filesystem, lib.functions.git_*, and lib.functions.manage_app_container handle substantial operations such as file I&#x2F;O, version control, and Docker container management. </code></pre> These components shoulder the bulk of the computational and I&#x2F;O work, ensuring efficient task execution and resource management.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;MittaAI&#x2F;webwright">https:&#x2F;&#x2F;github.com&#x2F;MittaAI&#x2F;webwright</a>
评论 #41007230 未加载
tlarkworthy10 个月前
This is literate programming! Why not just put the codebase in the wiki and not have two representations diverging. Why can&#x27;t we have diagrams and links in code??? We can, like <a href="https:&#x2F;&#x2F;observablehq.com" rel="nofollow">https:&#x2F;&#x2F;observablehq.com</a> notebooks, it&#x27;s a better representation for understanding.
评论 #41007247 未加载
maxsieg10 个月前
Hey, cofounder at Mutable.ai here.<p>I want to encourage you all to ask the chat some tough questions. You can ask very complex and general questions. Some examples: - Ask ollama (<a href="https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;ollama&#x2F;ollama">https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;ollama&#x2F;ollama</a>) how to add a new model - Ask langchain (<a href="https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;langchain-ai&#x2F;langchain">https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;langchain-ai&#x2F;langchain</a>) &quot;How can I build a simple personal assistant using this repo?&quot; - Ask flash attention (<a href="https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;Dao-AILab&#x2F;flash-attention">https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;Dao-AILab&#x2F;flash-attention</a>) &quot;What are the main benefits of using this code?&quot;<p>It is also useful for search - for example, if you ask langchain &quot;Where is the code that connects to vector databases?&quot; it will surface all the relevant information.<p>Very curious to hear what you ask (and whether you find the response helpful)!
评论 #41014885 未加载
senko10 个月前
Looks similar to what we&#x27;re doing in Pythagora with CodeMonkey agent (prompt: <a href="https:&#x2F;&#x2F;github.com&#x2F;Pythagora-io&#x2F;gpt-pilot&#x2F;blob&#x2F;main&#x2F;core&#x2F;prompts&#x2F;code-monkey&#x2F;describe_file.prompt">https:&#x2F;&#x2F;github.com&#x2F;Pythagora-io&#x2F;gpt-pilot&#x2F;blob&#x2F;main&#x2F;core&#x2F;pro...</a>, code: <a href="https:&#x2F;&#x2F;github.com&#x2F;Pythagora-io&#x2F;gpt-pilot&#x2F;blob&#x2F;main&#x2F;core&#x2F;agents&#x2F;code_monkey.py#L91">https:&#x2F;&#x2F;github.com&#x2F;Pythagora-io&#x2F;gpt-pilot&#x2F;blob&#x2F;main&#x2F;core&#x2F;age...</a>)<p>I think everyone who&#x27;s seriously tackled the &quot;code RAG&quot; problem is aware a naive vector approach doesn&#x27;t work, and some hybrid approach is needed (see also Paul&#x27;s comments on Aider).<p>Intuitively, I expect a combo of lsp&#x2F;treesitter directed by LLM + vector-RAG over &quot;wiki&quot; &#x2F; metadata would be a viable approach.<p>Very exciting to see all the research into this!
langcss10 个月前
This sort of approach always made more sense to me than RAG. I am less likely to try RAG than something that feeds the LLM what it actually needs. RAG is risky in providing piecemeal information that confuses the LLM.<p>The way I thought would work and like to try out is ask the LLM what info it wants next from an index of contents. Like a book. That index can be LLM generated or not. Then backtrack as you don&#x27;t need that lookup in your dialogue any more and insert the result.<p>It won&#x27;t work for everything but should work for many &quot;small expert&quot; cases and you then don&#x27;t need a vector DB you just do prompts!<p>Cheap LLMs make this more viable perhaps than it used to be. Use an open source small LLM for the decision making then a quality open source or proprietary LLM for the chat or code gen.
评论 #41002613 未加载
评论 #41007341 未加载
maxsieg10 个月前
Hey! I&#x27;m a cofounder at Mutable.ai, FYI we have run this on the following codebases (plus hundreds more):<p><a href="https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;hashicorp&#x2F;terraform">https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;hashicorp&#x2F;terraform</a><p><a href="https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;ggerganov&#x2F;llama.cpp">https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;ggerganov&#x2F;llama.cpp</a><p><a href="https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;ethereum&#x2F;go-ethereum">https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;ethereum&#x2F;go-ethereum</a><p><a href="https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;NVIDIA&#x2F;TensorRT">https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;NVIDIA&#x2F;TensorRT</a><p><a href="https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;langchain-ai&#x2F;langchain">https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;langchain-ai&#x2F;langchain</a><p><a href="https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;ollama&#x2F;ollama">https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;ollama&#x2F;ollama</a><p><a href="https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;tensorflow&#x2F;models">https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;tensorflow&#x2F;models</a><p><a href="https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;grafana&#x2F;grafana">https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;grafana&#x2F;grafana</a><p><a href="https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;OpenAutoCoder&#x2F;Agentless">https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;OpenAutoCoder&#x2F;Agentless</a><p><a href="https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;unslothai&#x2F;unsloth">https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;unslothai&#x2F;unsloth</a><p><a href="https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;Dao-AILab&#x2F;flash-attention">https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;Dao-AILab&#x2F;flash-attention</a><p><a href="https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;vercel&#x2F;next.js">https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;vercel&#x2F;next.js</a><p><a href="https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;microsoft&#x2F;vscode">https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;microsoft&#x2F;vscode</a><p><a href="https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;wasm3&#x2F;wasm3">https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;wasm3&#x2F;wasm3</a><p><a href="https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;deepfakes&#x2F;faceswap">https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;deepfakes&#x2F;faceswap</a><p><a href="https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;huggingface&#x2F;transformers">https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;huggingface&#x2F;transformers</a><p><a href="https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;vllm-project&#x2F;vllm">https:&#x2F;&#x2F;wiki.mutable.ai&#x2F;vllm-project&#x2F;vllm</a>
kleneway110 个月前
Nice job on this, it’s a really interesting approach. I’ve been developing an open-source coding agent over the past year, and RAG just wasn’t working at all. I switched to a repo map approach (which sounds similar to what aider is doing) and that helped a bit but still wasn’t great.<p>However, a few weeks ago I built an agent that takes in a new GitHub issue and is given a variety of tools to do research on the background information to complete the issue. The tools include internet searches or clarifying questions to ask the person who wrote the ticket. But the most useful tool is the ability to look at the codebase and create a detailed markdown file of various files, explanations of what each file does, relevant code samples or snippets from the files, etc..<p>It’s still early, but anecdotally I’ve seen a huge increase in the quality of the code that uses this research as part of the context (along with the repo map and other details). It’s also able to tackle much more complex issues than it could before.<p>I definitely think you’re on to something here with this wiki approach. I’ll be curious to dig in and see the details of how you are creating these. Here is my research code if you’re interested: <a href="https:&#x2F;&#x2F;github.com&#x2F;jacob-ai-bot&#x2F;jacob&#x2F;blob&#x2F;feature&#x2F;agent&#x2F;src&#x2F;server&#x2F;agent&#x2F;research.ts">https:&#x2F;&#x2F;github.com&#x2F;jacob-ai-bot&#x2F;jacob&#x2F;blob&#x2F;feature&#x2F;agent&#x2F;src...</a><p>And here’s an example of the research output (everything past the exit criteria section): <a href="https:&#x2F;&#x2F;github.com&#x2F;kleneway&#x2F;jacob&#x2F;issues&#x2F;62">https:&#x2F;&#x2F;github.com&#x2F;kleneway&#x2F;jacob&#x2F;issues&#x2F;62</a>
oshams10 个月前
Wow, I didn&#x27;t notice this hit the front page until now, will be answering questions momentarily!
zellyn10 个月前
These wikis are really interesting. I&#x27;m itching to try it on the common framework parts of our work monorepo.<p>[Update after looking at the Django wiki]<p>The wiki&#x27;s structure appears to be very (entirely?) based on the directory structure. Is that right?<p>It would be interesting to give it the Django documentation in addition to the codebase, or possibly even just the heading structure of the documentation, and let it use that as a scaffold to generate the structure&#x2F;organization of the wiki.<p>For a specific example, the Model is one of the most important concepts in Django, but in the auto-generated wiki, it shows up underneath databases.
评论 #41009664 未加载
zby10 个月前
A prompt here is a textual presentation of a data structure - this is an area that I am exploring right now. I wonder if it would not be equally effective if the LLM was getting a JSON or Python representation instead of the presumed Markdown. But my intuition is that because LLMs are trained on texts that are meant for human consumption - then they will follow better exactly the same texts as humans find easier and that means that they &#x27;want&#x27; exactly the same presentation as humans - nicely formatted text or nicely formatted programs, not mixes.
spirobelv210 个月前
it wants me to login to ask a question<p>I will just keep using phind<p>you have vc dollars - sponsor a public free search over open source repos.<p>Also think about what happens when your question touches multiple repos.<p>I tried a similar &quot;search github repo with ai&quot; product before, but it led me right back to phind, when it couldnt answer a question that required specific information from the repositiory as well as a google search.
评论 #41007292 未加载
评论 #41010153 未加载
magicalhippo10 个月前
So no free lunch? Making a detailed wiki of all the code would take several developer-years for us, and we&#x27;re just a handful of developers.<p>Or is the wiki generated somehow?
评论 #41006264 未加载
评论 #41007416 未加载
oshams10 个月前
BTW, if you ask for an open source repo in the comments to be processed by our system, we&#x27;ll do it for free!
评论 #41009421 未加载
J_Shelby_J10 个月前
This is amazing. Do you have any information on the implementation?
评论 #41009098 未加载