23 comments

  • simonw20 hours ago
    My advice for building something like this: don&#x27;t get hung up on a need for vector databases and embedding.<p>Full text search or even grep&#x2F;rg are a lot faster and cheaper to work with - no need to maintain a vector database index - and turn out to work really well if you put them in some kind of agentic tool loop.<p>The big benefit of semantic search was that it could handle fuzzy searching - returning results that mention dogs if someone searches for canines, for example.<p>Give a good LLM a search tool and it can come up with searches like &quot;dog OR canine&quot; on its own - and refine those queries over multiple rounds of searches.<p>Plus it means you don&#x27;t have to solve the chunking problem!
    • navar7 hours ago
      I created a small app that shows the difference between embedding-based (&quot;semantic&quot;) and bm25 search:<p><a href="http:&#x2F;&#x2F;search-sensei.s3-website-us-east-1.amazonaws.com&#x2F;" rel="nofollow">http:&#x2F;&#x2F;search-sensei.s3-website-us-east-1.amazonaws.com&#x2F;</a><p>(warning! It will download ~50MB of data for the model weights and onnx runtime on first load, but should otherwise run smoothly even on a phone)<p>It runs a small embedding model in the browser and returns search results in &quot;real time&quot;.<p>It has a few illustrative examples where semantic search returns the intended results. For example bm25 does not understand that &quot;j lo&quot; or &quot;jlo&quot; refer to Jennifer Lopez. Similarly embedding based methods can better deal with things like typos.<p>EDIT: search is performed over 1000 news articles randomly sampled from 2016 to 2024
    • andai12 hours ago
      <a href="https:&#x2F;&#x2F;www.anthropic.com&#x2F;engineering&#x2F;contextual-retrieval" rel="nofollow">https:&#x2F;&#x2F;www.anthropic.com&#x2F;engineering&#x2F;contextual-retrieval</a><p>Anthropic found embeddings + BM25 (keyword search) gave the best results. (Well, after contextual summarization, and fusion, and reranking, and shoving the whole thing into an LLM...)<p>But sadly they didn&#x27;t say how BM25 did on its own, which is the really interesting part to me.<p>In my own (small scale) tests with embeddings, I found that I&#x27;d be looking right at the page that contained the literal words in my query and embeddings would fail to find it... Ctrl+F wins again!
      • bredren7 hours ago
        FWIW, the org decided against vector embeddings for Claude Code due in part to maintenance. See 41:05 here: <a href="https:&#x2F;&#x2F;youtu.be&#x2F;IDSAMqip6ms" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;IDSAMqip6ms</a>
        • skrebbel5 minutes ago
          who&#x27;s &quot;the org&quot;?
        • mips_avatar6 hours ago
          It would also blow up the price&#x2F;latency of Claude code if every chunk of every file had to be read into haiku-&gt;summarized-&gt;sent to an embedding model -&gt;reindexed into a project index and that index stored somewhere. Since there’s a lot of context inherent in things like the file structure, storing the central context in Claude.md is a lot simpler. I don’t think them not using vector embeddings in the project space is anything other than an indication that it’s hard to manage embeddings in Claude code.
      • noobcoder8 hours ago
        No cross encoders?
    • drittich59 minutes ago
      Do you have a standard prompt you use for this? I have definitely seen agentic tools doing this for me, e.g., when searching the local file system, but I&#x27;m not sure if it native behaviour for tool-using LLMs or if it is coerced via prompts.
    • whakim12 hours ago
      In my experience the semantic&#x2F;lexical search problem is better understood as a precision&#x2F;recall tradeoff. Lexical search (along with boolean operators, exact phrase matching, etc.) has very high precision at the expense of lower recall, whereas semantic search sits at a higher recall&#x2F;lower precision point on the curve.
      • simonw12 hours ago
        Yeah, that sounds about right to me. The most effective approach does appear to be a hybrid of embeddings and BM25, which is worth exploring if you have the capacity to do so.<p>For most cases though sticking with BM25 is likely to be &quot;good enough&quot; and a whole lot cheaper to build and run.
        • mips_avatar6 hours ago
          Depends on the app and how often you need to change your embeddings, but I run my own hybrid semantic&#x2F;bm25 search on my MacBook Pro across millions of documents without too much trouble.
    • cwmoore17 hours ago
      I recently came across a “prefer the most common synonym” problem, in Google Maps, while searching for a poolhall—even literally ‘billiards’ returned results for swimming pools and chlorine. I wonder if some more NOTs aren’t necessary…interested in learning about RAGs though I’m a little behind the curve.
    • victorbuilds4 hours ago
      This matches what I found building an AI app for kids. Started with embeddings because everyone said to, then ripped it out and went with simple keyword matching. The extra complexity wasn&#x27;t worth it for my use case. Most of the magic comes from the LLM anyway, not the retrieval layer.
    • froobius19 hours ago
      Hmm it can capture more than just single words though, e.g. meaningful phrases or paragraphs that could be written in many ways.
    • mips_avatar19 hours ago
      In my app the best lexical search approaches completely broke my agent. For my rag system the llm would on average take 2.1 lexical searches to get the results it needed. Which wasn’t terrible but it meant sometimes it needed up to 5 searches to find it which blew up user latency. Now that I have a hybrid semantic search + lexical search it only requires 1.1 searches per result.
      • nostrebored15 hours ago
        The problem is not using parallel tool calling or not returning a search array. We do this across large data sets and don’t see much of a problem. It also means you can swap algorithms on the fly. Building a BM25 index over a few thousand documents is not very expensive locally. Rg and grep are freeish. If you have information on folder contents you can let your agent decide at execution time based on information need.<p>Embeddings just aren’t the most interesting thing here if you’re running a frontier fm.
        • mips_avatar6 hours ago
          Search arrays help, but parallel tool calling assumes you’ve solved two hard problems: generating diverse query variations, and verifying which result is correct. Most retrieval doesn’t have clean verification. The better approach is making search good enough that you sidestep verification as much as possible (hopefully you are only requiring the model to make a judgment call within its search array). In my case (OpenStreetMap data), lexical recall is unstable, but embeddings usually get it right if you narrow the search space enough—and a missed query is a stronger signal to the model that it’s done something wrong.<p>Besides, if you could reliably verify results, you’ve essentially built an RL harness—which is a lot harder to do than building an effective search system and probably worth more.
    • leetrout20 hours ago
      Simon have you ever given a talk or written about this sort of pragmatism? A spin on how to achieve this with Datasette is an easy thing to imagine IMO.
      • simonw16 hours ago
        I did a livestream thing about building RAG against FTS search in Datasette last year: <a href="https:&#x2F;&#x2F;simonwillison.net&#x2F;2024&#x2F;Jun&#x2F;21&#x2F;search-based-rag&#x2F;" rel="nofollow">https:&#x2F;&#x2F;simonwillison.net&#x2F;2024&#x2F;Jun&#x2F;21&#x2F;search-based-rag&#x2F;</a>
    • tra320 hours ago
      I built a simple emacs package based on this idea [0]. It works surprisingly well, but I dont know how far it scales. It&#x27;s likely not as frugal from a token usage perspective.<p>0: <a href="https:&#x2F;&#x2F;github.com&#x2F;dmitrym0&#x2F;dm-gptel-simple-org-memory" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dmitrym0&#x2F;dm-gptel-simple-org-memory</a>
    • dmezzetti3 hours ago
      Are multiple LLM queries faster than vector search? Even with the example &quot;dog OR canine&quot; that leads to two LLM inference calls vs one. LLM inference is also more expensive than vector search.<p>In general RAG != Vector Search though. If a SQL query, grep, full text search or other does the job then by all means. But for relevance-based search, vector search shines.
    • pstuart17 hours ago
      Perhaps SQLite with FTS5? Or even better, getting DuckDB into the party as it&#x27;s ecosystem seems ripe for this type of work.
    • enraged_camel20 hours ago
      Yes, exactly. We have our AI feature configured to use our pre-existing TypeSense integration and it&#x27;s stunningly competent at figuring out exactly what search queries to use across which collections in order to find relevant results.
      • busssard19 hours ago
        if this is coupled with powerful search engines beyond elastic then we are getting somewhere. other nonmonotonic engines that can find structural information are out there.
  • mips_avatar21 hours ago
    One thing I didn’t see here that might be hurting your performance is a lack of semantic chunking. It sounds like you’re embedding entire docs, which kind of breaks down if the docs contain multiple concepts. A better approach for recall is using some kind of chunking program to get semantic chunks (I like spacy though you have to configure it a bit). Then once you have your chunks you need to append context to how this chunk relates to the rest of your doc before you do your embedding. I have found anthropics approach to contextual retrieval to be very performant in my RAG systems (<a href="https:&#x2F;&#x2F;www.anthropic.com&#x2F;engineering&#x2F;contextual-retrieval" rel="nofollow">https:&#x2F;&#x2F;www.anthropic.com&#x2F;engineering&#x2F;contextual-retrieval</a>) you can just use gpt oss 20b as the model for generation of context.<p>Unless I’ve misunderstood your post and you are doing some form of this in your pipeline you should see a dramatic improvement in performance once you implement this.
    • yakkomajuri19 hours ago
      hey, author (not op) here. we do do semantic chunking! I think maybe I gave the impression that we don&#x27;t because of the mention of aggregating context but I tested this with questions that would require aggregating context from 15+ documents (meaning 2x that in chunks), hence the comment in the post!
      • NebulaStorm4564 hours ago
        Is there a way to convert documents into a hierarchical connected graph data structure which references each other similar to how we use personal knowledge tools like Obsidian and ability to traverse this graph? Is GraphRag technique trying to do this exactly?
      • mips_avatar19 hours ago
        Ah so you’re generating context from multiple docs for your chunks? How do you decide which docs get aggregated?
        • nostrebored15 hours ago
          Haven’t seen an answer better than “vibes” here. Especially with data across multiple domains.
          • mips_avatar11 hours ago
            I mean as long as they&#x27;re not too long I suppose you could use just about any heuristic for grouping sources. Just seems like it would be hard to generate succinct context if you mess it up.
  • nilirl20 hours ago
    Why is it implicit that semantic search will outperform lexical search?<p>Back in 2023 when I compared semantic search to lexical search (tantivy; BM25), I found the search results to be marginally different.<p>Even if semantic search has slightly more recall, does the problem of context warrant this multi-component, homebrew search engine approach?<p>By what important measure does it outperform a lexical search engine? Is the engineering time worth it?
    • kgeist17 hours ago
      It depends on how you test it. I recently found that the way devs test it differs radically from how users actually use it. When we first built our RAG, it showed promising results (around 90% recall on large knowledge bases). However, when the first actual users tried it, it could barely answer anything (closer to 30%). It turned out we relied on exact keywords too much when testing it: we knew the test knowledge base, so we formulated our questions in a way that helped the RAG find what we expected it to find. Real users don&#x27;t know the exact terminology used in the articles. We had to rethink the whole thing. Lexical search is certainly not enough. Sure, you can run an agent on top of it, but that blows up latency - users aren&#x27;t happy when they have to wait more than a couple of seconds.
      • victorbuilds4 hours ago
        This is the gap that kills most AI features. Devs test with queries they already know the answer to. Users come in with vague questions using completely different words. I learned to test by asking my kids to use my app - they phrase things in ways I would never predict.
        • embedding-shape1 hour ago
          Ironically, pitting a LLM (ideally a completely different model) up against what you&#x27;re testing, letting it write human &quot;out of the ordinary&quot; queries to use as test cases tend to work well too, if you don&#x27;t have kids you can use as a free workforce :)
      • babelfish13 hours ago
        How did you end up changing it? Creating new evals to measure the actual user experience seems easy enough, how did that inform your stack?
    • mips_avatar19 hours ago
      Depends on how important keyword matching vs something more ambiguous is to your app. In Wanderfugl there’s a bunch of queries where semantic search can find an important chunk that lacks a high bm25 score. The good news is you can get all the benefits of bm25 and semantic with a hybrid ranking. The answer isn’t one or the other.
    • andoando19 hours ago
      The benefit I see is you can have queries like &quot;conversations between two scientists&quot;.<p>Its very dependent on use case imo
  • davedx7 hours ago
    &gt; we use Sentence Transformers (all-MiniLM-L6-v2) as our default (solid all-around performer for speed and retrieval, English-only).<p>Huh, interesting. I might be building a German-language RAG at some point in my future and I never even considered that some models might not support German at all. Does anyone have any experience here? Do many models underperform or not support non-English languages?
    • navar7 hours ago
      You can refer to <a href="https:&#x2F;&#x2F;huggingface.co&#x2F;spaces&#x2F;mteb&#x2F;leaderboard" rel="nofollow">https:&#x2F;&#x2F;huggingface.co&#x2F;spaces&#x2F;mteb&#x2F;leaderboard</a> and use that to guide your selection.<p>Check under the &quot;Retrieval&quot; section, either RTEB Multilingual or RTEB German (under language specific).<p>You may also want to filter for model sizes (under &quot;Advanced Model Filters&quot;). For instance if you are self-hosting and running on a CPU it may make sense to limit to something like &lt;=100M parameters models.
    • yakkomajuri2 hours ago
      &gt; Do many models underperform or not support non-English languages?<p>Yes they do. However:<p>1. German is one of the more common languages to train on so more models will support it than say, Bahasa<p>2. There should still be a reasonable amount of multi-lingual models available. Particularly if you&#x27;re OK with using proprietary models via API. AFAIK all the frontier embedding and reranking models (non open-source) are multi-lingual
    • architectonic7 hours ago
      Yes I can confirm that,we had resorted to a multilingual embedding model back in the day. <a href="https:&#x2F;&#x2F;link.springer.com&#x2F;chapter&#x2F;10.1007&#x2F;978-3-031-77918-3_15" rel="nofollow">https:&#x2F;&#x2F;link.springer.com&#x2F;chapter&#x2F;10.1007&#x2F;978-3-031-77918-3_...</a>
  • andai8 hours ago
    When I started playing with this stuff in the GPT-4 days (8K context!), I wrote a script that would search for a relevant passage in a book, by shoving the whole book into GPT-4, in roughly context sized chunks.<p>I think it was like a dollar per search or something in those days. We&#x27;ve come a long way!<p>Anthropic, in their RAG article, actually say that if your thing fits in context, you should probably just put it there instead of using RAG.<p>I don&#x27;t know where the optimal cutoff is though, since quality does suffer with long contexts. (Not to mention price and speed.)<p><a href="https:&#x2F;&#x2F;www.anthropic.com&#x2F;engineering&#x2F;contextual-retrieval" rel="nofollow">https:&#x2F;&#x2F;www.anthropic.com&#x2F;engineering&#x2F;contextual-retrieval</a><p>The context size and pricing has come so far! Now the whole book fits in context, and it&#x27;s like 1 cent to put the whole thing in context.<p>(Well, a little more with Anthropic&#x27;s models ;)
  • Oras7 hours ago
    The hardest part in RAQ is document parsing. If you only consider text then it should be ok, but once you start having tables, tables going multiple pages, charts, ignore TOC when available, footnotes … etc, that part becomes really hard and accuracy suffers to get the context regardless of what chunking do you use.<p>There are some patterns to help such as RAPTOR where you make ingestion content aware and instead of just ingesting content, you start using LLMs to question and summarise the content and save that to the vector database.<p>But reality is, having one size fits all for RAQ is not an easy task.
    • Royce-CMR6 hours ago
      Super noob in vector embeddings: I never considered that tables would be a complexifier. (beyond defining in a parseable format for ingestion).<p>Do vector databases do better with long grouped text vs table formats?
      • Oras5 hours ago
        The issue is the ingestion (extracting the right data in the right format). This is mainly an issue in PDFs and sometimes when there are tables added as images in Docx too. You need a mix of text and OCR extraction to get the data correctly first before start chunking and adding embeddings
  • nh26 hours ago
    I&#x27;d like to have a local, fully offline and open-source software into which I can dump all our Emails, Slack, Gdrive contents, Code, and Wiki, and then query it with free form questions such as &quot;with which customers did we discuss feature X?&quot;, producing references to the original sources.<p>What are my options?<p>I want to avoid building my own or customising a lot. Ideally it would also recommend which models work well and have good defaults for those.
  • autogn0me12 hours ago
    What we use: - <a href="https:&#x2F;&#x2F;github.com&#x2F;ggozad&#x2F;haiku.rag" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ggozad&#x2F;haiku.rag</a><p>Why?<p>- developer oriented (easy to read Python and uses pydantic-ai)<p>- benchmarks available<p>- docling with advanced citations (on branch)<p>- supports deep research agent<p>- real open source by long term committed developer not fly by night
  • into_the_void9 hours ago
    Interesting perspective on the use of full-text search over vector databases for RAG. I appreciate the insights on agentic tool loops and handling fuzzy searching.
  • urbandw311er19 hours ago
    When it comes to the evals for this kind of thing, is there a standard set of test data out there that one can work with to benchmark against? ie a collection of documents with questions that should result in particular documents or chunks being cited as the most relevant match.
    • autogn0me10 hours ago
      Yes check out haiku-rag benchmarks and evaluations
  • JKCalhoun12 hours ago
    I kinda do want to build a local RAG? I want some significant subset of Wikipedia (I assume most people know about these) on a dedicated machine with a RAG front-end. I would have then an offline Wikipedia &quot;librarian&quot; I could query.<p>But I&#x27;m lazy and assumed that someone has already built such a thing. I&#x27;m just not aware of this &quot;Wikipedia-RAG-in-a-box&quot;.
    • yakkomajuri2 hours ago
      In this case do you even need a RAG? Most models will have been trained on Wikipedia anyway.<p>Give Jan (<a href="https:&#x2F;&#x2F;www.jan.ai&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.jan.ai&#x2F;</a>) a try for instance. You&#x27;ll need to do a bit of research as to what model will give you the best perf on your system but one of the quantized Llama or Qwen models will probably suit you well.
  • mijoharas18 hours ago
    I&#x27;m interested in the embeddings models suggested. I had some good results with nomic in a small embedding based tool I built. I also heard a few good things about qwen3-embedding, though the latency wasn&#x27;t great for my usecase so I didn&#x27;t pursue it much further.<p>Similarly, I used sqlite-vec, and was very happy with it. (if I were already using postgres I&#x27;d have gone with that, but this was more of a cli tool).<p>If the author is here, did you try any of those models? how would you compare the ones you did use?
  • _joel20 hours ago
    You can get local RAG with Anythingllm if you want minimal effort too fwiw. Pretty much plug and play. Used it for simple testing for an idea before getting into the weeds of langchain and agentic RAG.
  • barbazoo20 hours ago
    &gt; What that means is that when you&#x27;re looking to build a fully local RAG setup, you&#x27;ll need to substitute whatever SaaS providers you&#x27;re using for a local option for each of those components.<p>Even starting with having &quot;just&quot; the documents and vector db locally is a huge first step and much more doable than going with a local LLM at the same time. I don&#x27;t know any one or any org that has the resources to run their own LLM at scale.
    • mips_avatar19 hours ago
      It’s also just extremely viable to just host your own vector db. You just need a server with enough ram for your hnsw index.
    • procaryote19 hours ago
      Aren&#x27;t there a bunch of models that run OK on consumer hardware now?
      • lukan16 hours ago
        Hopefully my new GPU will arrive tomorrow, then I can confirm myself, but if you look around online, there are lots of private people out there running their own models. A 16 GB GPU starts at 270€, which lets you run something like deepseek r.14, 32 GB GPUs start at 1200 € and then it goes further up, in model quality and price. (Top models require something like 60- 200 GB of GPU memory I think)<p>So for sure any medium sized company could afford to run their own LLMs, also at scale if they want to make the investment. The question is, how much they value their confidential data. (I would not trust any of the big AI companies). And you don&#x27;t usually need cutting edge reasoning and coding abilities to process basic information.
      • FuckButtons8 hours ago
        A 120gb ram MacBook Pro will run gpt-oss-120b at a very respectable clip and I’ve found it to be quite serviceable for a lot of tasks.
        • adastra228 hours ago
          I bought one for this purpose, but LM Studio doesn&#x27;t seem to want to run even the most quantized versions. Any suggestions?
          • FuckButtons42 minutes ago
            Are you using the mix quantized versions? Also, there’s a setting that disables the memory allocation guardrails they put in place, which are irrelevant since macOS handles oom quite gracefully.
  • 0xC4517 hours ago
    For an open source, local (or cloud) vector DB, I would also recommend checking out Chroma (<a href="https:&#x2F;&#x2F;trychroma.com" rel="nofollow">https:&#x2F;&#x2F;trychroma.com</a>). It also supports full text search. Disclaimer: I work on Chroma cloud.
  • kbrisso20 hours ago
    I built this for local RAG <a href="https:&#x2F;&#x2F;github.com&#x2F;kbrisso&#x2F;byte-vision" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kbrisso&#x2F;byte-vision</a> it uses llama.cpp and Elasticsearch. On a laptop with 8 GB GPU it can handle a 30K token size and summarize a fairly large PDF.
    • busssard19 hours ago
      elasticsearch is the true limitation of rag systems...
      • kbrisso19 hours ago
        The vector search works great once you figure it out. I wanted to focus on writing the application and not have to rewrite a document store.
  • dwa359219 hours ago
    If you end up using any of the frontier models, don&#x27;t forget to protect private information in your prompts - <a href="https:&#x2F;&#x2F;github.com&#x2F;deepanwadhwa&#x2F;zink" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;deepanwadhwa&#x2F;zink</a>
    • cjonas19 hours ago
      Doesn&#x27;t seems necessary if you are using claude via bedrock or gpt via azure. At that point, its not different then sending PII through a serverless function.
      • wanderingmind10 hours ago
        Care to explain more? I understand the prompt might not be used for training, but how about sanitizing the PII from tracking or logging or memory bugs in these serverless functions
  • spacecadet2 hours ago
    You can vibe code a local RAG with or without vectors in 5 minutes. Like another commenter pointed out, unless your corpus is huge, you do not need vectors, but hey using vectors is fun so why not.<p>For what its worth, I run a local first, small model, private RAG that uses LangGraph, Neo4J knowledge graphs, I swap the models around constantly. It mostly just gets called by agent tools now.
    • okeuro491 hour ago
      Do you run the models locally?<p>No local model for me manages to get function calling right.
  • throwaway193435 hours ago
    No
  • johnebgd17 hours ago
    Interesting stack. I’ve been working on doing something like this with Apple specific tech. Swiftdata is not easy to work with.
  • ElasticBottle12 hours ago
    How does this compare with orama?
  • adastra228 hours ago
    Rust API?
    • yakkomajuri2 hours ago
      Post author (not OP) here.<p>Would you want a Rust SDK for Skald?
      • adastra221 hour ago
        Yes, none of the languages listed are very accessible from the frameworks I&#x27;m working with.
  • dmezzetti18 hours ago
    Glad to see all the interest in the local RAG space, it&#x27;s been something I&#x27;ve been pushing for a while.<p>I just put this example together today: <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;davidmezzetti&#x2F;d2854ed82f2d0665ec7efdd073d575d7" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;davidmezzetti&#x2F;d2854ed82f2d0665ec7efd...</a>