Tools,

Qianfan-OCR on a Mac, tested on 10 scanned pages

1,951 of 1,955

words read on 10 pages, in 30 s

Get the script

The 4-bit copy read nearly as well as bf16

Qianfan-OCR is Baidu's 4B document model. We ran two community MLX copies of it.

Words found, of 1,955, and time for 10 pages
Run Words Time
Qianfan-OCR, bf16 MLX copy 1,952 60 s
Qianfan-OCR, 4-bit MLX copy 1,951 30 s
Our Actor's code, on our Mac 1,880 54 s
Tesseract 5.5.4 1,878 31 s

Qianfan-OCR times leave out the model load, about 2 s.

Size on disk and peak memory
Copy Disk Peak
4-bit 3.1 GB 4.2 GB
bf16 9.5 GB 10.5 GB

Baidu's own upload will not load

mlx-vlm 0.8.1 reads the model type from config.json, and it does not know Baidu's:

ValueError: Model type qianfan_ocr not supported.

The MLX copies relabel it as internvl_chat, a type mlx-vlm knows. Both come from personal accounts, not from Baidu.

Leave out --trust-remote-code

The 4-bit card's command adds --trust-remote-code. That lets transformers run Python files from the model repo. mlx-vlm does not need them.

mlx/bin/python -m mlx_vlm.generate --model jason1966/Qianfan-OCR-MLX-4bit \
  --max-tokens 2000 --prompt "Parse this document to Markdown." \
  --image page-01.jpg

Without the flag, the card's command read 200 of 202 words on our page 1. In Python, load() with trust_remote_code=False loaded no code from the repo.

Thinking mode doubled the time

Qianfan-OCR can map the page layout before it reads (Baidu calls this Layout-as-Thought). In mlx-vlm, put <think> at the end of the prompt. On page 1, the enable_thinking=True switch from Baidu's card changed nothing.

4-bit copy, mlx-vlm's chat text, 10 pages
Thinking Words Time
Off 1,947 30 s
On 1,950 61 s

Baidu's card says to leave it off for single-column text. On our book pages, it doubled the time for 3 more words.

It tidied the author's dialect

Install once, with an Apple Silicon Python

brew install poppler python@3.12
python3.12 -m venv mlx
mlx/bin/pip install mlx-vlm==0.8.1

If pip finds no mlx, the Mac needs macOS 14 or newer and an arm64 Python. This must print arm64:

python3.12 -c "import platform; print(platform.machine())"

One script: scanned PDF in, Markdown out

Save this as qianfanocr.py:

import sys

from mlx_vlm import generate, load

model_id, *pages = sys.argv[1:]
model, processor = load(model_id, trust_remote_code=False)
# The model's own chat text (template qianfanvl). mlx-vlm puts the page at <image>.
chat = "<|im_start|>user\n<image>\nParse this document to Markdown.<|im_end|>\n<|im_start|>assistant\n"
for page in pages:
    r = generate(model, processor, chat, [page], max_tokens=4096, temperature=0.0)
    print(r.text, flush=True)

Then run it in the folder with scan.pdf:

pdftoppm -r 300 -jpeg -jpegopt quality=95 scan.pdf page
mlx/bin/python qianfanocr.py jason1966/Qianfan-OCR-MLX-4bit page-*.jpg > book.md

On our scan it found 1,951 words in 43 s, with page render and model load. The first run also downloads 3.1 GB.

Why the script writes its own chat text

mlx-vlm has a built-in chat text for internvl_chat models: "User:" and "Assistant:" lines. The model repo uses another one. With the built-in text, the 4-bit copy found 1,947 words, 4 fewer.

Same 10 pages as our MLX test

The 10 pages are proofread Wikisource scans, 1,955 words in all, the same pages as our MLX OCR test. The score is true words found in order.

How we ran it
  • mlx-vlm 0.8.1, MLX 0.32.5, Python 3.12 on macOS 26.6.
  • 4-bit: jason1966/Qianfan-OCR-MLX-4bit. bf16: mat50013/Qianfan-OCR-MLX-BF16. Each at a fixed commit.
  • Each page as a 1920 px JPEG, prompt "Parse this document to Markdown.", temperature 0, up to 4,096 tokens.
  • Case and punctuation count. Curly and straight quotes count the same.
  • One Apple Silicon Mac, one model at a time, at low priority, so times are rough.
  • Tesseract: --psm 3, 2 threads. Our Actor: its code at build 0.1.144, its default inputs.
  • Baidu's upload: its config.json through mlx-vlm 0.8.1's loader, without the weights.
  • Not tested: the GGUF files in llama.cpp, Baidu's weights in transformers, LM Studio, tables, handwriting and other languages.
  • Scripts and results stay in our private repo, in research/bench/qianfan-ocr-2026-11-26/.

Our Actor: no Mac needed

Our Apify Actor, PDF to Markdown OCR, reads PDF, PNG, JPEG, WEBP, TIFF, HEIC, AVIF, GIF, BMP and JP2 in the cloud, with nothing to install.

Questions people ask

Does Qianfan-OCR run on a Mac?

Yes, through an MLX copy in mlx-vlm on Apple Silicon. Baidu's own upload does not load in mlx-vlm 0.8.1. The 4-bit copy peaked at 4.2 GB of memory on our pages.

Should I use the 4-bit or the bf16 copy?

On our 10 pages, the 4-bit copy found 1 word fewer than bf16, in half the time, from a third of the disk space. Start with 4-bit.

How do I turn on thinking mode in mlx-vlm?

Put <think> at the end of the prompt. The enable_thinking=True switch from Baidu's card did nothing in mlx-vlm 0.8.1. On plain book pages, thinking doubled the time.

Is Qianfan-OCR free for business use?

Baidu publishes it under Apache-2.0, which allows business use. Both MLX copies carry the same license. mlx-vlm and MLX are MIT.