Skip to main content
DocAssessment logoDocAssessment
Methodology

Deterministic extraction before AI

DocAssessment runs seven deterministic steps before the AI layer sees any content — every fact is located by pattern first, and the AI only explains what was already found.

Most AI document tools send your raw document directly to a language model and ask it to summarize or interpret. That approach produces confident-sounding output that can invent facts, a failure mode known as hallucination. DocAssessment takes the opposite approach: the AI layer only ever sees already-extracted structured data, never the raw document. For anyone reviewing a contract or agreement before signing, that means each payment term, deadline, and liability clause is located by deterministic pattern matching first — the AI layer only explains what was already found, and every finding traces back to the exact clause that produced it. The seven steps below describe how that structured data is produced and validated.

Last reviewed: July 27, 2026

1. Text Extraction

The first step converts the uploaded file into plain text. The extractor selected depends on the file type:

  • PDF: a native PDF text-extraction library handles text-based PDFs and preserves positional data that later feeds table parsing.
  • Word documents: a dedicated .docx converter reduces the file to plain text while stripping styling artifacts.
  • Scanned images and image-only PDFs: an optical-character-recognition (OCR) engine reads the text and reports a scan-quality score that later gates the qualification step.
  • Pasted text: the input is already plain text, so step 1 is skipped and the pipeline jumps to type detection.

No AI model is involved in text extraction. Every character that continues into the pipeline came directly from the file or image the user uploaded.

2. Document Type Detection

Extracted text is classified as one of six supported types — residential lease, employment agreement, insurance policy, general contract, invoice, and quote — using keyword routing against a curated lexicon. The classifier is a short, auditable rules module, not a model. If no category scores high enough, the type returns unknown and the qualification gate refuses the document before payment is requested.

Keyword-based classification was chosen over statistical classifiers because it is deterministic: the same text always produces the same label, and each label is traceable to the token set that triggered it.

3. Content Segmentation

The document is split into labelled sections — header block, parties, term, payment, obligations, termination, references, signatures — using regex patterns tuned per document type. Section boundaries matter because downstream fact extraction weights the same token differently depending on which section it appears in. A dollar amount in a "payment" section, for example, is treated as rent or purchase price; the same amount in a "damages" section is treated as a risk signal.

When the structural pass finds fewer than three sections in certain agreement types, the segmenter falls back to paragraph-level splits so the downstream steps still have enough granularity to produce useful facts.

4. Fact Extraction

Parties, dates, money amounts, and places are extracted using a combination of regular expressions and an in-process natural-language library. That library runs entirely on our own servers, with no network calls and no AI model. It recognises entity suffixes like LLC and Inc., normalizes date strings, and tags money tokens with their currency.

Each candidate fact is scored for context validity — is it inside a plausible section, does it have the expected neighbours, is it a false positive such as an invoice number that looks like a dollar amount — and capped per category to prevent a noisy document from flooding the downstream explanation.

5. Risk Scoring

A heuristic scorer inspects the extracted clauses and facts for flat, generic risk signals: automatic renewal is present, a non-compete clause is present, indemnification that runs one-directional, a security deposit that appears above typical, late fees that appear above typical, and similar patterns. The score starts from a small baseline set by the document type and length, each signal that fires adds a fixed point weight on top of it, and the total is capped at 100. Because of that baseline, a document with no signals still carries a low non-zero score — the score is a relative indicator, not a count of problems found. The contributing tokens are stored so each risk flag can be traced back to source text in the report.

The scorer is a pure function of the extracted data, not a model. The point weights are fixed configuration, and every flag carries the source tokens that triggered it — so anyone reviewing the output can trace why a given flag fired back to the original text.

6. AI Explanation

Only after the first five steps produce structured data is an AI model invoked. An AI gateway routes the request to a large-language model selected for the job. The prompt contains the extracted facts, segment labels, and risk tokens — never the raw document body.

The model's job is narrow: rewrite the already-extracted facts and risks in plain language, grouping related points and flagging where context would help a non-specialist reader. Its output is validated against the extraction before it reaches you; the validator in step 7 rejects any output that contains numbers, dates, or party names that do not appear in the extraction.

7. Output Validation

Every AI response is parsed against a strict schema that enforces the shape of the explanation — required fields, length bounds, a forbidden-word list, and cardinality limits on the number of key points and risk flags. Output that fails validation is either retried with a stricter prompt or dropped in favour of the deterministic extraction alone; the user sees the extraction either way, so a validation failure does not leave them without a report.

Structured data for this page and every published article follows the schema.org Article specification, with the DocAssessment organization as the declared author. There are no author-identity or personal-bio fields — the analysis is produced by the pipeline described above, not by a named individual.

What this means for you

Because the AI never sees raw document text, and its output is validated against the extraction — any output that fails validation is rejected before it reaches you — a fact you did not put in your document should not appear in your report. Because the extraction is deterministic, running the same document through the pipeline twice produces the same facts and the same risk score. Because every risk flag carries the source tokens that triggered it, you can verify each flag against the original text before acting on it.

If you want to see the pipeline in action, head to the upload page. If you want to read more background on a specific document type, the articles library covers lease law, employment contracts, insurance, and related topics by jurisdiction.