Live data from Hacker News

Ask HN: What are you using to parse PDFs for RAG?

news.ycombinator.com

61–70 of 102 posts

Re: Ask HN: What are you using to parse PDFs for RAG?

#62
post #55

For use in retrieval/RAG, an emerging paradigm is to not parse the PDF at all. By using a multi-modal foundation model, you convert visual representations ("screenshots") of the pdf directly into searchable vector representations. Paper: Efficient Document Retrieval with Vision Language Models - https://arxiv.org/abs/2407.01449 Vespa.ai blog post https://blog.vespa.ai/retrieval-with-vision-language-models-... (my day…

No multi-modal model is ready for that in reality. The accuracy from other tools to extract tables and text are far superior.

Re: Ask HN: What are you using to parse PDFs for RAG?

#63
post #55

For use in retrieval/RAG, an emerging paradigm is to not parse the PDF at all. By using a multi-modal foundation model, you convert visual representations ("screenshots") of the pdf directly into searchable vector representations. Paper: Efficient Document Retrieval with Vision Language Models - https://arxiv.org/abs/2407.01449 Vespa.ai blog post https://blog.vespa.ai/retrieval-with-vision-language-models-... (my day…

I do something similar in my file-renamer app (sort.photos if you want to check it out):

1. Render first 2 pages of PDF into a JPEG offline in the Mac app.

2. Upload JPEG to ChatGPT Vision and ask what would be a good file name for this.

It works surprisingly well.

Re: Ask HN: What are you using to parse PDFs for RAG?

#64
I am surprised nobody has mentioned it yet.

If this is for anything slightly commercial related you are probably going to have the best luck using Textract/Document Intelligence/Document AI. Nothing else listed in the comments is as accurate, especially when trying to extract forms, tables and text. Multi-modal will take care of your the images. The combination of those two will get you a great representation of the PDF.

Opensource tools work and can be extremely powerful but you 1) won't have images and 2) your workflows will break if you are not building it for a specific pdf template.

Re: Ask HN: What are you using to parse PDFs for RAG?

#65
post #64

I am surprised nobody has mentioned it yet. If this is for anything slightly commercial related you are probably going to have the best luck using Textract/Document Intelligence/Document AI. Nothing else listed in the comments is as accurate, especially when trying to extract forms, tables and text. Multi-modal will take care of your the images. The combination of those two will get you a great representation of the…

Having explored this topic over the passed month this is the correct answer. And it has been mentioned in the comments by jumploops

Re: Ask HN: What are you using to parse PDFs for RAG?

#66
post #64

I am surprised nobody has mentioned it yet. If this is for anything slightly commercial related you are probably going to have the best luck using Textract/Document Intelligence/Document AI. Nothing else listed in the comments is as accurate, especially when trying to extract forms, tables and text. Multi-modal will take care of your the images. The combination of those two will get you a great representation of the…

I completely agree. Like the previous comment mentioned, I've explored this area over the past year, and in my tests, the offerings from Amazon, Google, and Microsoft were far superior to the open-source options, especially for long documents. It's unfortunate, but that's the way it is.

OCR itself isn't the issue; most open-source models handle that adequately. The problem lies in the lack of comprehensive features:

- Identification of chapters and headings

- Segmentation of headers and footers with an easy way to filter them out

- Handling of images

- Correctly processing two-column or other non-standard layouts

- Avoiding out-of-memory (OOM) errors, which, while not a flaw of the open-source software itself, is a common and frustrating issue

- Transcription of tables and forms, which exists in open-source models but isn't as effective

These ergonomic features are where the open-source solutions fall short.

Re: Ask HN: What are you using to parse PDFs for RAG?

#67

Apache Tika Server is very easy to set up - it can be configured to use tesseract for OCR.

Came here to mention Tika. I just set up a small POC with the 'full' tika docker container - default OCR bundled (with... 5 languages? English, Spanish, etc).

I parsed a PDF and when looking at the output, I noticed 'united stotes of america' was in the text. Didn't make any sense... Digging further, I saw that it had also parsed the images in the PDF, and one of them was some govt logo with bad artifacting. It did indeed read more like 'stotes' than 'states'.

Edit: That said, the OP asked about tables. I haven't tested any table stuff with tika (not something I need right now). Is the tika table support any good? Does it even exist? Seems like it might not really matter for many tika use cases (but I might be missing something obvious!)

Re: Ask HN: What are you using to parse PDFs for RAG?

#68
post #64

I am surprised nobody has mentioned it yet. If this is for anything slightly commercial related you are probably going to have the best luck using Textract/Document Intelligence/Document AI. Nothing else listed in the comments is as accurate, especially when trying to extract forms, tables and text. Multi-modal will take care of your the images. The combination of those two will get you a great representation of the…

Azure Document Intelligence with the Document Layout Model is pretty damn amazing at this.

Key thing is it labels titles, headers, sections, etc. This way you can stuff headers into the child chunks for much better RAG.

Re: Ask HN: What are you using to parse PDFs for RAG?

#69
post #58

You can start to look at pdftotext -layout and pandoc maybe. Personally I hope a day publishers start learning about the value of data and their representations so they decide to embed them like a *sv file attached to a pdf where the tabular data are immediately available, a .gp and alike file for graphs etc. Essentially the concept of embedding pdf "sources" as an attachment. In LaTeX it's easy to attach the LaTeX i…

Came here to say pandoc. OP, I've setup stacks for taking physical books to editable pdf, ebook, and asciidoc. You can do it to markdown too. Add in tesseract for ocr to catch misses and you are good! (be careful on foreign language sections)

Re: Ask HN: What are you using to parse PDFs for RAG?

#70

My apps are native Mac apps [0] [1] so naturally I use the native SDK for that. Apple provides PDFKit framework to work with PDFs and it works really well. For scanned documents, I use the Vision framework to OCR the content. Some additional content cleaning is still required but overall I don’t need any other third-party libraries. [0]: https://boltai.com [1]: https://pdfpals.com

Let's apply your app to your home page, easy as 1, 2, 3!

1. Reader mode, copy all text.

2. Prompt ChatGPT 4o:

Which headline or sentence structures in the following web page copy suggest a non-native English speaker, and how should each incorrect phrase be fixed for most native-sounding American English? Omit testimonials written by others, just focus on the marketing copy and faq, include reasons for revision.

3. Response:

Here are refined sentences focused on the marketing copy and FAQs:

Original: "From blog outlines, to highly technical content."

- Punctuation: "From blog outlines to highly technical content."

Original: "Natively intergrated with your favorite apps."

- Spelling: "Natively integrated with your favorite apps."

Original: "All costs are estimated, please refer to your OpenAI dashboard for the most accurate cost of your API key."

- Structure: "All costs are estimates. Please refer to your OpenAI dashboard for the most accurate pricing for your API key."

Original: "How does license work?"

- Non-native indicator: "How does the license work?"

Original: "The ChatGPT Plus subscription is separate and managed by OpenAI, it does not provide an API key that you can use with BoltAI."

- Punctuation: "The ChatGPT Plus subscription is separate and managed by OpenAI; it does not provide an API key for BoltAI."

Original: "Do you offer team plan license?"

- Non-native indicator: "Do you offer a team plan license?"

Original: "Absolutely. If for any reason you're not satisfied with your purchase, you can request a refund within 30 days of purchase."

- Fluency: "Absolutely. If you're not satisfied with your purchase for any reason, you can request a refund within 30 days."

These edits aim to make the text sound more natural and fluent in American English, improving clarity and coherence.

Post reply on HN