Back
OCR & Document Extraction

An OCR and RAG Platform for Conversational Document Intelligence

A built and validated system that converts scanned documents, PDFs, and images into a searchable, conversational knowledge base - grounding every chatbot answer in the client's own source content rather than generic model output.

August 21, 2026
Share
ENGAGEMENT SNAPSHOT

CS-009_OCR_RAG_Chatbot_System image 1
Figure 1 - Key figures from this engagement, at a glance.
EXECUTIVE SUMMARY
Our client needed to turn large volumes of scanned documents, PDFs, and images into something people could actually query in natural language, rather than manually reviewing paper or scanned records to find relevant content.
Pfactorial Technologies built and validated the Automated OCR and RAG-Integrated Chatbot System: a platform that digitizes documents through OCR, indexes the extracted content as embeddings in a vector database, and answers natural-language questions with a retrieval-augmented generation pipeline grounded directly in the retrieved source content.
The system has been applied to legal case files and contracts, and separately validated against financial disclosure documents, demonstrating consistent extraction and retrieval accuracy across two distinct document domains - with role-based access control governing who can query, upload, or administer the platform.
Why this engagement is representative This engagement demonstrates Pfactorial's approach to document intelligence: a pluggable OCR layer chosen on evaluated evidence rather than a single fixed engine, answers grounded strictly in retrieved source content, and access control that separates query users from system administrators by design.
THE CHALLENGE
Turning heterogeneous scanned and digital documents into a trustworthy, queryable knowledge base surfaced four distinct technical problems.

1. Documents arrive as images, not text

Scanned PDFs, images, and court documents carry no machine-readable text until OCR extracts it - and extraction quality varies sharply by document complexity and handwriting.

2. No single OCR engine is the right choice for every document

Open-source engines are free and fully customizable but less accurate on complex layouts and handwriting; proprietary engines are more accurate but carry per-document cost - a real trade-off, not a settled choice.

3. Chatbot answers have to be grounded, not generated

A response drawn from the model's own training data rather than the client's actual documents is not usable for legal or financial review - every answer needs to be traceable back to the specific passage that supports it.

4. Access needs differ sharply by role

A legal researcher needs to upload and query documents; a system administrator needs to manage API keys and vector database configuration - and those two sets of permissions should never overlap by default.
The real brief Not "build a chatbot over some documents" but "digitize documents at scale and ground every chatbot answer in the retrieved source content, with access control that keeps query users and system administrators cleanly separated."
THE SOLUTION
Pfactorial built the platform around two coordinated flows - document ingestion and query-time retrieval - so that every chatbot answer is generated from the same indexed, embedded content, regardless of the document's original format.
CS-009_OCR_RAG_Chatbot_System image 2
Figure 1 - The end-to-end RAG pipeline: OCR extraction, chunking, embedding generation, vector storage, and query-time retrieval and response synthesis.

Architectural principles

  • OCR is pluggable, not fixed - the OCR layer supports multiple engines behind a common interface, applying proprietary engines by default for complex or handwritten documents while retaining open-source engines as a lower-cost option for high-volume, straightforward documents.
  • Chunking balances precision against context - extracted text is segmented into chunks sized to improve retrieval accuracy without fragmenting the context a correct answer depends on, with size and overlap tuned per document type rather than fixed globally.
  • Every answer is grounded in retrieved content - the retriever searches the vector database for the most relevant chunks, which are passed to a response synthesizer that constructs an answer grounded in that retrieved content - not open-ended generation.
  • Access control is enforced by role, not convention - a legal researcher can upload documents and query insights but cannot modify system configuration; a system administrator manages infrastructure but does not interact with case-specific queries.
CAPABILITIES DELIVERED
The platform spans document intake, semantic search, grounded conversational answers, and the access controls needed to run all of it safely.
CAPABILITY
WHAT IT DOES
Retrieval-Augmented Generation
Answers natural-language questions with responses grounded directly in retrieved document content, rather than the model's general training data.
Optical Character Recognition
Converts scanned PDFs and images into machine-readable text through a pluggable, engine-agnostic OCR interface.
Role-Based Access Control
Governs feature and data access by predefined role, separating document-query users from system administrators.
Vector Database Storage
Stores document embeddings in Milvus for fast, similarity-based search across the full document collection.
Real-Time Ingestion & Querying
Processes newly uploaded documents and user queries without batch-processing delay.
REST API Integration
Exposes ingestion, querying, and administrative functionality for integration with external applications and workflows.
CS-009_OCR_RAG_Chatbot_System image 3
Figure 2 - Role-based access model: administrators assign users to roles, and each role is authorized for a defined, non-overlapping set of system permissions.
Design note The evaluation between open-source and proprietary OCR engines considered cost, customization, accuracy, language support, processing speed, and scalability. Based on that comparison, the system was configured with a pluggable interface rather than committing to a single provider - proprietary engines for complex or handwritten documents, open-source engines for cost-sensitive, high-volume workloads.
ENGINEERING FOR SCALE AND RELIABILITY
Several engineering decisions shape whether a document intelligence platform holds up on real, varied document collections rather than a clean benchmark set.

The OCR decision was evidence-based, not default

open-source and proprietary OCR engines were evaluated against one another on cost, accuracy, and scalability before the pluggable interface was chosen, rather than committing to one engine at project start.

Cloud deployment removes the local infrastructure ceiling

both the OCR layer and the Milvus vector store support cloud-based deployment, so throughput scales independently of on-premises hardware constraints.

Chunk size is tuned per document type

rather than a single global chunk size, the system tunes chunk size and overlap per document type during ingestion configuration, managing the retrieval-precision-versus-context-completeness trade-off explicitly.

Role granularity is configurable per deployment

RBAC roles are defined at the system-function level today, with role definitions designed to be extended with additional scoped roles without changes to the underlying access-control model.

Retrieval and generation are unified through a single query engine

each user query is embedded, matched against the vector store, and the retrieved chunks are passed to the language model for response synthesis - orchestrated end to end by LlamaIndex and LangChain.

The platform generalizes across document domains

the same OCR and RAG pipeline validated on legal case files was applied to financial disclosure documents with no architectural change, extracting and comparing figures such as year-over-year revenue and summarizing liquidity and capital resources sections.
DELIVERY APPROACH
The platform was built and validated across ingestion, retrieval, and access-control layers, with alternative approaches evaluated on evidence at each key decision point.
1. Build the OCR and ingestion pipeline - implemented format-aware document loading with a pluggable OCR interface, evaluated against open-source and proprietary alternatives.
2. Build chunking and embedding generation - segmented extracted text and generated embeddings via BGE M3 or OpenAI embedding models for semantic search.
3. Stand up vector storage and retrieval - indexed embeddings in Milvus and built the retriever and response synthesizer for grounded, context-aware answers.
4. Implement role-based access control - defined and enforced separate permission sets for legal researchers and system administrators.
5. Validate across document domains - applied the pipeline to legal case files and contracts, then separately validated it against financial disclosure documents.
RESULTS AND IMPACT

CS-009_OCR_RAG_Chatbot_System image 4
Figure - Key outcomes from this engagement.
On validation runs against a real financial disclosure document, the system correctly retrieved and compared fiscal-year revenue figures against the prior year, and condensed the liquidity and capital resources section into a structured summary - each answer paired with the underlying source passage that grounded it.
The same OCR and RAG pipeline, originally applied to legal case files and contracts, generalized to financial disclosure documents without an architectural change, demonstrating that the platform's extraction and retrieval accuracy holds across document domains rather than being tuned to a single use case.

What it enabled commercially

The client's teams can retrieve and analyze case-relevant or financial content through natural-language queries instead of manually reviewing paper or scanned records, with every answer traceable back to its source passage and administrative functions kept cleanly separated from day-to-day query workflows.
WHY PFACTORIAL
This engagement draws on Pfactorial's data and pipeline infrastructure capability: OCR and retrieval systems that generalize across document domains, with every generated answer grounded in retrieved source content rather than left to the model's own recall.
CS-009_OCR_RAG_Chatbot_System image 5
Figure - Service lines this engagement draws on.
Engagement enquiries Pfactorial Technologies works with legal, financial, and document-heavy teams looking to turn scanned and unstructured records into a queryable, grounded knowledge base. If you are evaluating an OCR or retrieval-augmented generation system, we are happy to give you an honest read on scope, cost, and risk before anyone commits to anything. · pfactorial.ai
APPENDIX A - TECHNOLOGY STACK
The technology stack underpinning the system, grouped by the layer it serves.
CS-009_OCR_RAG_Chatbot_System image 6

Result and Analysis

ENGAGEMENT SNAPSHOT

A built and validated system that converts scanned documents, PDFs, and images into a searchable, conversational knowledge base - grounding every chatbot answer in the client's own source content rather than generic model output.

CS-009_OCR_RAG_Chatbot_System image 1
CS-009_OCR_RAG_Chatbot_System image 2
CS-009_OCR_RAG_Chatbot_System image 3
CS-009_OCR_RAG_Chatbot_System image 4
CS-009_OCR_RAG_Chatbot_System image 5
CS-009_OCR_RAG_Chatbot_System image 6