← Latest papers
💻 computer science

PIX2DB: Reconstructing Executable Relational Databases from Document Images with a 2B Vision-Language Model

The paper introduces PIX2DB, a 2B vision-language model combined with a deterministic repair layer that reconstructs queryable SQLite databases directly from document images, achieving state-of-the-art performance on synthetic benchmarks and strong results on real-world receipts and tables by leveraging a hybrid training dataset of rendered and annotated sources.

Original authors: Musa Peker

Published 2026-10-23
📖 7 min read🧠 Deep dive

Original authors: Musa Peker

Original paper licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). ✨ This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

For decades, the world has been drowning in paper and pixels. Receipts, invoices, scanned reports, and screenshots of spreadsheets sit in our digital archives as flat pictures. To a human eye, these images are full of meaning: rows of numbers, headers that group data, and cells that stretch across columns to show a total. But to a computer, an image is just a collection of colored dots. It sees the shape of a table but not the logic inside it. It cannot tell that a merged cell belongs to every row beneath it, or that a dollar sign is a symbol for a number, not a letter. This gap between how we see data and how machines read it has long been a bottleneck. We can take a photo of a document, but turning that photo into a working database—one where a program can actually add up the costs or sort the dates—has usually required a human to manually retype the information or write complex scripts to guess the structure.

Researchers have tried to solve this by teaching computers to recognize the layout of a page, turning images into text or code that looks like a table. However, these methods often produce a faithful copy of the visual design rather than the underlying data. A computer might correctly identify that a cell spans two rows, but it fails to understand that the value inside that cell applies to both rows in the database. It treats the image as a picture to be described, not as a source of truth to be reconstructed. The goal of this new work is to bridge that final gap: to take a single image of a document and produce a fully functional database that a standard computer program can immediately use, query, and analyze, without any human intervention.

The researcher behind this project, Musa Peker, approached the problem by asking a computer to do something it rarely does: to make the hard decisions about data structure itself. Instead of just transcribing what it sees, the system is trained to decide how rows and columns relate, how to handle merged cells, and how to connect different parts of a document into a single, logical system. They built a system called PIX2DB, which stands for "Picture to Database." The core of this system is a vision-language model, a type of artificial intelligence that can look at an image and understand the text and structure within it. The researcher trained a relatively small version of this model, containing two billion parameters, to look at images of tables and receipts and output a specific set of instructions known as a SQL dump. This is a format that tells a database engine exactly how to build the tables, what kind of data goes in each column, and how the tables link to one another.

To teach the model this skill, the researcher faced a significant hurdle: they needed perfect examples of what the output should look like. They could not rely on existing datasets because those usually contain only the visual layout, not the correct database structure. So, they created their own training ground. They took real-world databases, such as those used in online stores or property listings, and used a computer program to render them as images. They created thousands of these images, varying the difficulty by adding different fonts, colors, merged cells, and even simulating the imperfections of a photograph, such as slight blurs or uneven lighting. They also converted existing public datasets of tables and receipts into the same strict format. Every single example they generated was checked by running the resulting code to ensure it actually worked. This process gave them a massive library of "gold standard" pairs: an image on one side and the perfect, executable database on the other.

The results of this training were surprising. The small, two-billion-parameter model, once trained on these thirty-six thousand examples, outperformed much larger models that were four times its size. When tested on images of tables it had never seen before, the small model successfully reconstructed the database structure with high accuracy. It correctly identified how to split merged cells into individual rows, how to turn a two-level header into a single column name, and how to link a list of items to a main invoice header using a foreign key, which is a rule that connects two tables together. In tests involving synthetic images, the model achieved an exact match on the table structure in eighty-six percent of cases. More impressively, it recovered the connections between different tables almost perfectly, getting the foreign keys right ninety-nine percent of the time.

The researcher also tested the system on real-world images, such as photos of receipts and scanned financial documents. Here, the model continued to perform strongly, correctly identifying the data in ninety-six percent of the cells for financial tables and recovering ninety-three percent of the data from receipt photos. The system proved particularly adept at handling the messy reality of documents, such as repeating a value from a merged cell into every row it covered, a task that confused larger models and other existing tools. However, the study also revealed a clear limit. When the team tested the model on a dataset of tables that was completely different from anything it had seen during training, its performance dropped. The model struggled to read the text in these new, unfamiliar photographs, often misreading numbers or letters. This suggested that while the model had mastered the logic of how to structure data, it still relied on the training data to learn how to read the text itself.

A key finding of the research was the importance of the training data itself. The researcher ran an experiment where they trained a version of the model using only the synthetic images they had created, without any real-world photos. This version performed perfectly on the synthetic tests but failed miserably when shown real pictures of documents. It could not handle the messy text found in actual photographs. This proved that the synthetic data taught the model the rules of the game, but the real data taught it how to read the players. The final system combined both, using the synthetic data to learn the structure and the real data to learn the text.

The researcher also added a safety net to their system, a deterministic repair layer that acts as a final check before the database is created. If the model makes a small mistake, such as forgetting to put a quote around a word that contains a comma, this layer fixes the error automatically. This step ensured that the output was not just theoretically correct but actually executable by a standard database program. Without this repair step, many of the outputs would have failed to run. With it, the system produced working databases in nearly every case, turning a visual image into a tool that can be queried, sorted, and analyzed immediately.

The study concludes that the path from a picture to a working database is not about building a bigger, more powerful brain, but about teaching a smaller, focused model the specific rules of data structure. The researcher found that a compact model, trained on exact examples and supported by a simple repair mechanism, could outperform larger, more general models that were simply asked to guess the structure. While the system still struggles with reading text in difficult, unfamiliar photographs, it has successfully solved the problem of turning the visual layout of a document into a logical, relational database. This means that for the first time, a computer can look at a photo of a receipt or a chart and instantly produce a database that a human can use to ask questions, find totals, or track trends, effectively unlocking the data trapped inside the image.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →