Formulas are not parsed correctly #44

Open
opened 2026-02-16 00:16:42 -05:00 by yindo · 3 comments
Owner

Originally created by @Starforged on GitHub (Mar 14, 2024).

When formulas are parsed some characters like the square root √ are deleted.
Character that should be lowered ₐ as well as raised ² characters are not correctly positioned.

The input:
X4gv1P60KMGXes1n

This is the raw text from the PDF (copy and paste):
[H3O +] Ka
2

  •  Ka
    2
    4
    = – + Ka ca

The output:
[H3O+] = – K2a + K4a2 + Ka ca

The expected output:
[H₃O⁺] = -Kₐ/2 + √{Kₐ²/4+Kₐcₐ}

The expected output was made manually by me and contains only unicode characters and no markdown or formatting information.
For example: √ (U+221A) and ₐ (U+0061)

Originally created by @Starforged on GitHub (Mar 14, 2024). When formulas are parsed some characters like the square root √ are deleted. Character that should be lowered ₐ as well as raised ² characters are not correctly positioned. The input: ![X4gv1P60KMGXes1n](https://github.com/run-llama/llama_parse/assets/11255685/64dbc055-24dc-4026-8887-27b7455cab44) This is the raw text from the PDF (copy and paste): [H3O +] Ka 2 +  Ka 2 4 = – + Ka ca The output: [H3O+] = – K2a + K4a2 + Ka ca The expected output: [H₃O⁺] = -Kₐ/2 + √{Kₐ²/4+Kₐcₐ} The expected output was made manually by me and contains only unicode characters and no markdown or formatting information. For example: √ (U+221A) and ₐ (U+0061)
yindo added the bug label 2026-02-16 00:16:42 -05:00
Author
Owner

@Starforged commented on GitHub (Mar 14, 2024):

chemiebuch_165.pdf
Here is the relevant PDF page, for reproducing the error.

@Starforged commented on GitHub (Mar 14, 2024): [chemiebuch_165.pdf](https://github.com/run-llama/llama_parse/files/14605164/chemiebuch_165.pdf) Here is the relevant PDF page, for reproducing the error.
Author
Owner

@hexapode commented on GitHub (Mar 15, 2024):

Thanks for sharing the document.

It seems that we still have font issue on Math characters (���) will take a look at it.

@hexapode commented on GitHub (Mar 15, 2024): Thanks for sharing the document. It seems that we still have font issue on Math characters (���) will take a look at it.
Author
Owner

@Starforged commented on GitHub (Mar 15, 2024):

@hexapode Hello, thanks for taking a look.
I did some more research to educate myself on how this problem should be solved correctly and it is apparently usually solved with OCR.

The expected output that I previously made manually is wrong in the sense that it uses nonstandard "math characters" and is not the generally agreed upon method of representing formulas.

I was able to find a project using pix2tex and PyTorch by @lukas-blecher that does the conversion correctly.
https://github.com/lukas-blecher/LaTeX-OCR (Available under MIT license)

Another exiting developement is that 5 days ago @chaodreaming puplished a Latex formula recognition model trained on 110 million datasets on their repo!
https://github.com/chaodreaming/Simple-LaTeX-OCR (Available under Apache-2.0 license)

I would recommend implementing this OCR based conversion to LaTeX format for formulas in LlamaParse.

An example conversion from LaTeX-OCR:

The input:
grafik

The output:
S=\int_{x}\left{\frac{1}{2}\sum_{a}\partial^{\mu}\chi_{a}\partial_{\mu}\chi _{a}+V(\rho)\right},

@Starforged commented on GitHub (Mar 15, 2024): @hexapode Hello, thanks for taking a look. I did some more research to educate myself on how this problem should be solved correctly and it is apparently usually solved with OCR. The expected output that I previously made manually is wrong in the sense that it uses nonstandard "math characters" and is not the generally agreed upon method of representing formulas. I was able to find a project using pix2tex and PyTorch by @lukas-blecher that does the conversion correctly. https://github.com/lukas-blecher/LaTeX-OCR (Available under MIT license) Another exiting developement is that 5 days ago @chaodreaming puplished a Latex formula recognition model trained on 110 million datasets on their repo! https://github.com/chaodreaming/Simple-LaTeX-OCR (Available under Apache-2.0 license) I would recommend implementing this OCR based conversion to LaTeX format for formulas in LlamaParse. An example conversion from LaTeX-OCR: The input: ![grafik](https://github.com/run-llama/llama_parse/assets/11255685/76843c61-3c0c-4e3a-a9df-af0114daeb61) The output: S=\int_{x}\left\{\frac{1}{2}\sum_{a}\partial^{\mu}\chi_{a}\partial_{\mu}\chi _{a}+V(\rho)\right\},
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: run-llama/llama_cloud_services#44