# How do you use Gemini 2.5 Pro for long documents?

Date: 2025-04-06 · Author: Robert Scales · https://guidetoartificialintelligence.com/en/learn/use-gemini-2-5-pro-long-documents/

**Answer:** Upload the whole PDF, count its tokens to confirm it fits in the one-million-token window, and ask questions that require page numbers and short quotes for every claim. Then check a sample of those citations against the document yourself before you rely on the answers.

Gemini 2.5 Pro, which Google released as an experimental model on March 25, has a **context window** of one million tokens. The context window is how much text a model can consider at once; a **token** is a piece of a word, and one million tokens is roughly 750,000 words. That is enough for a long annual report, a set of contracts or a thick technical manual in a single request, with room left for your questions. Google says a two-million-token window is coming.

It is also a **thinking model**: before answering, it works through the problem internally. For documents, that helps with questions that combine facts from different chapters, such as "Does the budget in section 7 match the targets in section 2?" Right now you can use it through the Gemini API, in Google AI Studio (Google's developer workspace), and in the Gemini app if you subscribe to Gemini Advanced.

## A worked example: a 300-page annual report

Imagine a town councillor who receives a 300-page annual report from a regional agency and has a weekend to prepare questions. The report and the outputs described here are illustrative.

**Step 1: Upload and count.** With the Gemini API and Google's `google-genai` Python library, you upload the PDF once and reuse it for every question. Counting tokens first tells you whether the whole file fits.

```python
import os
from google import genai

client = genai.Client(api_key=os.environ["GOOGLE_API_KEY"])
MODEL = "gemini-2.5-pro-exp-03-25"

report = client.files.upload(file="annual-report-2024.pdf")

tokens = client.models.count_tokens(model=MODEL, contents=[report, "Summarize."])
print(tokens.total_tokens)   # must be well under 1,000,000
```

The Gemini API reads each PDF page as an image of the page plus the text extracted from it, so tables, charts and captions are available to the model, not just the body text. Uploaded files are kept for two days.

**Step 2: Ask for a map before asking for answers.**

```prompt
List every chapter and appendix in this report with its starting page number,
and give one sentence on what each covers. Use the page numbers printed on the
pages. If a section has no printed page number, say so.
```

This first answer is your checklist. You can compare it with the report's own table of contents in a minute.

**Step 3: Ask cited questions.**

```prompt
Answer from this report only.
1. What were total operating expenses this year and last year?
2. Which three programs grew the most in spending?
3. Are any targets from the strategic plan section reported as missed?
For every fact, give the page number and a quote of no more than 15 words.
If the report does not say, write "Not in the report." Do not estimate.
```

```python
response = client.models.generate_content(
    model=MODEL,
    contents=[report, open("questions.txt").read()],
)
print(response.text)
```

Asking for a page and a short quote does two jobs: it pushes the model to anchor each answer in the text, and it gives you something quick to verify.

> **Try it:** Take a long PDF you know well, such as a manual or a policy you have read, and ask Gemini 2.5 Pro five questions with page citations. Check every citation, and note how many were exact, close or wrong.

## Tips that save time

- **One document, many questions.** Keep the uploaded file and send several short requests rather than one enormous prompt; each answer is easier to check.
- **Name the section when you can.** "In the financial statements, …" narrows the search and reduces mix-ups between similar tables.
- **Ask for disagreements.** "Where does the report contradict itself?" is a question long-context models are good at and humans find tedious.
- **Watch the label.** This is an experimental release, so behaviour and availability may change; save prompts and answers you rely on.

## How do you check that it read everything?

You can't watch a model read, but you can test whether its answers draw on every part of the document. First, the token count from Step 1 confirms the whole file was sent. If the number seems far too low for 300 pages, the PDF may be a scan with little extractable text, or the upload may have failed.

Second, use the chapter map from Step 2 as a coverage test. Then ask one specific question about each part, making sure to include the last third of the document and the appendices, the parts a quick reader is most likely to skip. A good question has a single, checkable answer: "What is the figure in the last row of the table on staffing in Appendix C?" If answers about late pages are vague or wrong while early pages are precise, treat the analysis as incomplete.

Third, check the citations. You don't need to verify all of them; pick five at random and open those pages. Quotes should match the page they cite, word for word. A quote that exists but sits on another page is a small error; a quote that doesn't exist at all is a serious one, and a sign to re-ask that question more narrowly. Combine the three checks and you know not only what the model said, but how much of it you can trust.

## Sources

- Gemini 2.5: Our most intelligent AI model: https://blog.google/technology/google-deepmind/gemini-model-thinking-updates-march-2025/
- Gemini API: Read a PDF: https://github.com/google-gemini/cookbook/blob/b17c49abee9abeed62433c15ee81bcdc61a4522e/quickstarts/PDF_Files.ipynb
- Google unveils a next-gen family of AI reasoning models: https://techcrunch.com/2025/03/25/google-unveils-a-next-gen-ai-reasoning-model/
