1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] How to preprocess PDFs with math formulas (text + images) for use in a RAG pipeline...

Discussão em 'Python' iniciado por Stack, Setembro 17, 2025.

  1. Stack

    Stack Membro Participativo

    I’m building a Retrieval-Augmented Generation (RAG) project for school notes (math-heavy, e.g., “Mathematics for Economics”).

    My PDFs contain a mix of:

    Normal text (which I can extract using PyPDFLoader / fitz).

    Math formulas, some embedded as text, but many appear as images in slides (integrals, fractions, etc.).

    I tried using latex-ocr (Pix2Tex) to convert formula images into LaTeX. It works sometimes, but often outputs garbled results. This makes it hard to embed and query formulars reliably

    Extract both text and math formulas from PDFs.

    Store formulas in a way that doesn’t get broken by chunking (e.g., don’t split inside a formula).

    Ideally save both LaTeX and the original formula image so that if OCR fails, I can still present the image.

    Free/open-source solutions preferred (Mathpix API works great but is paid).

    Continue reading...

Compartilhe esta Página