The unreasonable effectiveness of BM25 for agentic search — Jo Kristian Bergum, Hornet.dev
AI Engineer · 18 min · 159 sentences · from YouTube's caption track
Each timecode opens YouTube at the start of that sentence. Line anchors (#s42) are the cue ids in the WebVTT, and every line carries its start and end seconds. All transcripts has every talk, and the whole corpus as one file.
- 00:01[music]
- 00:12So great being here.
- 00:14Uh I'm Joe Bergam.
- 00:15I'm the CEO of Hornet Dev and I'm here today to talk about the unreasonable effectiveness of BM25 for Agentic Search.
- 00:23So how many of you heard about BM25 before?
- 00:26Is it new or is it Well, quite a few.
- 00:28So that's great.
- 00:29Uh I'm also watching the World Cup.
- 00:32Norway is playing there uh against the Ivory Coast second half.
- 00:35Norway is leading so that's good.
- 00:38So yeah and at Hornet we are building retrieval infrastructure for agents and uh I've been working on search and retrieval problems for a long time.
- 00:49As you can tell I'm gray hair.
- 00:51Uh been working in this space for more than 20 years.
- 00:56Um and in the talk today I'll talk about why this kind of 30-year-old lexical scoring function is uh making a strong comeback.
- 01:07First I will talk a little bit about what I mean by agentic search or aentic dribble and kind of define that for for you all of you.
- 01:14Um my definition is that agentic search is essentially search inside agent loop.
- 01:22So you have an agent that is trying to accomplish a task, write a coding or do some deep research or whatever task and inside that you have some kind of information need for the agent, right?
- 01:34In order to get that task done successfully and you essentially need three things uh to kind of build a good agentic search system and that is you need a capable model, a model that is able to use tools
- 01:49and is able to formulate queries.
- 01:51You also need a harness around the model and how you kind of expose the retrieval and the search functions to the model.
- 02:00There's different ways to do that.
- 02:02It could be through tool calling or it could be through code mode.
- 02:06Um, Edo here uh demonstrated what I call code mode for exposing retrieval infrastructure.
- 02:13So that's the harness part and you also need uh a retrieval engine to be able to do searches efficiently potentially over billion scaled uh document sets and to define BM25.
- 02:29So BM25 actually stands for best match 25.
- 02:33So there were some researchers doing plenty of different experiments and experiment number 25 turned out to be the best one.
- 02:40So that's that's the background of the name.
- 02:43It's essentially a scoring function.
- 02:45So you can imagine you have a query and you have a document and you calculate some kind of score by interaction between the query terms and the document terms and you come up with a score and you hope that this score kind of is a good proxy for the relevancy of the document with regards to the query.
- 03:02Right?
- 03:02So one way to calculate BM35 would be to take all the documents and score each of them you know and then figure out what are the top K documents
- 03:12and then there's like 30 or 40 years of interest in how you accelerate that type of retrieval top K lots of different algorithms we also invest a lot in that I'll
- 03:23show something in this direction but BM25 is the scoring function and there is a way to kind of accelerate top K retrieval Uh BM25 hasn't changed.
- 03:35It's the same scoring function, but the change here is really that we got a more powerful user.
- 03:41Uh Edo talked about general knowledge.
- 03:44The LLMs today have a lot of general knowledge.
- 03:46They know about entities, they know about companies, they know about dates, they know a lot, right?
- 03:52And by using that kind of implicit knowledge that is built into the parametric model, uh they essentially become very good at search.
- 04:01Um and that's the really change uh here now that we're is kind of making BM25 more relevant and BM25 used to be a kind of a baseline function.
- 04:13Any information retrieval research would include a BM25 baseline and then you would put something fancy advanced neural fancy stuff and then you would compare it with BM25.
- 04:25I also think it's interesting in how we evaluate search before because you will simply look at 10 blue links and you like have scan it and you compute some metrics.
- 04:34A lot of that is now going away because the agent is not really it's kind of powerful in the way that it can type out a lot more queries than a human can do.
- 04:45So it's less relevant to think about evaluating these systems just by a single shot query.
- 04:53And this is one of my kind of favorite benchmarks out there.
- 04:58I like to talk about benchmarks.
- 04:59So browsecom plus is a deep research benchmark
- 05:03[snorts]
- 05:04uh published in a paper last year and it has almost or exactly 830 questions.
- 05:14These are riddle like think about it like a pub quiz.
- 05:17Do you have pub quizzes in the US?
- 05:19Yeah.
- 05:19Okay great.
- 05:20So like kind of a riddle type of questions quite long and the agent the harness of this kind of or the protocol of this benchmark is that you have a model
- 05:31and it gets a very simple tool called search and it accepts a query string and you return some snippets back to the model and the corpus is about 105,000
- 05:43or 100,000 documents.
- 05:44So that's kind of tiny and these are web documents and the end to end accuracy.
- 05:50Um all of these questions have a golden reference answer and you can kind of check if the model and the entire loop produces that exact answer.
- 06:01Um but why kind of why do we need retrieval?
- 06:06I like to compare context windows with floppy discs because I'm old in the 80s, right?
- 06:11We install this kind of games on our computers using floppy discs.
- 06:15So one kind of you guys are so young so you don't probably have this kind of nostalgy but one floppy disc could fit about 1.4 megabytes of data and
- 06:27the current models before they start degrading in quality that's I in my opinion around 350,000 tokens.
- 06:35So that's one floppy disc of data right.
- 06:38Um, so you need retrieval in order to to fetch the information that you actually need to put into the context window and browse plus really demonstrate how uh retrieval quality
- 06:54affects the end toend accuracy of the task.
- 06:57Right?
- 06:57The endto-end accuracy here is essentially is the model equipped with this search tool able to answer the question, right?
- 07:05the riddle like question and if you artificially just stuff the evidence documents that is needed to answer this question into the context window of the model the accuracy is really high
- 07:21right so reasoning is not the bottleneck the model given the edit evidence up front answers the question with a very high accuracy rate even GPT4 um but if you expose the model with a harness with a retrieval tool.
- 07:37That accuracy falls because it now depends on the harness.
- 07:41It depends on the model's ability to formulate queries and the retrieval quality of the retriever.
- 07:48Um so for me this is also quite important because even if we get perfect models like models that are kind of agi you don't have to append make no mistakes
- 08:00you still will be limited to a context window that is approximately a floppy disk right so you have to decide what goes into that context window and I think retrieval
- 08:09is still very relevant as the previous slide showed and in this browsecom plus data set one of these riddlelike questions become a search trajectory because the model execute a query,
- 08:24gets some response back, reads it, reformulates the query and continues until it has kind of filled up the context window or found the answer, whatever comes first.
- 08:37And we spend some time to investigate these trajectories uh to see how GPT5 is formulating queries and we found a lot of interesting aspects with that.
- 08:52Uh we described it in a recent blog post as well.
- 08:55You can find it on hornet.dev.
- 08:57And we like to compare it with a AOL query log.
- 09:02So AOL AOL was like a service back in the day had some search interface and they accidentally published um a very large sample of what people were searching for on the web
- 09:17and they were quite short and I have seen more recent query logs as well and the user human pattern are still searching with just a few terms.
- 09:28GPD5 on the other hand it's a much more powerful user.
- 09:31It has the general knowledge and it can like bam write out very long queries.
- 09:36It can use a lot of syntax operators that are kind of useful from it has learned from web search.
- 09:42So site operator phrases etc. And this is a new type of workload.
- 09:52And on BM25, BM25 has essentially two hyperparameters that controls various aspects of the scoring function.
- 10:02And I talked about having a baseline and BM25 is usually a baseline and browser comp plus as well has a baseline with BM25, but it turns out that that baseline is terrible.
- 10:14So when you look at fancier techniques, embedding models, what have you, um it's stands out as a much better retrieval paradigm than BM25 if you look at the original paper.
- 10:27But more recent research shows that the parameters that were used in the browse comp plus research paper was not really adequate to handle these kind of long documents.
- 10:37So I like this which BM25 do you mean?
- 10:41uh because it has a quite dramatic impact on that specific config benchmarks on the overall accuracy and why is BM25 now more powerful with the new user.
- 10:56So I mentioned the general knowledge of the user and that he can type faster and more be more specific as a more powerful user and exact matching is still relevant right because the model knows names entities
- 11:09uh zip codes uh skus what have you that is not so easy to represent with an embedding model which kind of encodes all the tokens into a fixed vocabulary.
- 11:21Uh it's also relatively cheap especially if you take into consideration the cost of doing embedding inference right some of these embedding models have like 8 billion parameters and you encode text and you have to stand up infrastructure for this and what have you.
- 11:36So it's quite simple and also the tooling uh in the overall ecosystem is quite good.
- 11:41Um, so it's it's readily available and it's also very easy for the model to inspect the results and understand why a certain query formulation returned the result it did, right?
- 11:54Because you're matching literal terms and phrases and things like that which can help it kind of reformulate the queries.
- 12:03So these are the three key things and now into more hot topics on like what is all you need.
- 12:10Um and this is a very recent research that came out from Waterloo from Jimmy Lynn's group up there.
- 12:17They are doing a great job at the information retrieval research and also on agentic search.
- 12:23They have a recent paper that I love.
- 12:26Uh it's called scaling direct corpus interaction via dynamic workspace expansion.
- 12:32So I'll spend some time on expanding this.
- 12:35So imagine you want to stand up web search infrastructure for agents.
- 12:39A lot of companies are doing that at the moment.
- 12:42We are also working with some of these companies to help them build infrastructure for powering that kind of use case.
- 12:48And there you have potentially billions of documents, right?
- 12:53So that doesn't fit into the context window.
- 12:55So you obviously need retrieval and BM25 is a good baseline.
- 12:59So you can retrieve information over that.
- 13:03And the result of this is um you can imagine this as a search engine result page SER for agents because you can place these documents that are retrieved from the retriever into a workspace.
- 13:21And if you organize this workspace as a file system, you can uh play into the same things that you have around skills.
- 13:29You can have progressive disclosure because you can have the document like the title of the document and a small snippet of the document and expose that to the model
- 13:39and the model can then also decide oh I need to read more of the document and when it's doing that it can use all the primitive tools that it's really good at using you all use coding agents so you all seen GP and rip gp and said and
- 13:53whatever it's doing to kind of manage context so here you get the benefits of both worlds and also So you get to combine sandbox infrastructure, retrieval infrastructure.
- 14:02So and VFS and just bash and whatever.
- 14:05So it's also quite exciting, right?
- 14:07Because it combines all of these new type of paradigms that is happening at the moment.
- 14:11So I'm really excited about this type of direction.
- 14:14And it's also kind of a hack, right, to optimize for what the models are good at at the moment, right?
- 14:20Because all the frontier LLM companies are optimizing their model for cool for coding, for bash, for tool use.
- 14:27So if you put your kind of end to end task on the trajectory of that you kind of whatever there's a new model you know there's going to be better at this as well right
- 14:37so might be that when we get AGI they can just use the browser we'll see but currently this is a very powerful way to to build uh retrieval infrastructure
- 14:47and a whole agentic search experience and when it comes to evaluation right I talked about this earlier as well.
- 14:57In traditional information retrieval, we were used to having just one query, one rank list, compute NDG and compare it.
- 15:07That is no longer very relevant when the new user is agent because that agent can reformulate queries and do more queries and do expansion and all kinds of different stuff,
- 15:17right?
- 15:17So, a lot of the classical information retrieval evaluation is now kind of dead.
- 15:23instead look at like see if the model can perform the task it's it's set to and for example for question answering does it get the answer right and we at hornet we are betting on BM25
- 15:38as one of the primitives and we have set out on a vision to kind of have the best most efficient way to evaluate uh BM25 because I think it's such a strong fundamental
- 15:51primitive And this illustration compares some anonymized engines comparing with Hornet on the same type of same type of hardware with um web documents, 100 million web documents on a single node.
- 16:08And as you can see, Hornet has a much more efficient implementation than the other engines and can do more throughput for the same type of bucks, which for a lot of companies that are building infrastructure at the moment for web search etc.
- 16:22means a lot in savings.
- 16:25What is the yaxis?
- 16:26The y-axis is QPS.
- 16:29Sorry.
- 16:32The Y axis is Oh, sorry.
- 16:34The Y axis is latency.
- 16:36I'm sorry.
- 16:40So, four claims to take away from this talk.
- 16:44There's a new user.
- 16:46It's more powerful.
- 16:49It's able to type faster.
- 16:51It's able to read faster.
- 16:52It's able to reformulate queries and it has a lot of general knowledge which makes simple tools like GP and BM25 more powerful.
- 17:03That's number one.
- 17:04Number two, which BM25 do you mean?
- 17:07Uh there are differences in implementation, in performance, in parameters.
- 17:12So think about that.
- 17:14And also why is it effective for agentic search?
- 17:17It's simply because it's explainable for the model.
- 17:20So the model can see and also use it in combination with GP, right?
- 17:24Because you have literal matches and GP is almost about literal matches as well.
- 17:29And the combination of these two is a very strong agentic search or agentic retrieval paradigm.
- 17:39There's a lot of references.
- 17:40I think I will publish a talk uh or the talk will be published and also the the slides and if you hated it, you can tweet at me.
- 17:54Um there is not I was told that there's not a room for for questions but happy to chat about retrieval.
- 18:01You will find me around the conference.
- 18:03Probably best way to reach me is through my ex account and that's it.