Live data from Hacker News

Ask HN: I have many PDFs – what is the best local way to leverage AI for search?

news.ycombinator.com

41–50 of 92 posts

Re: Ask HN: I have many PDFs – what is the best local way to leverage AI for search?

#41

rga, aka ripgrep-all, is my go-to for this. I suppose grep is a form of AI -- or, at least, an advanced intelligence that's wiser than it looks. ;) https://github.com/phiresky/ripgrep-all

+1 for this. I use rga all the time. it's a "simple" solution but often enough for what I actually needed.

Re: Ask HN: I have many PDFs – what is the best local way to leverage AI for search?

#43
post #35

You don't. You use a full-text indexer and normal search tools. A chatbot is only going to decrease the integrity of query results.

I found that grep actually outperformed vector search for many queries. The only thing I was missing was when I didn't know how exactly to phrase something (the exact keyword to use). Do keyword search systems have workarounds for this? My own idea was for each keyword to generate a list of neighbor keywords in semantic space. I figured with such a dataset, I'd get something approximating vector search for free. I ma…

> The only thing I was missing was when I didn't know how exactly to phrase something (the exact keyword to use).

I think that's the only things GUI (or TUI) directories have over CLI. I remember having Wikipedia locally (english texts, back in 2010) and the portals were surprisingly useful. They act like the semantic space in case you can't find an article for your exact word. So Literature > Fiction > Fantasy > Epic Fantasy will probably land you somewhere close to "The Lord of The Rings".

Re: Ask HN: I have many PDFs – what is the best local way to leverage AI for search?

#44
post #35

You don't. You use a full-text indexer and normal search tools. A chatbot is only going to decrease the integrity of query results.

I found that grep actually outperformed vector search for many queries. The only thing I was missing was when I didn't know how exactly to phrase something (the exact keyword to use). Do keyword search systems have workarounds for this? My own idea was for each keyword to generate a list of neighbor keywords in semantic space. I figured with such a dataset, I'd get something approximating vector search for free. I ma…

Most developers are going to outperform vector search. We “get” how computers do lookups so we build our queries appropriately.

Vector search is amazing for using layman concepts.

Re: Ask HN: I have many PDFs – what is the best local way to leverage AI for search?

#45
post #35

You don't. You use a full-text indexer and normal search tools. A chatbot is only going to decrease the integrity of query results.

I found that grep actually outperformed vector search for many queries. The only thing I was missing was when I didn't know how exactly to phrase something (the exact keyword to use). Do keyword search systems have workarounds for this? My own idea was for each keyword to generate a list of neighbor keywords in semantic space. I figured with such a dataset, I'd get something approximating vector search for free. I ma…

The point of vector search is to support semantic search. It makes sense that grep will outperform if you're just looking for verbatim occurrences of a string.

Re: Ask HN: I have many PDFs – what is the best local way to leverage AI for search?

#46
The primary challenge is not just about harnessing AI for search; it's about preparing complex documents of various formats, structures, designs, scans, multi-layout tables, and even poorly captured images for LLM consumption. This is a crucial issue.

There is a 20 min read on why parsing PDFs is hell: https://unstract.com/blog/pdf-hell-and-practical-rag-applica...

To parse PDFs for RAG applications, you'll need tools like LLMwhisperer[1] or unstructured.io[2].

Now back to your problem:

This solution might be an overkill for your requirement, but you can try the following:

To set things up quickly, try Unstract[3], an open-source document processing tool. You can set this up and bring your own LLM models; it also supports local models. It has a GUI to write prompts to get insights from your documents.[4]

[1] https://unstract.com/llmwhisperer/ [2] https://unstructured.io/ [3] https://github.com/Zipstack/unstract [4] https://github.com/Zipstack/unstract/blob/main/docs/assets/p...

Re: Ask HN: I have many PDFs – what is the best local way to leverage AI for search?

#47
If you want to run locally you can look into this https://github.com/PaddlePaddle/PaddleOCR

https://andrejusb.blogspot.com/2024/03/optimizing-receipt-pr...

But I suggest that you just skip that and use gpt-4o. They aren't actually going to steal your data.

Sort through it to find anything with a credit card number or anything ahead time.

Or you could look into InternVL..

Or a combination of PaddleOCR first and then use a strong LLM via API, like gpt-4o or llama3 70b via together.ai

If you truly must do it locally, then if you have two 3090s or 4090s it might work out. Otherwise it the LLMs may not be smart enough to give good results.

Leaving out the details of your hardware makes it impossible to give good advice about running locally. Other than, it's not really necessary.

Re: Ask HN: I have many PDFs – what is the best local way to leverage AI for search?

#48
post #27
post #15

RAG cli from llamaindex, allow you to do it 100% locally when used with ollama or llamacpp instead of OpenAI. https://docs.llamaindex.ai/en/stable/getting_started/starter...

Does the llamaindex PDF indexer correctly deal with multi-column PDFs? Most I've seen don't, and you get very odd results because of this.

Locally you can choose pypdf or mupdf wich are good but not perfect. If you can send your data online llamaparse is quite good.

Re: Ask HN: I have many PDFs – what is the best local way to leverage AI for search?

#49

The primary challenge is not just about harnessing AI for search; it's about preparing complex documents of various formats, structures, designs, scans, multi-layout tables, and even poorly captured images for LLM consumption. This is a crucial issue. There is a 20 min read on why parsing PDFs is hell: https://unstract.com/blog/pdf-hell-and-practical-rag-applica... To parse PDFs for RAG applications, you'll need tool…

Apache Tika could help extract the relevant bits of PDFs, couldnt it?

https://tika.apache.org/

Re: Ask HN: I have many PDFs – what is the best local way to leverage AI for search?

#50
post #47

If you want to run locally you can look into this https://github.com/PaddlePaddle/PaddleOCR https://andrejusb.blogspot.com/2024/03/optimizing-receipt-pr... But I suggest that you just skip that and use gpt-4o. They aren't actually going to steal your data. Sort through it to find anything with a credit card number or anything ahead time. Or you could look into InternVL.. Or a combination of PaddleOCR first and then u…

> But I suggest that you just skip that and use gpt-4o. They aren't actually going to steal your data.

Why do you have this confidence? Is it based on reading their TOS, and assuming they'll follow it?

Post reply on HN