语义搜索:AI 编程的未来基石
大家好,欢迎来到本场关于在 Claude Code(一种 AI 编程环境)上进行语义搜索或语义代码检索的基准测试分享。我是来自 Turbopuffer 的 Kuba。对于不熟悉 Turbopuffer(Turbopuffer: 基于对象存储构建的无服务器全文本和向量搜索数据库)的朋友,我们为全球增长最快的 AI 公司提供服务。
AI 编程工具 Claude Code 默认不使用语义代码搜索。Claude Code 的创始人 Boris 曾指出,早期版本确实尝试过本地向量数据库的语义搜索,但他们发现代理式搜索(Agentic Search: 通过文件系统进行 grep 搜索)效果更好,且更简单。然而,Turbopuffer 的首批客户之一 Cursor(Cursor: 一款 AI 编程助手)却采用了语义代码搜索,并将其代码库索引到 Turbopuffer 中。虽然这看起来需要大量工作,但 Cursor 因此获得了显著的性能提升。根据他们的博文,Composer 模型(Composer Model: Cursor 内部使用的 AI 模型)的答案准确性相对提升了 24%,而所有模型整体提升了 12.5% 至 13%。此外,在线 A/B 测试显示,引入语义代码搜索使大型代码库的代码保留率提高了 2.6%,用户不满意请求减少了 2.2%。尽管这些数字看似不大,但考虑到并非所有查询都需要语义搜索,这些提升依然意义重大。
Original English Source
[music]
Hi everyone. Welcome to benchmarking semantic search or semantic code retrieval on cloud code. My name is Kuba. I'm here from Turbo Puffer. For those unfamiliar with Turbo Puffer, we are a serverless full text and vector search database built from first principles on top of object storage. We serve some of the fastest growing AI companies in the world and if you'd like to know more about the talk or any question about Turbo Puffer or anything, just find feel free to find me after.
So let's get started. So for those of you who are unaware, cloud code by default or I mean yeah, by default doesn't use semantic code search. There's actually a tweet from Boris. Those unfamiliar with Boris, he's actually like the founding father of cloud code and he talks about how cloud the early versions of cloud code did actually use semantic search with a local vector DB, but they just kind of found agentic search which is actually you know, grepping through your file system kind of worked better and you know, seems to work simpler for for cloud code.
However, one of Turbo Puffer's customers actually fun fact, one of our very first customer is Cursor does use semantic code search and does index code bases into Turbo Puffer and you may think like this seems like a lot of work and it kind of is, but the reason they do this is because they see real performance gains because of this. They have this amazing blog post about their semantic search. They also have one about indexing code bases which I highly recommend as well.
But you can see on the right the kind of performance gains they see with their composer model is like 24% increase in relative improvement in answer accuracy and I think it's like 12 and a half or 13% across all models and you know, I this benchmark came up before composer two, but you can probably imagine there's some sort of similar performance gains with that that new model as well. And in the bottom right you can see this is from to the same blog post. They talk about how in they perform an online AB test where they found that adding semantic either allowing or disallowing semantic code search led to like a 2.6% increase in code retention in large code bases and then 2.2% decrease in dissatisfied user requests. And you may also think like these numbers seem kind of small like what 2.6% 2.2%? Well, keep in mind that you know, out of 100 queries not all queries will ever really need semantic search or like benefit from it. So these they even state in the blog post that these numbers look small because not every you know, you can imagine a very simple tool call or very simple query would not really use semantic search.
嵌入:从重复计算到缓存智能
在 Turbopuffer,我们认为嵌入(Embeddings: 将文本、代码等非结构化数据转换为高维向量表示)本质上是一种缓存计算(Cache Compute: 预先计算并存储结果,以加速后续相同查询的处理)。
考虑一个典型的 Claude Code 追踪与 Cursor 式追踪的对比。在 Claude Code 的代理式搜索中(通常是 grep),每次会话都会重复执行通过文件系统查找元数据、过滤、理解代码库的过程。这意味着,即使是相同的查询或任务,每次也需要重新计算,随着会话和代理数量的增加,消耗的 token 会迅速累积。
相比之下,Cursor 模式则涉及一个前期成本:对代码库进行分块(Chunk: 将数据分割成更小的、可管理的部分)、嵌入(Embed: 创建数据的向量表示)和索引(Index: 组织数据以便快速检索)。但一旦完成,就拥有了一个语义意义的缓存。当代理需要理解元数据过滤的工作方式时,它只需查询“元数据是如何过滤的”,就能快速获取所需的代码块和理解,从而节省大量 token 并加速响应。虽然单次查询的节省可能不显著,但在同时运行多个代理的场景下,长期效益是巨大的。
Original English Source
So what we think about here at Turbo Puffer and why we kind of really think vector search and why Cursor probably sees this like real performance gain is we think about how embeddings are cache compute and you can also you know, what is what do you mean cache compute? This sounds like a bunch of baloney you're throwing at me. You know, if we were like walk through like a cloud code trace and like a Cursor type trace of kind of the same thing, you can imagine that on the left side this kind of like a you know, grepping through the file system or what they call agentic search. How it just has like grep through this is for finding metadata filtering and understanding it in your code base. That's essentially grep through, read the files, grep through more if it doesn't find the right things and again, this is repeated on every session across you know, every agent running in for the same code base so that even if you're asking the same question or trying to do the same thing multiple times, you always have to do this compute again and you can see like I mean in this case 6,000 tokens isn't a lot in one time, but across every session and every agent this really starts to add up. And if we you know, on the right of this is more of a like like Cursor style or Cursor level trace where you have this upfront cost where you have to chunk embed and index the code base, but then you would essentially have this cache of the semantic meaning so that when a when a agent wants to understand you know, where or how does metadata filtering work, it can simply query you know, how is metadata filtered and get a lot get the chunks it needs and kind of the understanding it needs a lot faster and with token savings and again, this doesn't it's not a lot of savings in one time, but we all you know, we're not really running one agent anymore. Like I'm running like three at one time. So there's definitely some long-term savings.
Turbo Grep:将语义搜索引入 Claude Code
为了将语义搜索能力带给 Claude Code,我们开发了一个简单的 CLI 工具,名为 Turbo Grep。
Turbo Grep 的工作原理是利用树分割库(Tree Splitter Library: 用于将代码结构化地分割成逻辑单元的工具)解析代码库,进行分块处理,然后使用 Voyage code model(Voyage code model: 一种用于生成代码嵌入的 AI 模型)生成嵌入,最后将这些嵌入上传到 Turbopuffer。这本质上是对文件系统进行遍历,以构建一个语义索引。目前,Turbo Grep V1 是开源的,而 V2 版本也将很快开源。
在演示中,可以看到 Claude Code 调用了 T Puffer 工具来搜索“password reset token generator”的代码。该工具能够快速检索到相关内容,并向用户提供完整的解释。
Original English Source
So what we did is we built a simple CLI tool for cloud code. We call it Turbo Grep. It's essentially you can imagine it's just a simple way of using a tree splitter library to essentially parse through your code base, chunk it, embed it using the Voyage code model and then upload it to Turbo Puffer. This is just a simple file system walk through. There is an open source library for the V1 version and then soon the V2 version will be open sourced. Here's a little video of example a tool call trace for a cloud code where you'll see it will call the T Puffer tool. Now it's called T Puffer search password reset token generator. This is in the Django repo. This is one of the repos I was testing it on and you can see that it gets the contents and then is able to kind of give the full explanation to the user.
基准测试:过程而非结果
为了量化语义搜索的优势,我们进行了基准测试。我们没有采用评估 AI 代理是否解决问题的传统方法,而是借鉴了 Context Bench(Context Bench: 一个评估 AI 代理在解决问题过程中查找特定文件、行和符号能力的基准测试)公共论文中的方法。该基准测试的核心理念是“过程同样重要”,即评估代理在解决问题的过程中,是否能够正确地找到相关的文件(File)、行(Line)和符号(Symbol)。这是一个人工标注的数据集,明确了完成特定任务所需查看的文件、行和符号。
我们测试了三种条件:
- 原始 Claude Code:开箱即用的默认配置。
- Claude Code + 窗口化 Grep:每次最大读取 50 行,以减少噪音。
- Claude Code + 窗口化 Grep + Turbo Puffer 语义搜索。
之所以设定 50 行的读取限制,是因为如果不加限制,读取长文件会迅速增加噪音,并掩盖不同方法间的真实差异。
Original English Source
And you know, it's very easy to say like oh this works better, but the important thing is obviously benchmark it. Let's see for real what what how much better does it work? Cursor has their own internal context bench and there's this paper this public paper called context bench where essentially the benchmark is not really testing whether or not the coding agent solved or didn't solve a problem. It tests when it in the process of solving the problem, did it find certain files? Did it find certain lines and it find certain symbols? Because they you know, they kind of have this this thesis that like it you know, it's also important how you get there not just like the end goal. The process really matters for understanding like are agents actually looking for the right files? So essentially it's a human labeled data set of like in order to complete this task they the agent should have looked at this file, these few lines and these few symbols in order to like actually complete the task well.
And I tested with three conditions. Essentially raw cloud code out of the box. Then I tested it with cloud code with a max of 50 line reads at a time and then the same thing with a windowed reads with the T Puffer search tool. You may ask me like why this like 50 line read thing limit? It's because it it became really noisy really fast if it's just reading like long files. It's really hard to like understand and get a difference because it all if it just reads a whole like a thousand line file, it doesn't really make a lot of difference in the numbers.
精度:语义搜索的显著优势
首先来看精度(Precision: 衡量代理读取的文件中有多少是实际所需的“黄金文件”)。
- 原始 Claude Code 的文件精度为 65%,行精度 33%,符号精度 43%。这意味着在 Claude Code 的文件读取中,大约每三个文件就有一个是完全浪费的。
- 通过窗口化 Grep,浪费的文件减少到每五个读取中有一个。
- 而引入语义搜索后,文件精度显著提升到 87%,浪费的文件进一步减少到每八个读取中只有一个。
这表明,Claude Code 默认倾向于探索性地读取大量文件,而语义搜索通过更精确地识别相关内容,显著提升了检索效率,减少了不必要的计算。
Original English Source
So we'll start with the first result of it. This is precision. Precision is essentially the the measure of of how many files did it read like in its total process? How many of them were actually golden files? So if there was if if cloud read 10 files and eight of them were needed, it hits 80% precision. You can see the baseline it hit like 65% precision, 33% on line precision and 43% on symbol and it kind of goes up as we add windowed grep and then windowed grep plus semantic search got it to like 87% file precision for example.
And this is also due to the fact like cloud code by default like it's a really exploratory. It loves to read as much as it can and like try to read everything for example and it kind of shows up in the 65% precision. And you know, it's hard to like translate these numbers, but a more like English or like human version of it is that you know, cloud code one in every three file reads is actually just a completely wasted file and with windowed grep it was one in five reads was a irrelevant file and then with semantic search there's only one in eight files was a you know, quote unquote wasted or irrelevant file and it kind of like scales up as you kind of add these tools. And you know, obviously this this is already like pretty good.
召回率与工具适用性:殊途同归的检索策略
接下来是召回率(Recall: 衡量代理找到了多少所需文件中的“黄金文件”)。
- 默认情况下,原始 Claude Code 在文件召回率方面表现较好,因为它会不惜一切代价探索所有文件。然而,它的行召回率却大幅下降,这表明它虽然阅读了大量文件,但很多文件并不包含核心的“黄金上下文行”。
- 窗口化 Grep 和语义搜索在召回率方面表现相似。值得注意的是,语义搜索在此处并未带来显著提升,甚至在某些任务上有所下降。
深入分析发现,不同的任务需要不同的工具:
- 语义搜索在查找与行为相关但关键词不匹配的文件时表现出色。例如,在处理多个 ORM 库时,传统关键词搜索可能无法完全覆盖,但语义搜索能够理解它们之间的行为关联。
- Grep 搜索则在追踪导入依赖和处理关键词搜索能快速定位的简单任务时更有效。
这强调了理解工具适用性的重要性:grep 和语义搜索以不同的方式查找代码,并产生不同的结果,并没有一个“万能”的解决方案。
Original English Source
Then we have recall. Recall is essentially how many of the needed files did it find? So for example, if there was 10 files in the task that it should have found, if cloud found five of them five files in its total trajectory and only three of them were actually these golden files, it would hit 30% recall. By default again, cloud code actually does win the file recall and again, part of this is because it just loves to explore every single file it can. Then we have line recall where it drops a lot more. This is kind of because it loved to read a lot of files, but also read to really read a lot of files that didn't have a lot of golden context lines. So you can kind of see that even though it did explore a lot, it also kind of explored the wrong things a lot and then with grep and grep plus semantic or windowed grep and windowed grep plus semantic search kind of have the same recall. You can kind of see on the right like kind of the what happened with the behavior between these three conditions.
And you may be thinking like well, you know, semantic search didn't really like add improvements here. Like what what went wrong? Like actually some decreases. And we can like dig in a little further into the recall numbers for certain tasks. This is across 50 tasks by default, but if we break it down into where semantic search won you know, quote unquote won and where just like windowed grep won, we see some stark differences between like certain tasks performed a lot better with semantic search allowed and then certain tasks performed a lot better with with no semantic search and this kind of proves you know, certain tasks requires different types of tools. For example, when semantic search won, it was really good at finding a lot of behavior adjacent files that didn't have the same kind of keywords. For example, it was like I think one example off top of my head was we're trying to like it was a multi like first handle lots of different ORMs that have to like handle across different libraries and it didn't by default the keyword search didn't by default find all of them, but behaviors semantic search was able to kind of like understand these are all related files. And then grep won when it was really good at just the task was a lot of it like tracing through imports and if it like was able to find the keywords in like the first or second tool call, it was able to like just keyword search through that and find the relevant files. So again, it's like two different types of how to find files, but they kind of lead to like really different results.
胜利者的法则:多种工具与上下文精炼
总结来看,语义搜索确实显著提升了精度,但 grep 和语义搜索以不同的方式定位代码。Cursor 之所以能取得更高的性能提升,是因为其 Composer 模型将语义搜索作为内置工具,模型能够智能地判断何时以及如何使用它。而 Claude Code 在使用附加的语义搜索工具时,缺乏这种深度的理解。
我们认为,长期的赢家将是那些能够提供轻量级工具,以多种不同方式查找正确上下文的方案。仅仅通过文件系统进行 grep 搜索是不足够的。存在多种访问不同类型信息的方式,而那些能够提供易用工具,将“十亿上下文窗口”缩小到“正确百万”的参与者,将会在长期竞争中获胜。
Original English Source
So in summary like what does this mean? Well, we like we saw semantic search like did boost precision quite a bit and we like kind of understand like grep and semantic search kind of find different code different ways. And an interesting thing to note as well was um these numbers weren't as great as Cursor's because part of like part of Claude code is it's built for just grepping. Like that's that's what Anthropic kind of focuses on. Like it's not built to under like to really understand like when to call semantic search or how to call it. Uh we kind of like add as an extra tool and it's like, "Hey, like here's this cool tool. You probably should use it sometimes." But it's very hard for it to have a true understanding of when to use it, why to use it uh versus like for example Cursor's composer they understand this is a built-in tool that um it knows when and how to use it and that's why they saw it's like 23 and 1/2 per uh percent uh performance gain. Uh so like in summary, uh you know, we think long-term winners were like kind of provide these lightweight tools to find the right context in various different ways. I think it's something important to think about. Uh you can't just like grep through everything unfortunately in a file system. Uh we think there's a lot of different ways to access lots of different types of information. Uh and the people that provide these like easy tools to provide to shrink down these billion context windows into the right million uh will win in the long term. Um that's the general talk. Thank you. If you have any questions, feel free to come up.
语义搜索:相似性与多模态的桥梁
在问答环节,演讲者澄清了语义搜索的定义:在此上下文中,它特指使用向量搜索(Vector Search: 基于数据点在多维向量空间中的相似性进行检索的技术),通过 Voyage code model 生成嵌入,然后将查询句或 token 嵌入后发送到 Turbopuffer 进行检索。Turbopuffer 作为 Cursor、Anthropic 和 Notion 等公司背后的向量数据库,已经广泛应用于实际场景。
关于代码的性能表现,语义搜索在代码注释(Code Comments)和内联文档(Inline Documentation)丰富的代码库中表现最佳,因为这些提供了丰富的语义信息供嵌入模型利用。
当被问及是否对目标数据进行预处理时,演讲者表示 Turbo Grep 当前直接使用原始代码(Raw Code)进行嵌入。然而,更复杂的客户可能会利用父子关系(例如,将“认证流程”作为查询来搜索相关的原始代码块),或者像 Cursor 那样通过注入虚拟注释(Inject Fake Comments: 在代码中添加非实际执行的注释,以提高语义模型的理解能力)来帮助模型更好地理解人类层面的查询,从而提升召回率。
最后,讨论了向量数据库(Vector Database: 存储和检索向量嵌入的数据库)与传统 Grep 搜索的适用场景。Grep 适用于零成本的本地文件系统搜索。而向量数据库则擅长处理多用户协作、数据间复杂关系以及多模态数据(Multimodal Data: 包含多种数据类型,如文本、图像、音频、视频等)场景。对于视频、音频、图像等无法通过 Grep 直接搜索的数据类型,向量数据库通过其语义理解能力展现出独特的价值,能够有效卸载计算并缓存语义意义。
Original English Source
[applause]
I have my own idea of what semantic search is, but could you define what you what's your definition is of semantic search?
Sure. Uh so this was just uh just doing vector search. It was just performing vector search using embedding it using Voyage's code model and then just embedding the the the query um query sentences or query tokens and just sending them back to to Turbo puffer. Yeah. Uh sorry, the uh embedding model Uh Voyage code three. Okay. And which vector DB? Turbo puffer. Yeah.
Sorry. Uh no worries. Yeah, yeah. Yeah, for those for those who are unfamiliar with Turbo puffer, we are the we are the vector database that powers companies like Cursor, Anthropic, Notion. So when you use something like Cursor uh you have by proxy used Turbo puffer. Um so you may know us just not by name, I guess. I was just going to ask You may not have a benchmark for this, but how does it perform on code? Oh, that's that's tough. I mean it's hard to say
better or is semantic better if the code's like a mess and you need to go and sort it out? Uh so I think it works best when there's a lot of like comments on code uh because it kind of finds that semantic meaning.
like the documentation is kind of inline. Yeah, if it's like inline documentation, that was like a big um boost. I believe one of the repos I remember like looking through some directories and like asking Claude be like, "Why did it perform so well here versus not?" And it was one of it kind of explains me like um when I was looking through as well like those with like really good comments, for example, just like comments above the function, it's able to like really understand a lot more cuz you you kind of give this context to the model and the embedding model. So then it can like actually search better. Um cuz that's that's part of it. Like the the embedding it and is not the hard part. It's like figuring out what meaning really is of that chunk. Yeah.
Yeah, you may have you you've mentioned some of it now, but of course semantic search is just similarity search. So if your query it doesn't really match the format of what you're querying against then you get some kind of innate distance. Do you do any kind of preprocessing on what your of the target data before you like do you do an parent-child where the parent is query-ish and the child is the real code or how do you
In in this case it was just simple just just the code. Yeah, just the raw code just as a thing, but I can't speak for like how these more complicated and sophisticated customers use this, but I can imagine it's definitely something of providing not just code level meaning, but you know, as you said at least a parent-child relationship of like authentication flow, like that could be a good query to do a similarity search against, but the code itself is more like raw. Yeah.
Yeah. Like Cursor has their own embedding model, which I think kind of helps with this of like how do you translate code into more of like a human level query. And I mean they're kind of been experts on that. I can't speak for how they do it, but I just know they do do it. I think they actually do what you said like they create fake comments on top of of your code and then embed the code with the comments. Yeah. So that's how they can have like their high recall when they So they add they kind of inject comments. Yes. Yeah, it's something that I think definitely could work. Yeah. In the back? Yeah.
I was going to ask like how do you see uh I guess the vector database kind of working with the partners and how like when do you code like long-term or need to reduce the size I mean I think it depends. Like obviously the easiest way like people love grepping because it's zero cost. Like if you're able to like download everything to your local file system and just like grep through it, like yeah, that works. Um I think vector DBs are built for actually like multiplayer and like this like super maybe in a sense like hard to understand or uh complicated relationships between lots of data. For example, like a knowledge base like a Notion, like you can imagine kind of hard to like really grep through that really easily on your local machine. Like it's in a sense best to like have that vectorize uh for the agents. Um and even stuff like we have customers doing stuff like with multimodal data. You can't really grep through a video file. You can't grep through an audio file. You can't grep through an an image file. Like maybe you can glob on the on the file name, um but like get a true understanding of kind of multimodal data as well is that something that we find a lot of customers are doing. Um so it just kind of depends on the workload and um I I yeah, if you if you're hitting like at some sort of even like miniature scale like a vector DB kind of like helps offload a lot of this this work into like you know, cache computer cache this semantic meaning. Any other questions? Okay. Thank you all.
Original English Source
\n\n[music]\n\n>> Hi everyone. Welcome to benchmarking semantic search or semantic code retrieval on cloud code. My name is Kuba. I'm here from Turbo Puffer. For those unfamiliar with Turbo Puffer, we are a serverless full text and vector search database built from first principles on top of object storage. We serve some of the fastest growing AI companies in the world and if you'd like to know more about the talk or any question about Turbo Puffer or anything, just find feel free to find me after.\n\nSo let's get started. So for those of you who are unaware, cloud code by default or I mean yeah, by default doesn't use semantic code search. There's actually a tweet from Boris. Those unfamiliar with Boris, he's actually like the founding father of cloud code and he talks about how cloud the early versions of cloud code did actually use semantic search with a local vector DB, but they just kind of found agentic search which is actually you know, grepping through your file system kind of worked better and you know, seems to work simpler for for cloud code.\n\nHowever, one of Turbo Puffer's customers actually fun fact, one of our very first customer is Cursor does use semantic code search and does index code bases into Turbo Puffer and you may think like this seems like a lot of work and it kind of is, but the reason they do this is because they see real performance gains because of this. They have this amazing blog post about their semantic search. They also have one about indexing code bases which I highly recommend as well.\n\nBut you can see on the right the kind of performance gains they see with their composer model is like 24% increase in relative improvement in answer accuracy and I think it's like 12 and a half or 13% across all models and you know, I this benchmark came up before composer two, but you can probably imagine there's some sort of similar performance gains with that that new model as well. And in the bottom right you can see this is from to the same blog post. They talk about how in they perform an online AB test where they found that adding semantic either allowing or disallowing semantic code search led to like a 2.6% increase in code retention in large code bases and then 2.2% decrease in dissatisfied user requests. And you may also think like these numbers seem kind of small like what 2.6% 2.2%? Well, keep in mind that you know, out of 100 queries not all queries will ever really need semantic search or like benefit from it. So these they even state in the blog post that these numbers look small because not every you know, you can imagine a very simple tool call or very simple query would not really use semantic search.\nOriginal English Source
\n\nSo what we think about here at Turbo Puffer and why we kind of really think vector search and why Cursor probably sees this like real performance gain is we think about how embeddings are cache compute and you can also you know, what is what do you mean cache compute? This sounds like a bunch of baloney you're throwing at me. You know, if we were like walk through like a cloud code trace and like a Cursor type trace of kind of the same thing, you can imagine that on the left side this kind of like a you know, grepping through the file system or what they call agentic search. How it just has like grep through this is for finding metadata filtering and understanding it in your code base. That's essentially grep through, read the files, grep through more if it doesn't find the right things and again, this is repeated on every session across you know, every agent running in for the same code base so that even if you're asking the same question or trying to do the same thing multiple times, you always have to do this compute again and you can see like I mean in this case 6,000 tokens isn't a lot in one time, but across every session and every agent this really starts to add up. And if we you know, on the right of this is more of a like like Cursor style or Cursor level trace where you have this upfront cost where you have to chunk embed and index the code base, but then you would essentially have this cache of the semantic meaning so that when a when a agent wants to understand you know, where or how does metadata filtering work, it can simply query you know, how is metadata filtered and get a lot get the chunks it needs and kind of the understanding it needs a lot faster and with token savings and again, this doesn't it's not a lot of savings in one time, but we all you know, we're not really running one agent anymore. Like I'm running like three at one time. So there's definitely some long-term savings.\nOriginal English Source
\n\nSo what we did is we built a simple CLI tool for cloud code. We call it Turbo Grep. It's essentially you can imagine it's just a simple way of using a tree splitter library to essentially parse through your code base, chunk it, embed it using the Voyage code model and then upload it to Turbo Puffer. This is just a simple file system walk through. There is an open source library for the V1 version and then soon the V2 version will be open sourced. Here's a little video of example a tool call trace for a cloud code where you'll see it will call the T Puffer tool. Now it's called T Puffer search password reset token generator. This is in the Django repo. This is one of the repos I was testing it on and you can see that it gets the contents and then is able to kind of give the full explanation to the user.\nOriginal English Source
\n\nAnd you know, it's very easy to say like oh this works better, but the important thing is obviously benchmark it. Let's see for real what what how much better does it work? Cursor has their own internal context bench and there's this paper this public paper called context bench where essentially the benchmark is not really testing whether or not the coding agent solved or didn't solve a problem. It tests when it in the process of solving the problem, did it find certain files? Did it find certain lines and it find certain symbols? Because they you know, they kind of have this this thesis that like it you know, it's also important how you get there not just like the end goal. The process really matters for understanding like are agents actually looking for the right files? So essentially it's a human labeled data set of like in order to complete this task they the agent should have looked at this file, these few lines and these few symbols in order to like actually complete the task well.\n\nAnd I tested with three conditions. Essentially raw cloud code out of the box. Then I tested it with cloud code with a max of 50 line reads at a time and then the same thing with a windowed reads with the T Puffer search tool. You may ask me like why this like 50 line read thing limit? It's because it it became really noisy really fast if it's just reading like long files. It's really hard to like understand and get a difference because it all if it just reads a whole like a thousand line file, it doesn't really make a lot of difference in the numbers.\nOriginal English Source
\n\nSo we'll start with the first result of it. This is precision. Precision is essentially the the measure of of how many files did it read like in its total process? How many of them were actually golden files? So if there was if if cloud read 10 files and eight of them were needed, it hits 80% precision. You can see the baseline it hit like 65% precision, 33% on line precision and 43% on symbol and it kind of goes up as we add windowed grep and then windowed grep plus semantic search got it to like 87% file precision for example.\n\nAnd this is also due to the fact like cloud code by default like it's a really exploratory. It loves to read as much as it can and like try to read everything for example and it kind of shows up in the 65% precision. And you know, it's hard to like translate these numbers, but a more like English or like human version of it is that you know, cloud code one in every three file reads is actually just a completely wasted file and with windowed grep it was one in five reads was a irrelevant file and then with semantic search there's only one in eight files was a you know, quote unquote wasted or irrelevant file and it kind of like scales up as you kind of add these tools. And you know, obviously this this is already like pretty good.\nOriginal English Source
\n\nThen we have recall. Recall is essentially how many of the needed files did it find? So for example, if there was 10 files in the task that it should have found, if cloud found five of them five files in its total trajectory and only three of them were actually these golden files, it would hit 30% recall. By default again, cloud code actually does win the file recall and again, part of this is because it just loves to explore every single file it can. Then we have line recall where it drops a lot more. This is kind of because it loved to read a lot of files, but also read to really read a lot of files that didn't have a lot of golden context lines. So you can kind of see that even though it did explore a lot, it also kind of explored the wrong things a lot and then with grep and grep plus semantic or windowed grep and windowed grep plus semantic search kind of have the same recall. You can kind of see on the right like kind of the what happened with the behavior between these three conditions.\n\nAnd you may be thinking like well, you know, semantic search didn't really like add improvements here. Like what what went wrong? Like actually some decreases. And we can like dig in a little further into the recall numbers for certain tasks. This is across 50 tasks by default, but if we break it down into where semantic search won you know, quote unquote won and where just like windowed grep won, we see some stark differences between like certain tasks performed a lot better with semantic search allowed and then certain tasks performed a lot better with with no semantic search and this kind of proves you know, certain tasks requires different types of tools. For example, when semantic search won, it was really good at finding a lot of behavior adjacent files that didn't have the same kind of keywords. For example, it was like I think one example off top of my head was we're trying to like it was a multi like first handle lots of different ORMs that have to like handle across different libraries and it didn't by default the keyword search didn't by default find all of them, but behaviors semantic search was able to kind of like understand these are all related files. And then grep won when it was really good at just the task was a lot of it like tracing through imports and if it like was able to find the keywords in like the first or second tool call, it was able to like just keyword search through that and find the relevant files. So again, it's like two different types of how to find files, but they kind of lead to like really different results.\nOriginal English Source
\n\nSo in summary like what does this mean? Well, we like we saw semantic search like did boost precision quite a bit and we like kind of understand like grep and semantic search kind of find different code different ways. And an interesting thing to note as well was um these numbers weren't as great as Cursor's because part of like part of Claude code is it's built for just grepping. Like that's that's what Anthropic kind of focuses on. Like it's not built to under like to really understand like when to call semantic search or how to call it. Uh we kind of like add as an extra tool and it's like, \"Hey, like here's this cool tool. You probably should use it sometimes.\" But it's very hard for it to have a true understanding of when to use it, why to use it uh versus like for example Cursor's composer they understand this is a built-in tool that um it knows when and how to use it and that's why they saw it's like 23 and 1/2 per uh percent uh performance gain. Uh so like in summary, uh you know, we think long-term winners were like kind of provide these lightweight tools to find the right context in various different ways. I think it's something important to think about. Uh you can't just like grep through everything unfortunately in a file system. Uh we think there's a lot of different ways to access lots of different types of information. Uh and the people that provide these like easy tools to provide to shrink down these billion context windows into the right million uh will win in the long term. Um that's the general talk. Thank you. If you have any questions, feel free to come up.\nOriginal English Source
\n\n>> [applause]\n\n>> I have my own idea of what semantic search is, but could you define what you what's your definition is of semantic search?\n\n>> Sure. Uh so this was just uh just doing vector search. It was just performing vector search using embedding it using Voyage's code model and then just embedding the the the query um query sentences or query tokens and just sending them back to to Turbo puffer. Yeah. Uh sorry, the uh embedding model Uh Voyage code three. Okay. And which vector DB? Turbo puffer. Yeah.\n\n>> Sorry. Uh no worries. Yeah, yeah. Yeah, for those for those who are unfamiliar with Turbo puffer, we are the we are the vector database that powers companies like Cursor, Anthropic, Notion. So when you use something like Cursor uh you have by proxy used Turbo puffer. Um so you may know us just not by name, I guess. I was just going to ask You may not have a benchmark for this, but how does it perform on code? Oh, that's that's tough. I mean it's hard to say\n\n>> better or is semantic better if the code's like a mess and you need to go and sort it out? Uh so I think it works best when there's a lot of like comments on code uh because it kind of finds that semantic meaning.\n\n>> like the documentation is kind of inline. Yeah, if it's like inline documentation, that was like a big um boost. I believe one of the repos I remember like looking through some directories and like asking Claude be like, \"Why did it perform so well here versus not?\" And it was one of it kind of explains me like um when I was looking through as well like those with like really good comments, for example, just like comments above the function, it's able to like really understand a lot more cuz you you kind of give this context to the model and the embedding model. So then it can like actually search better. Um cuz that's that's part of it. Like the the embedding it and is not the hard part. It's like figuring out what meaning really is of that chunk. Yeah.\n\nYeah, you may have you you've mentioned some of it now, but of course semantic search is just similarity search. So if your query it doesn't really match the format of what you're querying against then you get some kind of innate distance. Do you do any kind of preprocessing on what your of the target data before you like do you do an parent-child where the parent is query-ish and the child is the real code or how do you\n\n>> In in this case it was just simple just just the code. Yeah, just the raw code just as a thing, but I can't speak for like how these more complicated and sophisticated customers use this, but I can imagine it's definitely something of providing not just code level meaning, but you know, as you said at least a parent-child relationship of like authentication flow, like that could be a good query to do a similarity search against, but the code itself is more like raw. Yeah.\n\nYeah. Like Cursor has their own embedding model, which I think kind of helps with this of like how do you translate code into more of like a human level query. And I mean they're kind of been experts on that. I can't speak for how they do it, but I just know they do do it.\n\nI think they actually do what you said like they create fake comments on top of of your code and then embed the code with the comments. Yeah. So that's how they can have like their high recall when they So they add they kind of inject comments. Yes. Yeah, it's something that I think definitely could work. Yeah. In the back? Yeah.\n\nI was going to ask like how do you see uh I guess the vector database kind of working with the partners and how like when do you code like long-term or need to reduce the size I mean I think it depends. Like obviously the easiest way like people love grepping because it's zero cost. Like if you're able to like download everything to your local file system and just like grep through it, like yeah, that works. Um I think vector DBs are built for actually like multiplayer and like this like super maybe in a sense like hard to understand or uh complicated relationships between lots of data. For example, like a knowledge base like a Notion, like you can imagine kind of hard to like really grep through that really easily on your local machine. Like it's in a sense best to like have that vectorize uh for the agents. Um and even stuff like we have customers doing stuff like with multimodal data. You can't really grep through a video file. You can't grep through an audio file. You can't grep through an an image file. Like maybe you can glob on the on the file name, um but like get a true understanding of kind of multimodal data as well is that something that we find a lot of customers are doing. Um so it just kind of depends on the workload and um I I yeah, if you if you're hitting like at some sort of even like miniature scale like a vector DB kind of like helps offload a lot of this this work into like you know, cache computer cache this semantic meaning. Any other questions? Okay. Thank you all.\n📌 文中提及的人物和组织
公司/组织: Turbopuffer, Cursor, Anthropic, Notion
产品/模型: Claude Code, Composer, Composer Two, Voyage code model, Voyage code three