# Document Data Isn't Data Yet: How Growth Companies Build an OCR and Chunking Pipeline for AI Agents

> Document data preprocessing decides whether your AI agent works reliably. Here's how growth companies build an OCR and chunking pipeline for contracts.

- Published: 2026-09-19
- Author: Master Mind
- Canonical: https://aimaster.fi/en/artikkelit/dokumenttidata-ei-ole-viela-tietoa-nain-kasvuyritys-rakentaa-ocr-ja-pilkkomisput

Only 1% of Finnish companies use their data to build new business (Sitra). The usual reason isn't a lack of data — it's the format. Contracts, quotes, invoices, and manuals sit in PDFs, scanned images, and Word files, not database tables. When you build an AI agent on top of these documents, the first obstacle isn't the model. It's document data preprocessing: turning a hundred pages of contract text into something the agent can read reliably.

In a growth company's daily reality, data doesn't sit neatly in fields. It's buried in attachments, a folder called "scanned_2019," and a tender response someone printed and scanned again years ago. Feed this straight into a retrieval-augmented generation system — a RAG system, where the agent retrieves the right text passage from documents before answering — and it typically fails in two ways: it can't find the right section, or it mixes up rows and columns in a table. The result isn't a wrong answer. It's a confidently wrong answer.

## What does document data preprocessing mean for an AI agent?

Document data preprocessing is the process of turning PDFs, scanned images, and office files into a structured format an agent can use reliably. It has four steps: text recognition, structure detection, chunking into usable pieces, and attaching metadata. Skip this step, and the agent sees only a string of characters — not the information inside it.

## Why isn't OCR enough on its own?

OCR (optical character recognition) turns a scanned page's image into characters, but it doesn't understand the page's structure. It doesn't know which line is a heading, which cell belongs to a table, or which line is a signature. A growth company that feeds raw OCR output to an agent gets data without order — the agent has to guess which number belongs to which column. Layout detection is OCR's necessary partner, not an optional extra.

## How is a document split into pieces an agent can understand?

Chunking means splitting a document into units the agent retrieves and reads separately. Fixed-length chunking can cut a sentence or a table in half, and the agent loses context. Semantic chunking follows the document's own structure — a paragraph, a heading, a table — and keeps a complete idea in one piece. As an agent's knowledge base grows, a [knowledge graph](https://aimaster.fi/en/artikkelit/tietograafit-tekoalyagentin-muistina-kun-vektorihaku-ei-riita) complements chunked text by connecting relationships between documents — for example, that two contracts refer to the same customer.

## How do tables, charts, and signatures stay part of the information?

A table isn't text — it's a relationship between rows and columns. Flatten it into plain text, and the agent reads a price and a product name as unrelated fragments. A working pipeline extracts tables into their own structure (HTML or JSON, for example) before chunking, so rows and columns stay linked. Images and signatures get tagged as metadata, so the agent knows visual content exists on the page even if it doesn't read it word for word.

## How does Master Layer turn this into part of your company's data foundation?

[Master Layer](https://aimaster.fi/tuotteet/master-layer) is the data foundation layer that connects a company's existing systems (CRM, ERP, documents) securely for AI use. The document pipeline is one of its components: it pulls documents from the source system, runs them through OCR and structure detection, chunks the content semantically, and stores the result for the agent to retrieve. A growth company doesn't need a separate document-management project — the pipeline is built as part of a Master Layer sprint on top of the systems already in place.

| Step | What happens |
| --- | --- |
| 1. Text recognition (OCR) | A scanned page's image is converted into machine-readable characters |
| 2. Structure detection | Headings, tables, and paragraphs are separated from each other |
| 3. Chunking | Content is split into semantic pieces the agent can retrieve |
| 4. Metadata attachment | Each piece gets a source, a date, and a document type |
| 5. Storage for agent use | Pieces are stored in a search index as part of Master Layer |

## What does OCR mean in the context of an AI agent?

OCR (optical character recognition) converts the text in a scanned page or image into machine-readable characters. It's the first step in document data preprocessing, but it isn't enough on its own: the agent also needs structure detection and chunking to understand which text belongs together.

## Can an AI agent read a scanned contract directly?

Not directly. A scanned contract is an image first, not text. It needs to go through OCR, have its structure detected, and be split into appropriate pieces before an agent can retrieve information from it reliably. Skip this step, and the agent either fails to find an answer or gives the wrong one.

## Why does a PDF need to be chunked before an agent can use it?

A single PDF can run to hundreds of pages. An agent doesn't read the whole document every time — it retrieves only the relevant part. Chunking splits the document into retrievable pieces, so the agent finds the right section quickly without losing context mid-sentence or mid-table.

## What's the difference between chunking and a knowledge graph?

Chunking splits a single document into retrievable pieces. A knowledge graph connects relationships between different documents, such as two contracts referring to the same customer. In a large document base, you need both: chunking gives you precision, a knowledge graph gives you connections.

## How long does building a document pipeline take a growth company?

Cost and timeline depend on the volume and variety of documents. The sprint model makes progress predictable: development moves in 3-day cycles, and the first sprint targets one document type, such as contracts or invoices, before expanding to others.

Document data preprocessing isn't a technical detail — it decides whether you can trust the agent's answers. [Book a free Master Mind analysis](https://aimaster.fi/analyysi) to find out where your company's documents hold the most value for AI.

## Frequently asked questions

### What does OCR mean in the context of an AI agent?

OCR (optical character recognition) converts the text in a scanned page or image into machine-readable characters. It's the first step in document data preprocessing, but it isn't enough on its own: the agent also needs structure detection and chunking.

### Can an AI agent read a scanned contract directly?

Not directly. A scanned contract is an image first, not text. It needs OCR, structure detection, and chunking before an agent can retrieve information from it reliably.

### Why does a PDF need to be chunked before an agent can use it?

A single PDF can run to hundreds of pages. An agent retrieves only the relevant part rather than reading the whole file each time. Chunking splits the document into retrievable pieces so the agent finds the right section without losing context.

### What's the difference between chunking and a knowledge graph?

Chunking splits a single document into retrievable pieces. A knowledge graph connects relationships between different documents, such as two contracts referring to the same customer. Large document bases need both.

### How long does building a document pipeline take a growth company?

Cost and timeline depend on the volume and variety of documents. The sprint model makes progress predictable: development moves in 3-day cycles, starting with one document type before expanding to others.
