← All articles

Tools9 min read

How to ask questions about a PDF and check the AI answer against a quote

Ask a PDF five questions and check the evidence. Compare a text PDF and an OCR scan with a local model, and learn to spot a citation to an obsolete rule.

Igor Karmazin · AI Technical Product Operations

Ask your PDF

A PDF chat can help you find an answer and the passage you need to verify it. This is useful when you want one fact from a procedure, such as a dispatch cutoff, an order limit or the role that approves an exception. Ask for the file, the page and the exact sentence. A model can return the right number without producing evidence that would let a colleague trust it.

We used two copies of a fictional three-page warehouse procedure called K17. One had extractable text and the other contained only page images. We put five identical questions to a local model and checked its responses against the original. The files are safe to use as an exercise. The same check works with another product. Download the PDFs, questions, scripts and model output.

Decide what kind of PDF you have

Open the file and select a whole sentence. Paste that sentence into a plain-text editor. If the words remain readable and appear in order, the file probably contains a useful text layer. Some PDF viewers can select words in images with their own recognition feature. For a reproducible check, we also ran pdftotext -layout. Keep the page boundaries when you extract text so that a quote can be traced to its physical page.

In our kit, k17-procedure.pdf contains ordinary selectable text. Each page of k17-procedure-scan.pdf is a picture. Poppler extracted no meaningful text from that copy. We rendered each page individually, ran Tesseract and gave the resulting text to the model with the physical page numbers preserved. Both text inputs are included. This is a deliberately clean synthetic scan. A tilted photo, a stamp over a number or a two-column form would put different demands on OCR. How to check OCR on a scanned PDF · Tesseract project.

Choose a tool that fits the document

Job Starting point What to verify
Answer questions from a few public PDFs NotebookLM, called Gemini Notebook in Google's current help Open the cited passage and read its surrounding text
Read a value from a chart or a complex table A tool that processes page images, such as Gemini API Check the heading, units, row and column
Keep work text away from a hosted model Extract or OCR each page, preserve numbering and query a local model Verify which files your application reads and how it preserves pages

The cloud options in the table come from the vendors' documentation. The measured exercise uses Ollama and Qwen2.5 1.5B. A short text PDF may fit into a single prompt. For hundreds of procedures, retrieve a few relevant pages first and ask the model to answer from them. That is a common RAG design. If retrieval misses the active revision, even a capable model may produce a well-written answer from obsolete text. Gemini Notebook source formats · PDF processing with Gemini API · How RAG works.

Ask a question with a checkable answer

  1. Start with one file. Name it explicitly and indicate its revision if you have several. For a first check, choose a document whose answer you already know. That separates locating the evidence from writing the answer.
  2. Ask for one decision. “What is the current limit per K17 trial dispatch?” is easier to verify than “tell me about limits”. The first question points to one rule with a clear scope.
  3. Define the page number. Ask for the physical PDF page, counting from 1. On the second physical page of our file the footer reads Document page 01. Covers, appendices and internal numbering often make these two numbers differ.
  4. Ask for the full supporting sentence. Go to that page and read the words that govern the answer. A qualifier like “only”, “except” or “under revision 1.8” may carry most of the meaning.
  5. Allow the answer “not stated”. If the evidence is in a missing attachment, the model can identify the gap. A missing value does not mean zero, permission, or a request to fill in a plausible guess.

In Gemini Notebook, create a notebook, add the sample PDF and ask the question in chat. Google documents clicking a citation to open the relevant context. Leave only one source selected at first. When testing the scan, replace the text version or deselect it. Otherwise a correct answer may come from the readable copy even if the scan was never recognised. How to open citations in Gemini Notebook.

A prompt for your own check

Answer only from the selected PDF. Use the active revision. Return a short answer, the filename, the physical PDF page and one exact supporting sentence. If the value is absent, say “not stated” and leave the page and quote empty. If rules differ by revision, tell me which revision applies.

Five questions, two versions of one PDF

Page 1 establishes that revision 2.4 is active. It also mentions the old maximum of 40 from revision 1.8. The active limit of 24 is on page 2, next to the cutoff. Page 3 gives the role responsible for exceptions and leaves out a direct phone number.

Question Reference answer Physical PDF page
Which revision is active? 2.4 1
How many units are allowed under the current procedure? 24 2
What is the dispatch cutoff? 15:30 Moscow time 2
Who authorizes a release exception? Shift supervisor 3
What is the warehouse's direct phone number? Not stated —

For each independent question, the model received all three pages and returned fields for the answer, page and quote. We checked the substantive value, the page and whether the full reference sentence appeared in the output on that page. For the absent value we expected it to decline the guess, with an empty page and quote. JSON makes the records easy to check consistently. A correct JSON shape does not validate the contents. Structured outputs in Ollama.

What happened. The substantive answers matched all five reference values in both runs. Three of five responses from the text PDF met the full evidence check, and four of five from the OCR copy did. Those counts include correctly reporting that no phone number was stated. The text run left the quote empty for the active revision and quantity limit. The OCR run left it empty for the revision. The literal answer to the limit question was 24 units per trial both times. On the OCR copy, it came with the supporting sentence from page 2. This was one small synthetic document, so that difference tells us nothing about whether OCR generally improves answers.

A real citation can point to the wrong rule

Consider the answer “The maximum is 40 units, page 1.” There really is a sentence on page 1 about a maximum of 40. It explicitly describes an obsolete revision. We included this as an illustrative failure for you to catch. It is separate from the measured model output, which shows a different failure: a correct value with no supporting quote.

Use three checks before relying on an answer. First, open the given page and locate the text. Second, read it with the surrounding date, revision and eligibility criteria. Third, see whether a second document is needed. A source may be genuine and still fail to support the precise claim. For example, a procedure can defer the answer to an attachment that was never uploaded. In a review table, keep “found the quote” and “quote supports the claim” in separate columns.

Reproduce the local test and estimate the cost

The test uses Python 3, Poppler, Tesseract with English training data and Ollama. Extract the download into its own directory. The supplied extract.py builds pages.json, and ask.py sends five questions for each page set. We tested with Tesseract 5.5.3, Ollama 0.40.19 and the public qwen2.5:1.5b model. Public model catalogue · Getting started with Ollama.

On macOS or Linux, start a separate local instance with OLLAMA_HOST=127.0.0.1:18765 OLLAMA_NO_CLOUD=1 ollama serve. In the exercise directory in another terminal, run OLLAMA_HOST=127.0.0.1:18765 ollama pull qwen2.5:1.5b, then python3 extract.py and python3 ask.py. If that port is in use, agree on a different port in the commands and script. Pulling the model initially needs network access. The questions go to a local endpoint and do not require a paid model API key.

Gemini Notebook has a standard allowance without a paid plan and paid options with higher limits. Check the current allowance in your account for a short public-file exercise. On a large archive, the cloud cost depends on the plan or model and how much material you process more than once. With local processing, factor in model storage, recognition time and review time, especially for pages the scanner handles poorly. Current Gemini Notebook allowances.

FAQ

Can I ask questions about a PDF without paying for a subscription?

For a public sample, try the standard Gemini Notebook allowance. The local Poppler, Tesseract and Ollama workflow also works after software and model downloads. Check a few known values either way.

Is a page number enough to trust an AI answer?

Open the page and locate the exact sentence. Read the nearby conditions. A correctly cited passage might describe an old revision, a special case or an example that doesn't apply to your question.

What if the AI cannot read my scan?

Check that the source image is legible, run OCR and preserve page boundaries. For a diagram or complicated table, test a tool that processes page images. Verify key values against the original PDF.

Read on Telegram