1. Home
  2. Explore
  3. Computer Science
  4. Document Data Processing

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Document Data Processing

Document Intelligence and Agentic Workflows

Documents as a Data Challenge

Written language is a technology for recording and sharing information. Across history, people have used writing systems and reproduction technologies—from cave paintings, hieroglyphics, and cuneiform to movable type, photocopies, and digital files—to preserve important facts and communicate them to others.

In modern organizations, documents often contain information needed for data-driven decisions. The challenge is that documents are usually unstructured data: their information is not consistently arranged in a form that computers can easily query, compare, or analyze. Document intelligence aims to convert this information into structured, usable data while retaining enough context to support reliable decisions.

A document may contain several kinds of content:

  • Narrative text, including titles, paragraphs, and punctuation

  • Tabular information, ranging from simple tables to large, complex ones

  • Numbers and dates, which may appear in text or tables

  • Different amounts of content, from short files to documents hundreds of pages long

  • Layout-dependent information, such as tables that continue across page breaks

The difficulty increases when a document collection includes long files, tables with thousands of rows, or documents containing a mixture of text and tabular data. A useful system must do more than recognize individual words: it must also preserve their organization and meaning.


OCR and Its Limitations

Optical character recognition (OCR) uses computer vision to identify characters in images of documents and convert them into machine-readable text. OCR can also attempt to detect tables and other layout features.

OCR is useful for making scanned documents searchable and for supplying text to later processing stages. However, OCR alone does not provide a full understanding of a document:

  • It may identify words without understanding their meaning or role.

  • It may lose or misinterpret structure, especially around page breaks.

  • It may not reliably preserve relationships between table headers, rows, and values.

  • It generally produces text rather than a semantic interpretation of the document.

Thus, OCR is best understood as a way to extract textual content—not as a complete document-understanding solution. Further processing is needed to identify entities, relationships, and the specific facts required for a data model.


Why Document Collections Must Be Understood as a Whole

A single document may be difficult to interpret without the other documents related to it. Documents often form hierarchies: connected sets in which one document refers to, modifies, continues, or provides evidence for another. Understanding a collection therefore requires examining relationships among documents, not just extracting facts from each file independently.

Vertical hierarchies

A vertical hierarchy follows a sequence of related documents, often showing how a particular agreement, transaction, or process develops over time.

For example, a contractual relationship might include:

  1. A master service agreement

  2. One or more statements of work under that agreement

  3. Amendments to the statements of work

  4. A purchase order associated with a statement of work

  5. An invoice associated with the purchase order

Each document supplies context for others. An invoice, for example, may be difficult to interpret correctly without knowing which purchase order and statement of work it concerns.

Horizontal hierarchies

A horizontal hierarchy connects different document types or lines of work. It can reveal how information, events, or products relate across a broader process.

In research and product development, a sequence might include:

  • A research paper

  • Later research results that cite or build upon earlier work

  • A patent filing based on research

  • Product documentation associated with a resulting product

The relationships show how ideas developed, which work informed later results, and how research moved toward an application.

Supply-chain documents provide another example:

  • A bill of lading records the shipment and its contents.

  • A certificate of insurance documents coverage for the shipment.

  • A receiving or shipping receipt records what the recipient believes arrived.

  • A claim may be filed if goods were missing or damaged.

A claim may need to be linked to the shipment, the recipient, the receipt, and the applicable insurance certificate. This shows why document matching and relationship analysis are essential to understanding a transaction.


GPT Models and Language Processing

A major development in document intelligence is the use of GPT models, a family of foundation models used to build large language model applications. GPT stands for generative pre-trained transformer:

  • Generative means the model can produce new text.

  • Pre-trained means it first learns patterns from large amounts of data before being adapted or prompted for particular tasks.

  • Transformer refers to the model architecture that processes sequences and uses attention mechanisms to represent relationships among their elements.

Language models operate on text represented as tokens. A token may correspond to a word, part of a word, punctuation, or another text unit. The model converts tokens into numerical representations, processes those representations, and uses them to predict likely continuations or produce responses.

Embeddings and vector representations

An embedding represents a token or other item as a numerical vector. These vectors allow a model to process language mathematically and capture patterns of similarity and relationship. In practical systems, embeddings are generally multidimensional—not merely one-dimensional measures of distance.

Transformers and attention

Transformer models use attention to weigh relationships among tokens. This helps a model use relevant context when interpreting or generating language. Attention operates over learned vector representations and can account for relationships between words that are separated within a sequence.

Transformer processing may also include normalization and other computations that help organize and stabilize the model’s internal representations. The model’s detailed operations involve high-dimensional mathematics, but their practical purpose is to help it detect patterns in context and use them to generate or interpret language.

Output probabilities and style

A language model assigns scores to possible next tokens and converts them into a probability distribution. It then selects or samples a token according to its generation procedure and continues producing text. The probabilities describe the relative likelihood of candidate tokens; the model does not simply emit an entire response whose probability is one.

The wording and style of a response can be influenced by the prompt, instructions, and decoding settings. For example, a system can be asked to use a particular tone or domain vocabulary. Style control is not limited to one isolated “attention output” stage; it depends on how the model is prompted and configured.


From Documents to Structured Data

A document-intelligence system often needs to extract a small set of important facts from a large amount of source material. For example, a long document may contain hundreds or thousands of words, while an organization may need only a few dozen fields for a specific data model.

This process is not simply a matter of progressively deleting information. It involves several stages that may expand and transform the data before a system narrows it into the desired structured representation:

  1. Document input: The system receives one or more files, which may contain text, images, tables, or mixed layouts.

  2. Text and layout extraction: OCR or other tools identify text and may detect elements such as tables.

  3. Language processing: Natural language processing (NLP) identifies and analyzes linguistic content, such as entities, phrases, and relationships.

  4. Model-based analysis: A large language model can help interpret context, resolve meaning, and identify information relevant to a task.

  5. Structured extraction: The system maps the interpreted information into the fields required by a target data model.

Each stage may create additional representations, annotations, or intermediate data. The goal is ultimately to produce a compact, reliable structure containing the facts relevant to a particular decision or workflow.

OCR, NLP, and large language models serve different but complementary roles. OCR extracts text from images, NLP analyzes language, and language models can use context to support interpretation and extraction. A complete system may combine these technologies rather than relying on any one of them.


Agentic Workflows for Document Intelligence

An AI agent is a software component assigned a particular task. A document-processing system can use multiple agents, with each agent handling part of the larger problem. Agents may exchange results or inspect the work performed by other agents.

Common document-processing agents

Inspection agent

An inspection agent examines a file before or during processing. It may check:

  • File type, size, and length

  • Checksums or other file-integrity indicators

  • Word spacing and other document characteristics

  • The kinds of content present, such as text, images, or tables

This can help determine how a file should be processed and whether it has unusual properties.

OCR agent

An OCR agent converts image-based document content into machine-readable text and may identify alphanumeric data or tables. Some multimodal models can process images directly, but OCR remains a useful specialized component in many systems.

Vectorization agent

A vectorization agent prepares content for model-based search or analysis. It may divide a document into chunks, convert those chunks into token sequences, and create vector representations using an embedding model. Chunking is important because documents may be too long to process as one unit and because retrieval systems need manageable passages to compare.

Splitter agent

A splitter agent identifies where a combined file should be separated into multiple documents. This is useful when several documents have been scanned or uploaded as one file. The agent may use page content, layout, or other evidence to infer document boundaries.

Extraction agent

An extraction agent identifies the information required by a target data model. It may use prompts or other instructions that specify which fields to locate, how to interpret them, and how to return the results. Its purpose is to transform a large body of document information into a smaller set of relevant data points.

Matching agent

A matching agent compares documents and their metadata to determine which files are related. It can help establish vertical and horizontal relationships—for example, linking an invoice to a purchase order or a claim to a shipping record and insurance certificate.


Traditional and Agentic Workflows

A traditional data pipeline is often sequential and deterministic: a predefined stage produces an output, and that output becomes the input to the next stage. The order and conditions of processing are designed in advance.

An agentic workflow can be more flexible. Agents may respond to events, such as new data arriving, and may examine information produced by other agents before deciding what action to take. Rather than following only one fixed sequence, the system can coordinate specialized tasks according to the situation.

Potential advantages include:

  • Autonomy: Agents can carry out assigned tasks with less direct human intervention.

  • Efficiency: Work can be routed to the components best suited to it.

  • Scalability: A system can handle increasing volumes or varieties of documents by coordinating more processing resources.

  • Adaptability: Agents can respond to the content or state of incoming work rather than relying entirely on a fixed sequence.

Agentic systems also introduce greater non-determinism. Their actions or outputs may vary based on context, model behavior, or the results of other agents. This flexibility can enable new approaches, but it also makes careful coordination and evaluation important. Human oversight, validation, and clear requirements remain valuable when extracted information supports consequential decisions.


Key Takeaways

  • Documents are often unstructured, even when they contain recognizable text, tables, dates, and numbers.

  • OCR extracts text but does not by itself provide reliable semantic understanding or preserve all document relationships.

  • Document collections frequently form vertical and horizontal hierarchies that must be understood to interpret individual files correctly.

  • GPT models use token-based numerical representations and transformer attention to process language and generate or interpret text.

  • Effective document intelligence combines extraction, language analysis, model-based interpretation, and structured data mapping.

  • Specialized agents can inspect, OCR, vectorize, split, extract, and match documents.

  • Agentic workflows offer flexibility and autonomy compared with fixed pipelines, while requiring attention to validation and non-deterministic behavior.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent