HACKER Q&A
📣 zephodb

Local RAG with private knowledge base


Looking for a free, local, open source RAG solution for running a reference library with 1000s of technical PDFs and word docs. Tried the Ollama + open webui, Ollama+Anything LLM with opensource models such as Llama3.2 etc. As expected the more documents we feed the lower the accuracy. Doing it for a bunch of senior citizens who still love geeking out.


  👤 Ey7NFZ3P0nzAe Accepted Answer ✓
I've made wdoc just for that: https://github.com/thiswillbeyourgithub/WDoc

I am a medical student with thousands of pdfs, various anki databases, video conferences, audio recordings, markdown notes etc. It can query into all of them and return extremely high quality output with sources to each original document.

It's still in alpha though and there's only 0.5 user beside me that I know of so there are bugs that have yet to be found!


👤 pamelafox
I’ve got this RAG repo working entirely locally (Ollama/Postgres) but it doesnt RAG on documents like you want.

https://github.com/Azure-Samples/rag-postgres-openai-python

I’d like to make that version when I have the time, probably just using Llamaindex for the ingestion.

My tips for getting SLMs working well for RAG: http://blog.pamelafox.org/2024/08/making-ollama-compatible-r...


👤 mutagen
I'm very interested in checking something like this out for getting to grips with a local codebase of unfamiliar SQL and assorted scripts and reports.

I have a few tabs open that I haven't had a chance to try:

https://github.com/Mintplex-Labs/anything-llm

https://github.com/Bin-Huang/chatbox

https://github.com/saeedezzati/superpower-chatgpt


👤 shikha1001
You can use BerryDB for doing this use case at scale. BerryDB is a JSON native database that can ingest PDFs, images, etc and it has a built in semantic layer (for labeling) so that way you can build your knowledge database with entities and relationships. This will ground your knowledge with entities and accuracy scales very well with large number of documents

It provides APIs to extract paragraphs or tables from your PDFs in bulk, You can also separately do bulk labeling (say classification, NER and other labeling types). Once you have a knowledge database, it creates 4 indexes on top of your JSON data layer - db index for metadata search, full text search index, annotation index and vector index, so that way you can perform any search operation including hybrid search

The fact that your data layer is in JSON, it gives you infinite flexibility to add new snippets of knowledge or new labels and improve accuracy over time.

https://berrydb.io


👤 imrantech
The key to accuracy is use case specific knowledge graphs. Here is a YouTube video of how to do it. https://youtu.be/iWtF1Qe7QkM The key benefits are - Improved data quality of the data available for genAI - Reduction in risk associated with genAI’s known problems - Increasing business value due to being able to hit use case driven accuracy/reliability, security, and transparency metrics

👤 tmshapland

👤 kingkongjaffa
> expected the more documents we feed the lower the accuracy

Not surprising!

The LLM itself is the least important bit as long as it’s serviceable.

Depending on your goal you need to have a specific RAG strategy.

How are you breaking up the documents? Are the documents consistently formatted to make breaking them up uniform? Do you need to do some preprocessing to make them uniform?

When you retrieve documents how many do you stuff into your prompt as context?

Do you stuff the same top N chunks from a single prompt or do you have a tailored prompt chain retrieving different resourced based on the prompt and desired output?


👤 specproc
Fascinating there doesn't seem to be a consensus "just use this" answer here.

👤 0xbadc0de5
Is it possible that you're using RAG in a nonstandard way? Thousands of documents seems like a lot to feed into a single query. Have you tried using collections and tags to narrow down the field prior to performing the semantic search? You may also want to consider using a larger model or one with a larger context window.

👤 jerpint
Just remember that retrieval is the real bottleneck in RAG, so your problem could very much be related to how you create and embed your chunks and not the model you’re using

👤 ivan_ah
I recently watched a talk[1] on this exact use case: a RAG system that runs on localhost with a simple web UI, and based on very powerful text processing, and a simple backend (PHP and sqlite3 with FTS and vector search extensions).

You can see the project page here: https://textualization.com/ragged/

src and scripts here: https://github.com/Textualization/the-ragged-edge-box

[1] video presentation about the project https://www.youtube.com/watch?v=_fJFuL2pLvw


👤 its_down_again
I recently had some luck turning an excel tracker that lists multiple locations and their services into markdown for RAG. It worked great as a natural language lookup, way better than digging through a big Excel sheet.

I uploaded them through Supabase Embeddings Generator if you're curious. https://github.com/supabase/embeddings-generator

But things got a bit messy when I handed it off to someone else. They started using synonyms for locations, like abbreviated addresses to refer to certain columns, which didn't return the right documents.

Followed a friend's suggestion to try NotebookLM, so I uploaded the same docs there, and it was awesome. Some cloud-hosted vector DB tools only handle PDFs, but NotebookLM accepted my Markdown and chunked the docs better than the Supabase library I was using. It just "worked".

I would swap over to NotebookLM because their document chunking and RAG performance is working for my use case, but they just don’t offer an API yet.

I also gave Gemini a shot using this guide, but didn’t get the results I was hoping for. https://codelabs.developers.google.com/multimodal-rag-gemini...

Am I overhyping NotebookLM? I’d love to know to get on-par document chunking, because that seems to deliver fantastic RAG right out of the box. I’m planning to try some other suggestions I’ve seen here, but any insights into how NotebookLM does its magic would be super helpful.


👤 depingus
txtai was brought up in a discussion yesterday. I saved it to look at later. But you might find it useful. https://github.com/neuml/txtai

Here is that that thread. https://news.ycombinator.com/item?id=41981907


👤 gmac
I've been working on this, which allows you to build a full RAG pipeline in Postgres: https://github.com/neondatabase-labs/pgrag. You can compile it yourself, or it's available on Neon (including the free plan) since yesterday.

👤 kylecazar
I would look at articles on building an open source RAG pipeline. Generation (model) is the last in a series of important steps -- you have options to choose from (retrieval, storage, etc) in each component step. Those decisions will affect the accuracy you mention.

Langchain, llamaindex have good resources on building such a pipeline the last I checked


👤 obelos
You might find Rag to Riches' (R2R) built-in use of Unstructured for doc parsing, hybrid search, knowledge graphs, and HyDE queries improves the quality of your retrievals. https://github.com/SciPhi-AI/R2R

👤 teleforce
Check this Manning Early Access Program (MEAP) soon to be published book on AI-Powered Search:

https://www.manning.com/books/ai-powered-search


👤 wu-tsy

👤 pruthvishetty
Why not use FAISS and/or ChromaDB?

👤 jz391
Does anyone have experience using any of these for scientific paper PDFs, in particular containing equations (I'm guessing graphs are still well beyond their reach)? The workflow for these seems to involve converting PDF->text...

👤 _jonas
This one looks pretty good, haven't tried it yet though: https://github.com/QuivrHQ/quivr

👤 shreyasbg

👤 bluesounddirect
The New York Post or the Daily News .

👤 youmom
vvgthfvukjn,hn

👤 KateSterling
look into Rig. It’s a Rust library that works with LLMs and integrates well with vector stores like MongoDB.

Helpful for building a scalable, local RAG solution tailored to your group’s needs—plus, it’s open source-friendly if i'm correct.