Show HN: Semble – Code search for agents that uses 98% fewer tokens than grep

github.com

187 points by Bibabomas 11 hours ago

Hey HN! We (Stephan and Thomas) recently open-sourced Semble. We kept running into the same problem while using Claude Code on large codebases: when the agent can't find something directly, it falls back to grep, reading full files or launching subagents. This uses a lot of tokens, and often still misses the relevant code. There are existing tools for this, but they were either too slow to index on demand, needed API keys, or had poor retrieval quality.

Semble is our solution for this. It combines static Model2Vec embeddings (using our latest static model: potion-code-16M) with BM25, fused via RRF and reranked with code-aware signals. Everything runs on CPU since there's no transformers involved. On our benchmark of ~1250 query/document pairs across 63 repos and 19 languages, it uses 98% fewer tokens than grep+read and reaches 99% of the retrieval quality of a 137M-parameter code-trained transformer, while being ~200x faster.

Main features:

- Token-efficient: 98% fewer tokens than grep+read

- Fast: ~250ms to index a typical repo on our benchmark, ~1.5ms per query on CPU (very large repos may take longer)

- Accurate: 0.854 NDCG@10, 99% of the best transformer setup we tested

- MCP server: drop-in for Claude Code, Cursor, Codex, OpenCode

- Zero config: no API keys, no GPU, no external services

Install in Claude Code with: claude mcp add semble -s user -- uvx --from "semble[mcp]" semble

Or check our README for other installation instructions, benchmarks, and methodology:

Semble: https://github.com/MinishLab/semble

Benchmarks: https://github.com/MinishLab/semble/tree/main/benchmarks

Model: https://huggingface.co/minishlab/potion-code-16M

Let us know if you have any feedback or questions!

jerezzprime 7 hours ago

I'd be interested in seeing actual agent benchmarks (eg CC or Copilot CLI with grep removed and this tool instead).

For example, I have explored RTK and various LSP implementations and find that the models are so heavily RL'd with grep that they do not trust results in other forms and will continually retry or reread, and all token savings are lost because the model does not trust the results of the other tools.

  • stephantul 6 hours ago

    Yeah we're also interested in doing this, it's on the roadmap together with optimization of the prompt and descriptions so that models have an easier time using it.

    Perhaps anecdotally: we do use this tool ourselves of course, and it's been working pretty well so far. Anthropic models call it and seem to trust the results.

  • giancarlostoro 6 hours ago

    I forced Claude to have a global memory for RTK and my own AI memory system (GuardRails) which it happily uses both, the only times it doesnt use GuardRails is if I dont mention it at all, otherwise it always uses RTK unless RTK falls apart running a tool it does not support.

  • nextaccountic 5 hours ago

    Codex CLI is quite happy running RTK. Well with GPT 5.5 xhigh anyway

    One thing that irks me is that when it doesn't support eg. a cli flag of find, it gives an error message rather than sending the full output of the command instead. Then the agent wastes tokens retrying, or worse, doesn't even try because the prompting may make them afraid to not run commands without rtk

    • aleksiy123 4 hours ago

      how effective is RTK for you? worth using?

      • maille 3 hours ago

        Wondering too

      • philipbjorge 30 minutes ago

        I can't find the relevant issues in their repo, but I've been somewhat skeptical of their tool over-reporting token savings and there are many issues to that effect in the repo.

        I'm not likely to install it again in my latest configuration, instead applying some specific tricks to things like `make test` to spit out zero output exit on unsuccessful error codes, that sort of thing. Anecdotally, I see GPT-5.5 often automatically applying context limiting flags to the bash it writes :shrug:

  • AussieWog93 4 hours ago

    I just put something in my global CLAUDE.md (under ~/.Claude) asking it to use the LSP instead of grep and have never had this issue since.

    • gigatexal 4 hours ago

      My q would have been this. Lsp solved this no?

    • yakbarber 3 hours ago

      can you share that prompt?

andai 50 minutes ago

Nice, this sounds great. I want to mention a related issue here, which is that on small codebases, Claude spends a lot of time looking for stuff when it could have just dumped the whole codebase into the context in one go and used very little tokens.

I found a nice workaround which is that you can just dump the whole directory into context, as a startup hook. So then Claude skips the "fumble around blindly in the dark" portion of every task. (I've also seen a great project that worked on bigger repos where it'll give the model an outline with stubs, though I forget what it was called.)

aadishv 23 minutes ago

Seems like a cool idea so I decided to play with it a bit. The test I ran was in the browsercode (https://github.com/browser-use/browsercode) repo with the following prompt:

"Answer this question by only using the `semble` CLI (docs below):

> What tools does Browsercode provide to the agent other than the base OpenCode tools? Provide the exact schema for tool input and tool output and briefly summarize what they do and how they work

---

[the AGENTS.md snippet provided from https://github.com/MinishLab/semble#bash-integration]"

And the equivalent for the non-Semble test:

"Answer this question by only using the `rg` and `fd` CLIs:

> What tools does Browsercode provide to the agent other than the base OpenCode tools? Provide the exact schema for tool input and tool output and briefly summarize what they do and how they work"

In both cases, I used Pi with gpt-5.4 medium and a very minimal setup otherwise. (And yes, I did verify that either instance only used rg & fd, or only used semble.)

Without Semble, it used 10.9% of the model context and used $0.144 of API credits (or, at least, that's what Pi reported - I used this with a Codex sub so cannot be sure). With Semble, it used 9.8% of the model context and $0.172 of API credits. The resulting responses were also about the same. Very close!

I tried one more test in the OpenCode repo. The question was > Trace the path from 1) the OPENCODE_EXPERIMENTAL_EXA env var being set to to 1 to 2) the resulting effects in the system prompt or tool provided to the OpenCode agent.

And I included the same instructions/docs as above. The non-Semble version was a bit more detailed -- it went into whether the tool call path invoked Exa based on whether Exa or Parallel was enabled for the web search provider -- but w.r.t. actually answering the question, both versions were accurate. The Semble version used 14.7% context / $0.282 API cost, while the non-Semble version used 19.0% / $0.352. Clearly a win for Semble for context efficiency, but note that the non-Semble version finished about twice as fast as the Semble version.

Of course this is just me messing around. ymmv.

gslepak 15 minutes ago

Does this support any language or is it limited to a specific set of languages?

esperent 2 hours ago

I did some evals with pi and GPT 5.5. I tested RTK on / headroom on / both on / both off (all with the standard pi system instructions and no AGENTS.md).

I forget the exact tests I used (a couple of the standard agent evals that people use, one python and one typescript because those are what I use).

I don't claim it was an exhaustive test, or even a good one. It's possible I could have spent a day or so tuning my AGENTS.md and the pi system prompt/tool instructions and gotten better results, because if there's one thing running evals taught me it's that subtle differences there can change the results a lot.

However, I got clearly better results with both off, enough to convince me to stop the tests immediately after 3 rounds.

The problem was that while context use did go down (sometimes), the number of turns to complete went up so the overall cost of the conversation was higher.

It's made me very aware of one thing: so many people are sharing these kind of tools, but either with zero evals (or suspiciously hard to reproduce), or in the case of this one, extensive benchmarks testing the wrong thing.

I'm sure this tool does use fewer tokens than grep, and the benchmarks prove it, but that's not what matters here. What matters is, does an agent using it get the same quality of work done more quickly and for lower cost?

  • zobzu 1 hour ago

    with AI the "they could so they never wondered if they should" will be a very frequent thing.

    • jack_pp 53 minutes ago

      yeah I think I'm prone to do the same, it is so easy to create and we get too excited by it instead of first doing the research necessary which is much more boring than actually producing something.

AussieWog93 4 hours ago

Better than grep obviously, but how does this compare to existing LSPs?

  • CharlesW 3 hours ago
    • cormacrelf 49 minutes ago

      Try running both on the CK codebase. CK takes like 15 minutes to index itself and gives hundreds of completely irrelevant doc comments as results for “run model on CPU” query. Semble indexes for like 3 seconds and prints out the actual code that runs the model on the CPU.

singpolyma3 5 hours ago

Semantic code search seems like a useful tool for a human too. Not just for agents.

abcdefg12 5 hours ago

Shouldn’t it be a part of the harness at least for local codebase? I wonder how many harnesses are doing that already.

  • dopidopHN2 4 hours ago

    I'm playing with PI as a custom harness ( for Claude code because that what is provided to me )

    I will try that ! It make sense and I'm curious to see results, for this or any similar projects mentioned in the thread

wrxd 4 hours ago

I also like the index feature form https://maki.sh Source code has a lot of structure, using a real parser instead of grepping and reading files can potentially save a lot of tokens

onoesworkacct 2 hours ago

fantastic token savings and performance... but unlike grep it's probabilistic search on search terms.

is that an issue? the tiny model might not surface something important

smcleod 5 hours ago

How does it compare to context-mode or serina that are both well established now?

esafranchik 9 hours ago

Is the benchmark measuring one-shot retrieval accuracy, or Coding agent response accuracy?

  • stephantul 9 hours ago

    Hey! Co-author here. The benchmark currently only measures retrieval accuracy.

    We’re interested in measuring it end to end and also optimizing, e.g. the prompt and tools, for this, but we just haven’t gotten around to it.

    • esafranchik 9 hours ago

      Two follow-ups:

      1) How do you compare accuracy? by checking if the answer is in any of the returned grep/bm25/semble snippets?

      2) How do you measure token use without the agent, prompt, and tools?

      • stephantul 9 hours ago

        1) yes! It’s not accuracy, but ndcg 2) we assume that if the agent gets the correct answer in the returned snippets it does not need to read further

        • esafranchik 8 hours ago

          Wouldn't NDCG/token results vary wildly depending on the agent's query and the number of returned items?

          e.g. agents often run `grep -m 5 "QUERY"` with different queries, instead of one big grep for all items.

          • stephantul 8 hours ago

            The same holds for semble: the agent can fire off many different semble queries with different k/parameters.

            I guess the point we’re trying to make is that you need fewer semble queries to achieve the same outcome, compared to grep+readfile calls.

jahala 4 hours ago

This looks great! I built a tool in the same space- and I found that the biggest challenge was often to get the agent to prefer to use the tool over bash tools. What’s your experience with that?

  • Escapade5160 4 hours ago

    Setup hooks. Hooks are how your harness forces compliance with your own rules.

porker 5 hours ago

Congratulations on the release!

Could you add fff to the benchmarks?

mrpf1ster 8 hours ago

Does this work well for non-coding documents as well? Say api docs or AI memory files?

  • stephantul 8 hours ago

    Hey, this is something we're actively investigating. We recently added a flag, `--include-text-files`, which, when set, also makes Semble index regular documents (i.e., markdown, text, json). This should also work relatively well.

ramsono 3 hours ago

Very useful thanks for sharing!

ludicrousdispla 8 hours ago

grep doesn't need tokens, so what is 98% fewer than zero?

  • stephantul 8 hours ago

    You need readfile to do something with those tokens. Grep only gives you the matching lines, not the context.

    • djaboss 8 hours ago

      `grep -C $NUM` ? ;)

      • stephantul 8 hours ago

        Even so. Take a look at the NDCG numbers for grep. It's not pretty

        • hparadiz 6 minutes ago

          ripgrep exists though

vikeri 5 hours ago

very curious to give it a spin but why write a cli in python? would surely be faster and more portable with go or rust?

  • skeledrew 4 hours ago

    Perhaps Python is their main language (they seem to be ML peeps, which would make that most likely), which means it's easier for them to do manual reviews even if they're using AI for implementing, etc.