Back to directory
Documents · 2026-09-17

Turning math-heavy PDFs into clean Markdown and Word with Qwen vision

Daily OCR of math- and table-heavy PDFs into LaTeX-correct Markdown and Word, using Qwen vision models on llama.cpp instead of a smaller model that misreads numbers.

Most of this person's local work is OCR: turning PDFs full of equations and tables into files they can edit.

Setup

On a 9950X3D workstation with 96GB DDR5-6600 and an RTX 5070 Ti, they run Qwen vision models through llama.cpp instead of a small model like Gemma 4 12B, because Gemma regularly misreads small numbers inside equations while the Qwen vision models are more accurate on math and produce LaTeX that survives a real document.

They keep two llama-server configurations:

  • Mainline build: Qwen 3.8 27B at 20K context with an 8-bit KV cache, ~1,000-1,100 prefill and 50-52 generation tok/s
  • Unsloth fork: a rebuilt Qwen 3.8 Flash Next with MTP speculative decoding at 50K context, 100-120 prefill and 29-32 generation tok/s

The pipeline matters more than the speed

A VBS script calls a Python script that drives LibreOffice and a prompt tuned so LaTeX resolves correctly in both Markdown and Word, letting most document types (including image-only PDFs) come out as editable Markdown and .docx with formulas intact. Easier source material uses a faster hybrid OCR path, with the vision model kept as a safety net.

VERIFIABLE SOURCE

Reported anonymously by an r/LocalLLM contributor · 1 upvotes at capture

View source
SETUP HISTORY

Snapshots over time

2 versions
CURRENT2026-09-17Turning math-heavy PDFs into clean Markdown and Word with Qwen vision

Daily OCR of math- and table-heavy PDFs into LaTeX-correct Markdown and Word, using Qwen vision models on llama.cpp instead of a smaller model that misreads numbers.

Documents1 machineQwen 3.8 27B, Qwen 3.8 Flash Nextllama.cpp
ChangedDescription
Compare with revision 1
DescriptionPreviousMost of this person's local work is OCR: turning PDFs full of equations and tables into files they can edit. On a 9950X3D workstation with 96GB of DDR5-6600 and an RTX 5070 Ti, they run Qwen vision models through llama.cpp instead of a small model like Gemma 4 12B, because Gemma regularly misreads small numbers inside equations while the Qwen vision models are more accurate on math and produce LaTeX that survives a real document. They keep two llama-server configurations: a mainline build running Qwen 3.8 27B at a 20K context with an 8-bit KV cache, reporting about 1,000-1,100 prefill and 50-52 generation tokens per second, and an Unsloth fork running a rebuilt Qwen 3.8 Flash Next setup with MTP speculative decoding at a 50K context, reporting 100-120 prefill and 29-32 generation tokens per second. The speed is secondary to the pipeline around it: a VBS script calls a Python script that drives LibreOffice and a prompt tuned so LaTeX resolves correctly in both Markdown and Word, letting most document types, including image-only PDFs, come out as editable Markdown and .docx with formulas intact. For easier source material they use a faster hybrid OCR path and keep the vision model as a safety net.This snapshotMost of this person's local work is **OCR**: turning PDFs full of equations and tables into files they can edit. ## Setup On a 9950X3D workstation with 96GB DDR5-6600 and an **RTX 5070 Ti**, they run Qwen vision models through **llama.cpp** instead of a small model like Gemma 4 12B, because Gemma regularly misreads small numbers inside equations while the Qwen vision models are more accurate on math and produce LaTeX that survives a real document. They keep two `llama-server` configurations: - **Mainline build**: Qwen 3.8 27B at 20K context with an 8-bit KV cache, ~1,000-1,100 prefill and 50-52 generation tok/s - **Unsloth fork**: a rebuilt Qwen 3.8 Flash Next with MTP speculative decoding at 50K context, 100-120 prefill and 29-32 generation tok/s ## The pipeline matters more than the speed A VBS script calls a Python script that drives LibreOffice and a prompt tuned so LaTeX resolves correctly in both Markdown and Word, letting most document types (including image-only PDFs) come out as editable Markdown and `.docx` with formulas intact. Easier source material uses a faster hybrid OCR path, with the vision model kept as a safety net.

This is the currently published snapshot.

REVISION 12026-09-17Turning math-heavy PDFs into clean Markdown and Word with Qwen vision

Daily OCR of math- and table-heavy PDFs into LaTeX-correct Markdown and Word, using Qwen vision models on llama.cpp instead of a smaller model that misreads numbers.

Documents1 machineQwen 3.8 27B, Qwen 3.8 Flash Nextllama.cpp

Archived published snapshot — kept for context and comparison.

Discussion

0 comments

No comments yet. Questions and corrections on this setup are welcome.

Leave a comment

Comments are reviewed before they appear. Keep it civil, cite your sources, and stay on topic.