Skip to content
← Blog

What Neural Network LLMs Like ChatGPT Actually Do With Images, and Why It's So Different From Traditional OCR

By OpenOCR Team

I assumed ChatGPT had an OCR engine hidden inside it. Find the text, turn the letters into characters, pass them along. That assumption was wrong.

There is no OCR model inside a chatbot

OpenAI doesn't publish what ChatGPT is built with, so I can't show you. But every model that does publish its design works one way, and ChatGPT shows the same signs. A vision encoder, a small network, cuts a picture into squares and turns each square into a vector. The language model reads those vectors with the same weights it uses for text. Nothing finds text first, and nothing recognizes characters as a separate step. It reads the whole page the way it reads a sentence.

A diagram where an image passes through a vision encoder and an MLP connector to become orange tokens, while a question passes through a tokenizer to become yellow tokens, and both rows feed one language model

LLaVA-1.5. The picture arrives as the orange tokens and the question as the yellow ones, and the language model reads both. Figure 1 of Liu et al., 2023, cropped. CC BY 4.0.

A language model never sees raw words anyway. Text goes through a tokenizer and comes out as vectors. The vision encoder hands over vectors of the same length, and the training objective is unchanged: predict the next token.

The evidence that ChatGPT works the same way is indirect, but there's a lot of it.

Mistral's Pixtral is the clearest. It's a chat model from a major lab, and the design is published. The Pixtral 12B paper (Agrawal et al., 2024) sums it up in one sentence: a vision encoder that tokenizes images, and a decoder that predicts the next text token given a sequence of text and images. The decoder is Mistral's ordinary 12 billion parameter language model, Nemo. There's no text finder anywhere in it.

OpenAI's own documentation points the same way. It describes cutting an image into patches, 32 pixels on a side on its current models, and billing each one as an ordinary input token. That's why a blank page costs the same as a full one. Its list of known limitations includes rotated text, which is the kind of problem a find-and-straighten stage would have solved.

Then there's behavior. We sent a blank white image through the OpenAI models on OpenOCR and some of them read it (more on that later). A pipeline with a text detector in front returns nothing for that page, which is what every classical OCR engine did.

After that, the pattern is hard to miss. The open models that publish their designs all build it this way. LLaVA, Qwen, GLM and Pixtral put the picture tokens in the row next to the text tokens. BLIP-2 and Flamingo attach the picture to a frozen language model in slightly different ways. Anthropic and Google don't publish their architectures either, but Anthropic charges by the 28-pixel block and Google by the tile.

Catastrophic forgetting

Teaching a network a new skill risks wiping out what it already knew. Everything it knows lives in the same connection strengths, and there is no separate place to put the new learning. McCloskey and Cohen documented this in 1989 while modeling memory with small networks, and it's called catastrophic forgetting. It's like sending your truck in for a brake job and getting it back with the radio wired to the horn.

The cause is overlap. New learning reuses the connections that stored the old learning. And with pictures, overlap is the goal. The picture of a dog has to land near the word "dog" inside the model, or the model can't answer a question about the picture.

The damage is real. A 2024 paper on text-only forgetting found that models given vision get worse at text tasks they used to handle. When Meta trained Chameleon on images and text together, runs became unstable above 8 billion parameters until they changed the architecture. And Mistral went out of its way in the Pixtral paper to say the model does not compromise on natural language performance. Nobody writes that sentence unless forgetting is a real risk.

How the open models are trained

The recipe is boring on purpose. Take a finished language model and a finished vision encoder, and rebuild neither.

In stage one of LLaVA, both are frozen. A frozen network can't forget anything, because its weights never change. It also can't learn anything, so the only thing trained is a small connector between the two. LLaVA's was a single matrix, trained on 595,000 captioned images. The connector learns to place each picture where the frozen language model can already work with it.

In stage two the language model is unfrozen and trained on 158,000 conversations that include pictures, while the vision encoder stays frozen.

Two panels: a frozen image encoder feeds a Q-Former in stage one; the Q-Former feeds a frozen large language model in stage two

BLIP-2 never unfreezes its language model. The snowflakes mark the frozen parts. Figure 1 of Li et al., 2023. CC BY 4.0.

Other models never take that second step. BLIP-2 keeps its language model frozen the whole time. Flamingo does too, and puts its vision layers behind gates that start at zero, which is introducing vision to the network on mute. When the researchers removed the zero start, training became unstable.

LLaVA-1.5 adds one detail that I think is the best part of the recipe. They mixed text-only conversations into the training data, so the model kept practicing language while it learned pictures. It also learned to answer in more languages, because the text-only data was multilingual. The whole recipe was 1.2 million examples and about a day on one machine with eight GPUs.

Google took the other route with Gemini and trained on text and images from the start. Then there's no old skill to forget, but the mixture has to be right, and their report calls it an open question whether training that way gives strong ability in every domain.

The language model does the seeing

The vision encoder only translates, so the understanding has to happen somewhere else.

A study looked inside LLaVA. As the vectors for an object move up through the layers, they shift toward the model's text embedding for that object's name. The picture of a dog gets pulled toward "dog". And when the researchers removed the visual tokens carrying that information, the model's accuracy at naming the object dropped by more than 70%.

A diagram of a study: an image of a dog beside a Christmas tree is cut into patches, encoded and added to a question as green visual tokens, and the model's layers move them toward word embeddings such as "dog"

The method from that study. The picture becomes the green tokens, sitting in the row next to the question. Figure 1 of Neo et al., 2024. CC BY 4.0.

There's a simpler sign from the outside. The LLaVA team kept the same vision encoder and swapped the 7 billion parameter language model for the 13 billion one. Their score on visual conversation went from 31.1 to 36.1, the largest jump in their table. The vision encoder was identical in both runs.

What I took from it

I'm not sure how far to take this.

A network that's general enough can take on a new kind of input without a new module, as long as the input is translated into a form it already handles. I think that says more about these models than about the universe, which I did wonder for a bit. The part that comes from the world is only that pictures and text describe the same reality, so one map can hold both.

What it means for OCR

At OpenOCR we route documents to more than a hundred OCR models, and this explains both ways these models go wrong on a page.

The first is small print. In our benchmarks every model gets the same page image, with its long side at 1,024 pixels. A letter size page becomes about a thousand squares, and one square covers about eight characters of body text. Fine print can disappear before the language model ever sees it.

A US Letter page at 1,024 pixels tall covered in a 14-pixel grid, beside enlarged views of its body text and a 6-point footnote with 28-pixel squares drawn over the letters

Our benchmark page size, cut into the squares a vision encoder reads. On the right is what one square has to carry in normal text and in a footnote. We made this figure ourselves. The page text is filler.

We tested this with an open model whose authors recommend larger images. It scored 78.3 at our standard size, 84.0 when we enlarged the same image with plain interpolation, and 84.7 with a genuinely sharper render. Almost all of the gain came from the size. The model didn't want sharper letters. It wanted wider parking spaces for its tokens.

The second is a blank page, and we found it by accident. While testing a fix for Gemini Flash-Lite returning empty text on real documents, we sent it a blank white image as a control. It came back with "REDUCE / REUSE / RECYCLE". On another try it transcribed a passage titled "THE WONDER OF IT ALL BY DR. BENJAMIN E. MAYS", with a made-up foreword by Martin Luther King Jr.

That happens because a traditional OCR engine looks for text regions and returns nothing when there are none, while a language model produces the most likely next token. So we sent the blank page to 184 engines. Many of them read it. Every classical engine we tested (AWS Textract, Azure Document Intelligence, Google Document AI, IBM Docling, Tesseract) returned nothing, which is a rare case of a machine having the dignity to admit a page is empty.

None of these models is the right tool for every document, so at OpenOCR we don't suggest one. We suggest looking at what's in the document first.

A lot of PDFs already contain their real text. Anything exported from Word, and most documents that come back from an e-signature service like DocuSign, is a text file with a page layout attached. The signature is a picture, but the rest is text you can select with the mouse. For those, image understanding isn't needed at all. You read the text out and skip the pixels.

That case is more common than you'd think. Engineers at Citigroup, Ernst & Young and NVIDIA found that about 92% of their 10,507 pages could take that route, and only 853 needed full-page OCR (our write-up). And when a small vision model was given the PDF's own text layer next to the page images, its accuracy on document questions went from 35.0% to 69.1% (our write-up).

A scan or a photo has no text layer, so something has to look at the pixels. For really challenging documents, the best option is an LLM that's been trained on OCR, like Mistral's state-of-the-art model. Models trained only to be OCR specialists come second.

And when you read a PDF, never throw away text that's readable as text in favor of image recognition.

Put those together, and an ensemble is always the best strategy. What goes into it can get complicated, because it depends on your priorities. Speed or raw performance. If you really want to read diagrams, or if you care about handwriting, there are different specialists for different situations.

Edited by Ben Hain.