Skip to main content
OctopusPDF Guide

summarize a 200-page regulatory compliance pdf with ai on a government employee's air-gapped computer

Summarize a 200 Page Regulatory Compliance PDF with AI on a Government Employee's Air Gapped Computer To summarize a 200 page regulatory compliance PDF with AI …

Summarize a 200-Page Regulatory Compliance PDF with AI on a Government Employee's Air-Gapped Computer

To summarize a 200-page regulatory compliance PDF with AI on a government employee's air-gapped computer, you must run the entire workflow offline: extract the PDF's text with a local tool, split it into chunks that fit your model's context window, summarize each chunk with a locally hosted large language model such as Ollama or llama.cpp, merge the per-chunk summaries using a hierarchical strategy, and have a human verify the result against the source. Cloud AI services and online API keys will not work on a truly air-gapped machine because it has no internet connection; the only workable path is local text extraction, local inference, and manual review.

What You Will Need

  • The 200-page regulatory compliance PDF, already stored on the air-gapped machine (or moved there under your agency's removable-media policy).
  • An approved local LLM runtime: Ollama (simpler, CLI-first) or llama.cpp (lower memory footprint).
  • An approved model file suitable for the document's data classification, such as a quantized (GGUF) 8B-class Llama or Mistral model.
  • A PDF text extraction tool: poppler-utils (pdftotext) is the primary recommendation; Apache Tika may be used if installed and approved.
  • A local OCR tool, Tesseract, only if the PDF is a scanned/image document.
  • A text editor or small script for chunking, page mapping, and recursive merging.
  • A human reviewer with knowledge of the regulations in the document.

Step-by-Step Instructions

Step 1. Confirm agency rules, software approval, and model licensing

Check the document's classification level and your agency's policy on loading new software and AI models onto an air-gapped machine. Regulatory compliance work frequently involves sensitive, FOIA-related, or otherwise confidential material, so the classification determines which tools are permitted.

The same review applies to the model itself. Verify that the model's license (for example, the Llama Community License or a Mistral license) allows internal government use, and obtain written approval before acquiring or transferring the model. Record approval numbers and any conditions attached to the media transfer or installation.

Watch out: Do not move the PDF to a networked machine to "save time," even temporarily, unless your agency's transfer policy explicitly allows it. Air-gapped workflows exist for a reason, and a removable-media violation is usually a serious compliance breach.

Step 2. Acquire, verify, and transfer an approved local AI model through authorized media

On an approved, networked workstation, download the model weights from the official publisher repository. Verify the SHA-256 checksum against the value published by the model publisher, and record the model name, version, expected hash, and download date in a transfer log.

  • Confirm the model license is on the approved list and that the model does not require any external data or telemetry.
  • Copy the model files to approved removable media (for example, a designated, possibly encrypted USB drive) following your agency's removable-media policy.
  • Physically move the media to the air-gapped machine and copy the model to the approved storage location.
  • Re-verify the SHA-256 checksum after copying.
  • Install the runtime (Ollama or llama.cpp) from approved software media and load the model. Document the date, model name and version, final checksum, and approver in the transfer/installation log.

Why: Air-gapped machines have no internet, so the AI model must physically travel to the machine on approved media. Checksum verification ensures the model file was not corrupted or altered in transit, and license review ensures the use is lawful and policy-compliant.

Watch out: Never attach the air-gapped machine to any network, even briefly, to "just pull the model." That defeats the air gap and may trigger a security incident.

Step 3. Extract text from the 200-page PDF locally

Convert the PDF's contents to plain text or Markdown on the air-gapped machine so the language model can read it. The most direct command is:

pdftotext -layout compliance_manual.pdf compliance_manual.txt

The -layout flag preserves two-column and table alignment. If pdftotext is not available, Apache Tika is a reliable alternative:

java -jar tika-app-x.x.jar --text compliance_manual.pdf > compliance_manual.txt

You may also use a local browser-based PDF parser if it is on your agency's approved software list and runs fully offline, but the command-line workflow is easier to reproduce and audit.

Watch out: If pdftotext returns empty text, the PDF is image-only and needs OCR first. Skip to Step 4 only after you confirm real text exists.

Step 4. Split the extracted text into context-sized chunks and keep a page map

Large language models have a finite context window; a 200-page document will not fit in one pass. Split the text into chunks that fit comfortably inside the model's context window, and prefer splitting on the document's own structure (Part, Section, paragraph) rather than at arbitrary character counts.

Typical model context window Safe chunk size (tokens) Approx. characters
4K context 1,500–2,000 6,000–8,000
8K context (e.g., Llama 3.1 8B default) 4,000–6,000 16,000–24,000
32K+ context 6,000–8,000 24,000–32,000

To make page-level verification possible, first extract each PDF page into its own text file:

mkdir pages
for i in $(seq 1 200); do
  p=$(printf "pages/page_%04d.txt" "$i")
  pdftotext -layout -f "$i" -l "$i" compliance_manual.pdf "$p"
done

Then use a small script to combine consecutive page files into chunks based on your target chunk size. The script should record the start page and end page of each chunk in a manifest file, for example chunks/manifest.csv. If the document has clear headings, the script can stop combining pages at a heading boundary before the target size is exceeded.

Watch out: Keep each requirement or definition inside a single chunk. A compliance obligation that is split across two chunks may be missed entirely by the model.

Step 5. Spot-check extraction quality on a few pages

Open the first page, last page, and a random middle page from the extracted text files. Check for garbled text, interleaved columns, missing footnote numbers, or broken tables. Regulatory PDFs frequently contain numbered clauses, cross-references, and tables; these are exactly what a summarizer needs to handle correctly.

Action: If the text reads cleanly, proceed. If not, re-run extraction with pdftotext -layout, switch to a structure-aware extraction tool, or run OCR.

Watch out: Do not skip this step. A model cannot summarize what the extraction step silently dropped.

Step 6. Summarize each chunk with a local model via the command line

Run the local model over every chunk using a fixed prompt template so the output format stays consistent. Example prompt:

"You are reviewing a government regulatory compliance document. Below is chunk X of N. Produce a factual summary containing: (1) every compliance requirement, prohibition, or obligation; (2) all explicit thresholds, numbers, and deadlines; (3) any ambiguous clauses that need human review. Do not add advice or guess missing details."

A simple shell loop can produce one summary per chunk:

for f in chunks/chunk_*.txt; do
  ollama run llama3.1:8b "You are reviewing a government regulatory compliance document. Below is chunk $f. Produce a factual summary containing every compliance requirement, prohibition, or obligation; all explicit thresholds, numbers, and deadlines; and any ambiguous clauses that need human review. Do not add advice or guess missing details." > "summaries/$(basename "$f" .txt)_summary.txt"
done

If the shell command becomes too long for a large chunk, write a short Python or shell script that sends the chunk text to the local Ollama HTTP API at http://localhost:11434 or directly invokes ollama run in a subprocess. The important point is that the model runs on the air-gapped machine and no text leaves it.

Watch out: A connection error when using the API almost always means Ollama is not running, or the host/port is wrong. Confirm the service is up before rerunning.

Step 7. Merge chunk summaries recursively (multi-level synthesis)

Do not try to feed all chunk summaries into the model in one pass. For a 200-page document, you may have dozens or even a hundred chunk summaries, and their total length can easily exceed the context window.

Use a hierarchical merging strategy instead:

  1. Group chunk summaries into batches that fit comfortably in the model's context window — for example, 8–10 summaries per batch.
  2. For each batch, prompt the model to produce an intermediate summary that preserves every explicit requirement, number, deadline, cross-reference, and open item.
  3. Group the intermediate summaries into larger batches and repeat the process until you have a single final digest.

Example for 80 chunk summaries:

  • 80 chunk summaries → 10 intermediate summaries (batch size 8)
  • 10 intermediate summaries → 2 high-level summaries (batch size 5)
  • 2 high-level summaries → 1 final digest

Each step stays within a 4K–6K token context under this configuration.

Use a synthesis prompt similar to the following:

"Synthesize the following chunk summaries into a structured digest: (1) executive summary; (2) table of key obligations with deadlines and thresholds; (3) list of items requiring human review. Preserve every explicit deadline, threshold, cross-reference, and ambiguous item that appeared in any source summary. Do not add new facts."

Store chunk summaries, intermediate summaries, and the final digest in separate folders (summaries/chunks/, summaries/intermediate/, summaries/final/) so you can trace any claim back to the source chunk and page.

Watch out: Every merging pass can also hallucinate. Keep all intermediate files as part of the audit trail.

Step 8. Human-review the summary against the source PDF

Spot-check every high-risk statement in the final digest against the original PDF. Verify clause numbers, dates, percentages, and the names of any required forms or filings, because these are the items most likely to be misstated by an AI model.

Action: Flag any discrepancy in the draft, correct it, and record that the correction was made manually.

Watch out: Never treat the AI output as an official compliance determination. Treat it as an annotated index that speeds up a human reviewer's work.

Step 9. Save and label the deliverable

Save the final summary in the approved document repository on the air-gapped machine. Label it clearly as an "AI-assisted draft — pending human review" and include the date, the model name and version, and the name of the reviewing officer.

Why: Government compliance work requires an audit trail. The label ensures nobody mistakes the AI output for official analysis.

Common Mistakes / Troubleshooting

Problem Likely Cause Fix
Ollama crashes or runs out of memory Model is too large for the machine's RAM/CPU Switch to a smaller quantized GGUF model, or use llama.cpp with 4-bit quantization
pdftotext produces garbled or interleaved text Two-column layout was flattened incorrectly Re-run with pdftotext -layout, or use Apache Tika
Extraction yields no text at all The PDF is a scanned image document Run local OCR first with Tesseract, then re-extract
Local API call returns a connection error Ollama is not running, or the host/port is wrong Confirm Ollama is running and is listening on http://localhost:11434
Summary contains a requirement number or date not in the source Model hallucination Flag it, check the original page, correct manually, and keep the summary labeled as a draft
All chunk summaries will not fit in context in one pass Attempting single-pass synthesis Use recursive merging with batches as described in Step 7

How to Verify Success

  • The 200-page PDF never left the air-gapped machine, and no network connection was established.
  • SHA-256 checksums for the model and tools match the publisher's published values, and the model license/approval is documented.
  • Text extraction produced readable content covering all 200 pages.
  • Every page is assigned to a chunk: check the manifest generated in Step 4 (e.g., chunks/manifest.csv) with a small script that verifies the start/end pages are contiguous from 1 to 200, with no gaps or duplicates.
  • Every chunk produced a summary: compare the number of files in chunks/ and summaries/chunks/ programmatically.
  • The merged digest contains an executive summary, an obligations table, and an open-items list.
  • At least five specific facts (clause numbers, dates, thresholds) were spot-checked against the source and corrected where needed.
  • The final file is labeled "AI-assisted draft — pending human review" with model version and reviewer name.

FAQ

Q1. Can I use ChatGPT or another cloud AI service on an air-gapped computer?

No. By definition, an air-gapped computer has no internet connection, so cloud AI services cannot be reached. The only workable approach is a locally hosted model (Ollama or llama.cpp). If your agency policy permits moving the document to a networked machine, you must first follow its data transfer and classification rules.

Q2. Is using AI on government regulatory documents allowed?

It depends on your agency's policy and the document's classification. Obtain written approval for the document, the software, and the model license, keep all processing on the air-gapped machine, and never connect to a cloud endpoint for these documents. Follow the transfer and approval steps in Step 1 and Step 2.

Q3. What if the 200-page PDF is a scanned document with no text layer?

Run local OCR first with Tesseract (or OCRmyPDF) to produce a text version, then continue with the same chunking and summarization steps. Never upload the scan to an online OCR service, because that would violate the air gap and the file would leave your control.

Key Facts

  • A truly air-gapped computer cannot reach cloud AI; all summarization must run on a locally hosted model such as Ollama or llama.cpp.
  • Use pdftotext for extraction and a command-line loop for chunk summaries to keep the workflow simple and auditable.
  • A 200-page document must be split into context-sized chunks, summarized chunk by chunk, and then merged recursively using batch synthesis so that no prompt exceeds the context window.
  • Image-only PDFs require local OCR with Tesseract before any AI summarization can occur.
  • Model weights must be acquired through an approved supply chain: verify checksums, confirm license compliance, and transfer only on authorized media.
  • Every AI-generated summary of a compliance document must be human-reviewed; clause numbers, dates, and thresholds must be verified against the original PDF before the summary is used.