What you need and which model to pick

Windows 10 22H2 or 11, about 15 GB of free disk and, if possible, an NVIDIA card with 12 GB of memory or more. It also works without a GPU, more slowly. Pick the model from “Dedicated GPU memory” in Task Manager.

  • GPU with 12 GB or more: gemma4:12b (8.0 GB on disk). On the 16 GB card it used 8.3–9.3 GB of graphics memory and wrote at 111–113 tokens per second.
  • GPU with 6–8 GB, or no GPU: qwen3.5:4b (3.3 GB on disk). Without a GPU it dropped to 11.9 tokens per second: slower answers, but it works.
  • pdftotext comes with the free Xpdf command line tools; in version 4.06 the program ends up in C:\xpdf-tools-win-4.06\bin64\pdftotext.exe.
  • Python, installed with the Python Install Manager (py install default). The script only uses what comes with Python: no pip packages.

Convert, index and ask: the commands

Before you load anything confidential, cut Ollama’s internet access: with the default configuration it connects to ollama.com as soon as it starts. How to do it and prove it is in Does Ollama connect to the internet?.

From PDFs to verified answers (PowerShell)
  1. ollama pull gemma4:12b
  2. [Environment]::SetEnvironmentVariable('OLLAMA_NO_CLOUD', '1', 'User') and then quit Ollama from the tray and open it again
  3. New-Item -ItemType Directory -Force C:\pdf-local\pdf, C:\pdf-local\txt, C:\pdf-local\scripts | Out-Null
  4. cd C:\pdf-local\scripts; py ask_pdf.py convert C:\pdf-local\pdf --out C:\pdf-local\txt --pdftotext C:\xpdf-tools-win-4.06\bin64\pdftotext.exe
  5. py ask_pdf.py index C:\pdf-local\txt
  6. py ask_pdf.py ask C:\pdf-local\txt "Which courts do the parties to the advisory agreement submit to?"
  7. Output: ANSWER: The parties submit to the courts of Zaragoza. · advisory-agreement-example.txt, p. 3: "The parties submit to the courts of Zaragoza." -> VERIFIED

ask_pdf.py is the script from the book’s free package; the question is about one of its fictional example PDFs. If a page converts with “no text”, it’s a scanned image and needs OCR first.

How the citation check works

The model is asked to answer with file, page and the exact sentence it used. Then the script looks for that sentence on that page of the extracted text, ignoring capitals, accents and line breaks, and labels it. This is the difference between a chat that sounds right and one you can audit.

  • VERIFIED: the sentence is on that page.
  • OTHER PAGE (p. 2): the sentence exists, but the model got the page wrong.
  • NOT FOUND: the quote isn’t in the document. The model paraphrased or made it up, and the answer is worthless until you check it by hand.

Three questions to ask before you trust it

Run these on test documents with known answers before you load a single real one. The book’s package comes with ten ready-made questions for its examples (py ask_pdf.py check C:\pdf-local\txt .\questions-examples.csv), each scored PASS or REVIEW into a CSV you can open in Excel.

  • A question whose answer isn’t in any document (“Who signs the agreement on behalf of Comercial Ejemplo S.A.?”). It must answer PENDING; if it gives a name, it made it up.
  • A fact that changed between versions (“What is the maximum per night for accommodation under the current expenses policy?”). It must pick the current policy, not the superseded one.
  • A fact that appears only on the last page of your longest file. If it finds it, nothing is being cut off.

Why you don’t need embeddings or a vector database

The script doesn’t hand the model your whole documents. It uses keyword search (BM25, the method behind a classic search engine) to find the four chunks most like your question and passes only those, each labeled with file and page. That is RAG, done simply. With 14 internal policy documents and 18 questions, keyword search found the right document for every question that had an answer, just like embeddings, and was the fastest option.

Pasting everything in doesn’t work either: those 14 short documents took 4,200–4,350 tokens, more than the 4,096 Ollama uses by default on a 16 GB card, so part of them would have been dropped without warning. The script sends little text and sets the context to 16,384 tokens. If you build your own setup, read Ollama context length on Windows.

Frequently asked questions

Can I chat with PDFs offline?Yes. Ollama, pdftotext and Python all run locally; with OLLAMA_NO_CLOUD=1 and no :cloud models, our network check showed 0 external connections while it answered.

Do I need LangChain or a vector database?No. Keyword search found the right document as reliably as embeddings in our test with 14 documents, and it was faster.

What about scanned PDFs?pdftotext reports “no text” for pages that are images. Those need OCR (optical character recognition) before the script can use them.

How do I know the answer isn’t made up?Look at the label after each quote: only VERIFIED means the exact sentence was found on that page. NOT FOUND means check it by hand.