Research Agent: open-source paper search
Role: AI Research Contributor (volunteer)
Search backend rebuild for the B2 Foundation
- Problem
- Long searches stalled for 24+ minutes and then crashed, and 50.8% of the corpus had no embeddings.
- What was done
- Merged SQLite, FAISS and BM25 into one LanceDBAn open-source database that stores data alongside vector embeddings and supports both keyword and similarity search over them.Read more about LanceDB on docs.lancedb.com index, traced the crash to five bugs, and backfilled embeddings for 196,082 rows.
- What changed
- After the fixes, a search that had stalled 24+ minutes and crashed finished in 47.7 seconds with zero errors.
- Long search, stall and crash fixed (zero errors after)
- 24+ min to 47.7 s
- Papers in the corpus (2026-07-22 build)
- 385,655
- Two slow queries after the embedding backfill
- 185.2 s to 14.3 s and 10.4 s
- Reranker speed on CPU
- about 3x faster
- Reranker MTEB score, new vs old
- 0.584 vs 0.553
- Reranker size
- 568M to 150M parameters
- Cloud Run peak memory
- 100% (OOM) to about 55% of 8 GiB
- Ranking baseline, Kendall's tau over 16 queries (built, not shipped)
- 0.316
- NDCG@10 over 19 queries (built, not shipped)
- 0.81
Step through a search, then compare search times
Retrieval stages, one search
385,655
papers in the corpus, 2026-07-22 build
The stored library of computer science papers from arXiv and Semantic Scholar, in one LanceDB index on Cloudflare R2.
Stage 1 of 4: 385,655 papers in the corpus, 2026-07-22 build.
Search time, before and after
- Before the fixes24+ minutes, then a crash
- After the fixes47.7 s, zero errors
The stall and crash traced to five bugs in LLM timeouts and connection pooling.
Long search: stalled 24+ minutes and crashed before the fixes, 47.7 s with zero errors after.
Problem
Research Agent searches a stored library of about 385,000 to 390,000 computer science papers from arXiv and Semantic Scholar. Search ran across SQLite, FAISS and BM25. Long searches stalled and crashed, 50.8% of the corpus had no embeddings, and Google Cloud RunA Google Cloud service that runs an app packaged as a container and scales it with traffic, with no servers to manage.Read more about Google Cloud Run on cloud.google.com ran out of memory.
Approach
A query parser reads the brief, with a 4-tier fallback from Groq to OpenRouter to Ollama Cloud to rules. LanceDB hybrid full-text and vector search on Cloudflare R2 fuses results with Reciprocal Rank FusionA simple way to merge several ranked result lists into one, giving each item more credit the higher it ranks in each list.Read more about Reciprocal Rank Fusion on cormack.uwaterloo.ca to 1,200 candidates. SPECTER2An open model from the Allen Institute for AI that turns scientific papers into numeric vectors so similar papers can be found.Read more about SPECTER2 on huggingface.co rerankingA second pass over search results that reorders a shortlist with a slower, more careful model so the best matches come first.Read more about reranking on sbert.net them to 200, then a gte-reranker-modernbert-base cross-encoderA model that reads a query and a document together and scores how relevant they are, more accurate but slower than comparing precomputed vectors.Read more about cross-encoder on sbert.net ranks the reading list and MiniLM picks evidence sentences. FastAPI streams results over Server-Sent EventsA web standard that lets a server push updates to a browser over one open connection, so results appear as they are ready.Read more about Server-Sent Events on developer.mozilla.org.
Highlights
- Merged SQLite, FAISS and BM25 into one LanceDB index of 385,000+ papers.
- Traced a 24+ minute crash to five bugs in LLM timeouts and connection pooling.
- After the fix, the same search finished in 47.7 seconds with zero errors.
- Cut two slow queries from 185.2 s to 14.3 s and 10.4 s.
- Backfilled embeddings for 196,082 rows in a 14-hour checkpointed run.
- Swapped a 568M cross-encoder for a 150M ModernBERT model, about 3x faster on CPU.
- The new reranker scores higher on MTEB, 0.584 vs 0.553.
- Cut Cloud Run peak memory from out-of-memory crashes to about 55% of 8 GiB.
- Rebuilt two broken filters that matched only 21 and 2 of about 390,000 papers.
- Built, not shipped: an LLM-as-judgeUsing a large language model to grade or rank answers or search results, as a faster and cheaper stand-in for human reviewers.Read more about LLM-as-judge on arxiv.org ranking evaluation, Kendall's tauA statistic from minus 1 to 1 that measures how closely two rankings agree, counting pairs of items placed in the same order.Read more about Kendall's tau on en.wikipedia.org 0.316 over 16 queries.
- That evaluation caught a scoring change that would have cut tau to 0.080.