ColPali retrieval: one run for the website demo¶

This notebook runs my ColPali retrieval application's own code once, on a fixed set of public documents, and saves the results for the demo on my website. Visitors replay these results; they never run a model.

From the application, unchanged: PDF pages to images (PDFProcessor), indexing every page as an image with ColQwen2 (EmbeddingProcessor.embed_documents), late-interaction scoring (sum_max_sim), the query pipeline with Gemini answers and similarity heat maps (QueryProcessor.process_query, QueryVisualizer).

Added for the demo only: choosing the 33 pages and 14 questions, and saving the results (run_demo.py, below).

Adjusted at run time (the application's files are not edited): the ColQwen2 checkpoint is pinned to its March 2025 snapshot (the model repository moved to a new format in August 2026); the Gemini model is gemini-2.5-flash (gemini-2.0-flash-exp was retired); the model runs on the GPU.

Documents: US federal publications, in the public domain: 19 pages of the NIST AI Risk Management Framework 1.0 and 14 slides of the EIA Annual Energy Outlook 2026 presentation.

How to run it¶

  1. Runtime → Change runtime type → L4, A100, H100 or T4 GPU (not a TPU, not a Blackwell/G4 GPU).
  2. Key icon on the left → add a secret named GEMINI_API_KEY with a Gemini API key, and allow notebook access. (Without it, everything except the answers still runs.)
  3. Runtime → Run all. The first cell asks you to upload colpali-retrieval-src.zip (the application's src folder).
  4. About 15 minutes later the last cell downloads colpali_export.zip.

1. The application code¶

In [1]:
import os, zipfile
os.makedirs("/content/app", exist_ok=True)
if not os.path.exists("/content/app/src"):
    from google.colab import files
    uploaded = files.upload()  # choose colpali-retrieval-src.zip
    with zipfile.ZipFile(next(iter(uploaded))) as z:
        z.extractall("/content/app")
print("application modules:", sorted(os.listdir("/content/app/src")))
Saving colpali-retrieval-src.zip to colpali-retrieval-src.zip
application modules: ['__init__.py', 'api', 'cli', 'config', 'embeddings', 'models', 'querying', 'static', 'utils']

2. A separate Python 3.11 environment with the application's 2025 package versions¶

Colab's own environment (Python 3.13 and the newest TensorFlow, protobuf and transformers) clashes with the versions the application was built on. So the run happens in its own environment, created here with uv, and Colab's packages are left alone. This takes about 3 minutes.

In [2]:
%%writefile /content/env-requirements.txt
# The ColPali retrieval app's dependencies, as in its requirements.txt (early 2025),
# plus the versions they resolved to then. Installed into a separate Python 3.11
# environment so nothing clashes with Colab's preinstalled packages.
colpali-engine==0.3.6
transformers==4.46.3
tokenizers==0.20.3
peft==0.13.2
accelerate==1.0.1
huggingface-hub==0.26.5
safetensors==0.4.5
numpy==1.26.4
pillow==11.1.0
google-generativeai==0.8.3
pdf2image==1.17.0
pypdf==5.1.0
python-dotenv==1.0.1
tqdm==4.67.1
matplotlib==3.10.0
seaborn==0.13.2
fastapi==0.104.1
python-multipart==0.0.6
aiohttp==3.9.3
sqlalchemy==2.0.36
Writing /content/env-requirements.txt
In [3]:
!pip install -q uv
!uv venv -q --allow-existing /content/env --python 3.11
!uv pip install -q --python /content/env/bin/python torch==2.5.1 --index-url https://download.pytorch.org/whl/cu121
!uv pip install -q --python /content/env/bin/python -r /content/env-requirements.txt
!apt-get update -qq > /dev/null 2>&1; apt-get install -y -qq poppler-utils > /dev/null 2>&1; pdftoppm -v 2>&1 | head -1
!/content/env/bin/python -c "import sys, torch, transformers, colpali_engine; print('Python', sys.version.split()[0], '| torch', torch.__version__, '| transformers', transformers.__version__, '| GPU:', torch.cuda.get_device_name() if torch.cuda.is_available() else 'none')"
import subprocess
cap = subprocess.run(["/content/env/bin/python", "-c", "import torch; print(torch.cuda.get_device_capability()[0] if torch.cuda.is_available() else -1)"], capture_output=True, text=True).stdout.strip()
if cap == "-1":
    print("No GPU: it will still run, but on the CPU it takes about an hour. For speed: Runtime → Change runtime type → L4/A100/T4 GPU.")
elif cap and int(cap) >= 10:
    raise SystemExit("This GPU is too new for torch 2.5.1. Runtime → Change runtime type → L4, A100, H100 or T4.")
pdftoppm version 24.02.0
Python 3.11.18 | torch 2.5.1+cu121 | transformers 4.46.3 | GPU: NVIDIA L4

3. The run: the application's pipeline on the chosen pages and questions¶

In [4]:
%%writefile /content/app/run_demo.py
"""One run of the ColPali retrieval application's own code, for the website demo.

Runs from the application's folder (the one that contains `src/`). Everything that
matters comes from the application: PDFProcessor (PDF pages to images),
EmbeddingProcessor (indexing with ColQwen2), sum_max_sim (late-interaction
scoring), QueryProcessor.process_query (top pages, Gemini answers, heat maps) and
QueryVisualizer. This script only chooses the documents and questions and saves
the results.

Three settings are adjusted at run time; the application's files are not edited:
  1. the ColQwen2 checkpoint is pinned to its March 2025 snapshot (the model
     repository moved to a new format in August 2026);
  2. the Gemini model is gemini-2.5-flash (gemini-2.0-flash-exp was retired);
  3. the model runs on the GPU when there is one.
A Gemini call that fails is recorded as "no answer" so the run always finishes.

Environment: GEMINI_API_KEY (optional), OUT (default ./colpali_export),
MODEL_PATH (default: the pinned snapshot), MAX_PAGES / MAX_QUESTIONS (testing).
"""

import io
import json
import os
import shutil
import sys
import time
import urllib.request
import zipfile

sys.path.insert(0, os.getcwd())


class Redact:
    """Hides the API key in everything printed or logged (some error messages include it)."""

    def __init__(self, stream, secret):
        self.stream, self.secret = stream, secret

    def write(self, s):
        return self.stream.write(s.replace(self.secret, "***") if self.secret else s)

    def __getattr__(self, name):
        return getattr(self.stream, name)


# Before anything from the application is imported: its loggers keep a reference to
# the output stream they are created with, and some error messages contain the key.
if os.environ.get("GEMINI_API_KEY"):
    sys.stdout = Redact(sys.stdout, os.environ["GEMINI_API_KEY"])
    sys.stderr = Redact(sys.stderr, os.environ["GEMINI_API_KEY"])

import torch  # noqa: E402
from pypdf import PdfReader, PdfWriter  # noqa: E402

import src.config.settings as settings  # noqa: E402
import src.models.initializers as initializers  # noqa: E402
from src.embeddings.embedding_processor import EmbeddingProcessor  # noqa: E402
from src.querying.query_processor import QueryProcessor  # noqa: E402
from src.utils.pdf_utils import PDFProcessor  # noqa: E402

USER_ID = 1  # the application keeps each user's documents apart; the demo is one user
DOCS = [
    {"id": "nist", "file": "nist-ai-rmf-selected-pages.pdf",
     "title": "NIST AI 100-1: Artificial Intelligence Risk Management Framework (AI RMF 1.0)",
     "publisher": "National Institute of Standards and Technology, January 2023",
     "url": "https://nvlpubs.nist.gov/nistpubs/ai/NIST.AI.100-1.pdf",
     "pages": [6, 7, 8, 9, 10, 15, 16, 17, 19, 20, 21, 22, 23, 25, 27, 31, 34, 37, 43]},
    {"id": "eia", "file": "eia-aeo2026-slides-2-15.pdf",
     "title": "Annual Energy Outlook 2026 (release presentation)",
     "publisher": "U.S. Energy Information Administration, April 2026",
     "url": "https://www.eia.gov/outlooks/aeo/pdf/AEO2026_Release_Presentation.pdf",
     "pages": list(range(2, 16))},
]
QUESTIONS = [
    "Which end-use sector's energy consumption grows the most by 2050?",
    "How much electricity could data center servers use in 2050 in the High Electricity Demand case?",
    "What share of light-duty vehicles could be battery electric by 2050?",
    "What GDP growth and oil price does the Counterfactual Baseline assume?",
    "Which energy sources are consumed most in 2050?",
    "How large could U.S. liquefied natural gas exports become by 2050?",
    "What happens to nuclear generation in the Low Oil and Gas Supply case?",
    "How did past Annual Energy Outlook projections of total energy consumption compare with what actually happened?",
    "What are the characteristics of trustworthy AI?",
    "What are the four functions of the AI RMF Core?",
    "What kinds of harm can AI systems cause?",
    "How do AI risks differ from traditional software risks?",
    "Who are the AI actors across the AI lifecycle?",
    "What does the MEASURE function cover?",
]
TOP_K = 3
GEN_MODEL = "gemini-2.5-flash"
MODEL_ID, MODEL_REVISION = "vidore/colqwen2-v1.0-merged", "14ed9f04a49d1aa8ec08f3aad455a54eea9ee09a"  # March 2025
OUT = os.path.abspath(os.environ.get("OUT", "colpali_export"))
MAX_PAGES = int(os.environ.get("MAX_PAGES", "0"))
MAX_QUESTIONS = int(os.environ.get("MAX_QUESTIONS", "0"))


def step(title):
    print(f"\n=== {title} ===", flush=True)


def main():
    key = os.environ.get("GEMINI_API_KEY") or None
    for d in ("pages", "maps", "pdfs"):
        os.makedirs(os.path.join(OUT, d), exist_ok=True)

    step("1. Documents: the chosen pages go into the user's upload folder")
    settings.create_user_directories(USER_ID)
    raw_dir = settings.RAW_DATA_DIR(USER_ID)
    for f in os.listdir(raw_dir):
        os.remove(os.path.join(raw_dir, f))
    docs = DOCS
    if MAX_PAGES:  # testing only: a few pages of the first document
        docs = [dict(DOCS[0], pages=DOCS[0]["pages"][:MAX_PAGES])]
    for d in docs:
        req = urllib.request.Request(d["url"], headers={"User-Agent": "Mozilla/5.0"})
        reader, writer = PdfReader(io.BytesIO(urllib.request.urlopen(req, timeout=120).read())), PdfWriter()
        for n in d["pages"]:
            writer.add_page(reader.pages[n - 1])
        with open(os.path.join(raw_dir, d["file"]), "wb") as fh:
            writer.write(fh)
        shutil.copy(os.path.join(raw_dir, d["file"]), os.path.join(OUT, "pdfs", d["file"]))
        print(f"{d['file']}: {len(d['pages'])} pages", flush=True)

    step("2. Model (the application's initialize_base_model)")
    model_path = os.environ.get("MODEL_PATH")
    if not model_path:
        from huggingface_hub import snapshot_download
        model_path = snapshot_download(MODEL_ID, revision=MODEL_REVISION)  # adjustment 1
    initializers.COLQWEN2_MODEL_PATH = model_path
    device = "cuda" if torch.cuda.is_available() else None  # adjustment 3
    t = time.time()
    model, processor = initializers.initialize_base_model(device_map=device)
    device_name = torch.cuda.get_device_name() if device else "CPU"
    print(f"loaded in {time.time() - t:.0f} s on {device_name}", flush=True)

    step("3. Indexing (PDFProcessor.process_directory + EmbeddingProcessor.embed_documents)")
    images, pdf_sources = PDFProcessor.process_directory(USER_ID)
    embedding_processor = EmbeddingProcessor(model, processor)
    t = time.time()
    document_embeddings, images, document_token_ids = embedding_processor.embed_documents(images)
    index_seconds = time.time() - t
    print(f"indexed {len(images)} pages in {index_seconds:.1f} s ({index_seconds / len(images):.2f} s per page); "
          f"{int(document_embeddings[0].shape[0])} vectors of {int(document_embeddings[0].shape[1])} numbers for the first page", flush=True)

    step("4. Questions (QueryProcessor.process_query: scores, top pages, Gemini answers, heat maps)")
    import google.generativeai as genai
    gemini_model = None
    if key:
        initializers.initialize_gemini(api_key=key)  # the application's setup: configures the key
        gemini_model = genai.GenerativeModel(  # adjustment 2: same settings, current model
            model_name=GEN_MODEL, generation_config=genai.types.GenerationConfig(**settings.GEMINI_CONFIG))
    else:
        print("No GEMINI_API_KEY: retrieval and heat maps still run; answers are left empty.", flush=True)
    query_processor = QueryProcessor(embedding_processor, gemini_model, document_embeddings, images, pdf_sources, document_token_ids)
    original_answer = query_processor._get_gemini_response

    def answer_or_note(image, query):
        if gemini_model is None:
            return ""
        try:
            return original_answer(image, query)
        except Exception as e:  # keep going: one failed call must not stop the run
            print(f"  Gemini call failed: {e}", flush=True)
            return ""
    query_processor._get_gemini_response = answer_or_note

    questions = QUESTIONS[:MAX_QUESTIONS] if MAX_QUESTIONS else QUESTIONS
    results = []
    for qi, q in enumerate(questions):
        out = query_processor.process_query(q, top_k=min(TOP_K, len(images)), visualize=True, db=None, user_id=USER_ID)
        q_emb = embedding_processor.embed_queries([q])[0]
        scores = [float(embedding_processor.sum_max_sim(q_emb, e, ids)) for e, ids in zip(document_embeddings, document_token_ids)]
        maps = []
        for k, rel in enumerate(out.get("visualization_paths") or [], start=1):
            dst = f"maps/q{qi + 1:02d}-match{k}.png"
            shutil.copy(os.path.join(settings.OUTPUT_DIR, rel), os.path.join(OUT, dst))
            maps.append(dst)
        results.append({"question": q, "scores": scores, "matches": out["matches"], "metrics": out["metrics"], "maps": maps})
        print(f"\n{q}", flush=True)
        for m in out["matches"]:
            print(f"  {m['source']} page {m['page']} (score {m['score']:.1f}): {(m['answer'] or '(no answer)').strip()[:160]}", flush=True)

    step("5. Saving the results for the website")
    pages = []
    for i, (img, src) in enumerate(zip(images, pdf_sources)):
        d = next(x for x in docs if x["file"] == src["filename"])
        original_page = d["pages"][src["page"] - 1]
        name = f"pages/{d['id']}-{original_page:02d}.webp"
        small = img.convert("RGB")
        small.thumbnail((1100, 1100))
        small.save(os.path.join(OUT, name), "WEBP", quality=82)
        pages.append({"index": i, "file": src["filename"], "page_in_file": src["page"], "doc": d["id"], "page": original_page, "image": name})
    export = {
        "model": MODEL_ID, "model_revision": MODEL_REVISION, "generator": GEN_MODEL if gemini_model else None,
        "gemini_config": settings.GEMINI_CONFIG, "top_k": TOP_K, "device": device_name,
        "index_seconds": round(index_seconds, 1), "dim": int(document_embeddings[0].shape[1]),
        "vectors_per_page": [int(e.shape[0]) for e in document_embeddings],
        "docs": [{k: d[k] for k in ("id", "file", "title", "publisher", "url", "pages")} for d in docs],
        "pages": pages, "questions": results,
    }
    with open(os.path.join(OUT, "colpali-demo.json"), "w") as fh:
        json.dump(export, fh, indent=1)
    zip_path = OUT.rstrip("/") + ".zip"
    with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as z:
        for root, _, files in os.walk(OUT):
            for f in files:
                z.write(os.path.join(root, f), os.path.relpath(os.path.join(root, f), OUT))
    answered = sum(1 for r in results for m in r["matches"] if m.get("answer"))
    print(f"{zip_path}: {os.path.getsize(zip_path) / 1e6:.1f} MB; {len(pages)} pages, {len(results)} questions, {answered} answers", flush=True)


if __name__ == "__main__":
    main()
Writing /content/app/run_demo.py
In [5]:
import os, subprocess
env = {k: v for k, v in os.environ.items() if k not in ("PYTHONPATH", "MPLBACKEND")}
env.update(MPLBACKEND="Agg", OUT="/content/colpali_export", PYTHONUNBUFFERED="1")
try:
    from google.colab import userdata
    env["GEMINI_API_KEY"] = userdata.get("GEMINI_API_KEY")
except Exception as e:
    print("No Gemini key available (", type(e).__name__, "): the answers will be left empty.")
proc = subprocess.Popen(["/content/env/bin/python", "run_demo.py"], cwd="/content/app", env=env,
                        stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
for line in proc.stdout:
    print(line, end="")
if proc.wait() != 0:
    raise SystemExit("The run stopped with an error (see above).")
/content/env/lib/python3.11/site-packages/google/api_core/_python_version_support.py:254: FutureWarning: You are using a Python version (3.11.18) which Google will stop supporting in new releases of google.api_core once it reaches its end of life (2027-10-24). Please upgrade to the latest Python version, or at least Python 3.12, to continue receiving updates for google.api_core past that date.
  warnings.warn(message, FutureWarning)

=== 1. Documents: the chosen pages go into the user's upload folder ===
nist-ai-rmf-selected-pages.pdf: 19 pages
eia-aeo2026-slides-2-15.pdf: 14 pages

=== 2. Model (the application's initialize_base_model) ===

Fetching 12 files:   0%|          | 0/12 [00:00<?, ?it/s]
Fetching 12 files:   8%|▊         | 1/12 [00:00<00:08,  1.36it/s]
Fetching 12 files:  42%|████▏     | 5/12 [00:00<00:01,  6.57it/s]
Fetching 12 files:  42%|████▏     | 5/12 [00:19<00:01,  6.57it/s]
Fetching 12 files:  50%|█████     | 6/12 [00:30<00:42,  7.05s/it]
Fetching 12 files: 100%|██████████| 12/12 [00:30<00:00,  2.56s/it]
`Qwen2VLRotaryEmbedding` can now be fully parameterized by passing the model config through the `config` argument. All other arguments will be removed in v4.46
loaded in 3 s on NVIDIA L4

=== 3. Indexing (PDFProcessor.process_directory + EmbeddingProcessor.embed_documents) ===
INFO: Starting document embedding for 33 images
INFO: Processing 17 batches

Processing documents:   0%|          | 0/17 [00:00<?, ?it/s]
Processing documents:   6%|▌         | 1/17 [00:04<01:09,  4.36s/it]
Processing documents:  12%|█▏        | 2/17 [00:08<01:01,  4.13s/it]
Processing documents:  18%|█▊        | 3/17 [00:12<00:56,  4.05s/it]
Processing documents:  24%|██▎       | 4/17 [00:16<00:52,  4.01s/it]
Processing documents:  29%|██▉       | 5/17 [00:20<00:47,  3.99s/it]
Processing documents:  35%|███▌      | 6/17 [00:24<00:43,  3.98s/it]
Processing documents:  41%|████      | 7/17 [00:28<00:39,  3.97s/it]
Processing documents:  47%|████▋     | 8/17 [00:32<00:36,  4.06s/it]
Processing documents:  53%|█████▎    | 9/17 [00:36<00:32,  4.12s/it]
Processing documents:  59%|█████▉    | 10/17 [00:40<00:29,  4.16s/it]
Processing documents:  65%|██████▍   | 11/17 [00:45<00:25,  4.19s/it]
Processing documents:  71%|███████   | 12/17 [00:49<00:21,  4.21s/it]
Processing documents:  76%|███████▋  | 13/17 [00:53<00:16,  4.22s/it]
Processing documents:  82%|████████▏ | 14/17 [00:57<00:12,  4.23s/it]
Processing documents:  88%|████████▊ | 15/17 [01:02<00:08,  4.24s/it]
Processing documents:  94%|█████████▍| 16/17 [01:06<00:04,  4.25s/it]
Processing documents: 100%|██████████| 17/17 [01:07<00:00,  3.34s/it]
Processing documents: 100%|██████████| 17/17 [01:07<00:00,  3.98s/it]
INFO: Successfully embedded 33 documents
indexed 33 pages in 67.6 s (2.05 s per page); 731 vectors of 128 numbers for the first page

=== 4. Questions (QueryProcessor.process_query: scores, top pages, Gemini answers, heat maps) ===
INFO: QueryProcessor: Starting process_query with query text: 'Which end-use sector's energy consumption grows the most by 2050?' for user 1
INFO: Found top 3 matches with scores: [21.126609802246094, 17.4249324798584, 16.080581665039062]
INFO: Query processing completed in 32.47s
INFO: Visualization for match 1 saved to: user_1/match_1.png
INFO: Visualization for match 2 saved to: user_1/match_2.png
INFO: Visualization for match 3 saved to: user_1/match_3.png

Which end-use sector's energy consumption grows the most by 2050?
  eia-aeo2026-slides-2-15.pdf page 7 (score 21.1): Based on the chart, the **industrial** sector's energy consumption grows the most by 2050.

The green line, representing industrial energy consumption, shows a 
  eia-aeo2026-slides-2-15.pdf page 6 (score 17.4): Based on the provided image, there is no information about "end-use sectors" (such as residential, commercial, industrial, or transportation). Both charts displ
  eia-aeo2026-slides-2-15.pdf page 10 (score 16.1): Based on the title of the image: "Data center load is emerging as the dominant driver of long-term U.S. electricity growth," and the fact that the middle and ri
INFO: QueryProcessor: Starting process_query with query text: 'How much electricity could data center servers use in 2050 in the High Electricity Demand case?' for user 1
INFO: Found top 3 matches with scores: [22.390151977539062, 20.769136428833008, 16.863985061645508]
INFO: Query processing completed in 28.46s
INFO: Visualization for match 1 saved to: user_1/match_1.png
INFO: Visualization for match 2 saved to: user_1/match_2.png
INFO: Visualization for match 3 saved to: user_1/match_3.png

How much electricity could data center servers use in 2050 in the High Electricity Demand case?
  eia-aeo2026-slides-2-15.pdf page 10 (score 22.4): Based on the middle chart, "Commercial data center server electricity consumption":

In the **High Electricity Demand** case (the red line), the electricity con
  eia-aeo2026-slides-2-15.pdf page 5 (score 20.8): Based on the provided image, the "High Electricity Demand" case **examines uncertainty about long-term computational requirements and data center server power d
  eia-aeo2026-slides-2-15.pdf page 11 (score 16.9): Based on the provided image, the information about electricity usage specifically for "data center servers" in any case, including the "High Electricity Demand"
INFO: QueryProcessor: Starting process_query with query text: 'What share of light-duty vehicles could be battery electric by 2050?' for user 1
INFO: Found top 3 matches with scores: [18.4947452545166, 16.946258544921875, 14.282910346984863]
INFO: Query processing completed in 31.73s
INFO: Visualization for match 1 saved to: user_1/match_1.png
INFO: Visualization for match 2 saved to: user_1/match_2.png
INFO: Visualization for match 3 saved to: user_1/match_3.png

What share of light-duty vehicles could be battery electric by 2050?
  eia-aeo2026-slides-2-15.pdf page 9 (score 18.5): Based on the "Battery electric vehicle share of light-duty vehicle stocks" chart (the left graph), the data provided only extends to **2045**, not 2050.

Howeve
  eia-aeo2026-slides-2-15.pdf page 8 (score 16.9): Based on the provided image, the share of light-duty vehicles that could be battery electric by 2050 is **not explicitly stated or shown**.

The left chart ("U.
  eia-aeo2026-slides-2-15.pdf page 5 (score 14.3): I'm sorry, but the provided image does not contain information about the share of light-duty vehicles that could be battery electric by 2050.

The image describ
INFO: QueryProcessor: Starting process_query with query text: 'What GDP growth and oil price does the Counterfactual Baseline assume?' for user 1
INFO: Found top 3 matches with scores: [18.805736541748047, 16.49365997314453, 15.897980690002441]
INFO: Query processing completed in 29.53s
INFO: Visualization for match 1 saved to: user_1/match_1.png
INFO: Visualization for match 2 saved to: user_1/match_2.png
INFO: Visualization for match 3 saved to: user_1/match_3.png

What GDP growth and oil price does the Counterfactual Baseline assume?
  eia-aeo2026-slides-2-15.pdf page 4 (score 18.8): The Counterfactual Baseline assumes:
*   **GDP Growth:** 1.7% annual GDP growth
*   **Oil Price:** Brent crude at $87 per barrel in 2050
  eia-aeo2026-slides-2-15.pdf page 13 (score 16.5): The provided image does not contain information about the GDP growth or oil price assumptions for the "Counterfactual Baseline" scenario.

The image shows proje
  eia-aeo2026-slides-2-15.pdf page 11 (score 15.9): The provided image **does not explicitly state** the specific GDP growth and oil price assumptions for the "Counterfactual Baseline" scenario.

In EIA's Annual 
INFO: QueryProcessor: Starting process_query with query text: 'Which energy sources are consumed most in 2050?' for user 1
INFO: Found top 3 matches with scores: [17.21845245361328, 15.050333023071289, 14.821001052856445]
INFO: Query processing completed in 29.29s
INFO: Visualization for match 1 saved to: user_1/match_1.png
INFO: Visualization for match 2 saved to: user_1/match_2.png
INFO: Visualization for match 3 saved to: user_1/match_3.png

Which energy sources are consumed most in 2050?
  eia-aeo2026-slides-2-15.pdf page 6 (score 17.2): According to the title of the image and both charts, **Natural gas** and **Petroleum and other liquids** are the energy sources consumed most in 2050.

The righ
  eia-aeo2026-slides-2-15.pdf page 7 (score 15.1): In 2050, based on the projections in the graph, the **industrial** sector is projected to consume the most energy.
  eia-aeo2026-slides-2-15.pdf page 11 (score 14.8): Based on the "Total generation in all sectors, 2025 and 2050" bar chart (the right side of the image, looking at the rightmost part of each bar for 2050):

The 
INFO: QueryProcessor: Starting process_query with query text: 'How large could U.S. liquefied natural gas exports become by 2050?' for user 1
INFO: Found top 3 matches with scores: [22.72726821899414, 18.87939453125, 16.117679595947266]
INFO: Query processing completed in 28.58s
INFO: Visualization for match 1 saved to: user_1/match_1.png
INFO: Visualization for match 2 saved to: user_1/match_2.png
INFO: Visualization for match 3 saved to: user_1/match_3.png

How large could U.S. liquefied natural gas exports become by 2050?
  eia-aeo2026-slides-2-15.pdf page 12 (score 22.7): Looking at the "U.S. liquefied natural gas exports" chart (the rightmost one):

The highest projection for U.S. liquefied natural gas exports by 2050 is represe
  eia-aeo2026-slides-2-15.pdf page 13 (score 18.9): Based on the provided image, it is not possible to determine the potential size of U.S. liquefied natural gas (LNG) exports by 2050.

The charts in the image di
  eia-aeo2026-slides-2-15.pdf page 6 (score 16.1): I'm sorry, but the provided image focuses on **U.S. energy consumption by fuel type** under various scenarios for 2025 and 2050 (and 2030, 2040 for the right ch
INFO: QueryProcessor: Starting process_query with query text: 'What happens to nuclear generation in the Low Oil and Gas Supply case?' for user 1
INFO: Found top 3 matches with scores: [17.23406982421875, 15.533129692077637, 15.48381519317627]
INFO: Query processing completed in 33.78s
INFO: Visualization for match 1 saved to: user_1/match_1.png
INFO: Visualization for match 2 saved to: user_1/match_2.png
INFO: Visualization for match 3 saved to: user_1/match_3.png

What happens to nuclear generation in the Low Oil and Gas Supply case?
  eia-aeo2026-slides-2-15.pdf page 14 (score 17.2): In the "Low Oil and Gas Supply" case (represented by the **yellow line**), U.S. nuclear electricity generation is projected to **increase significantly** after 
  eia-aeo2026-slides-2-15.pdf page 11 (score 15.5): In the "Low Oil and Gas Supply" case, nuclear generation (represented by the dark red segment) appears to remain largely unchanged in absolute terms compared to
  eia-aeo2026-slides-2-15.pdf page 6 (score 15.5): In the **Low Oil and Gas Supply case**, nuclear consumption (represented by the dark red/maroon segment) remains relatively stable between 2025 and 2050.

*   I
INFO: QueryProcessor: Starting process_query with query text: 'How did past Annual Energy Outlook projections of total energy consumption compare with what actually happened?' for user 1
INFO: Found top 3 matches with scores: [17.960603713989258, 17.93341064453125, 16.627437591552734]
INFO: Query processing completed in 38.12s
INFO: Visualization for match 1 saved to: user_1/match_1.png
INFO: Visualization for match 2 saved to: user_1/match_2.png
INFO: Visualization for match 3 saved to: user_1/match_3.png

How did past Annual Energy Outlook projections of total energy consumption compare with what actually happened?
  eia-aeo2026-slides-2-15.pdf page 2 (score 18.0): The image states that the EIA (U.S. Energy Information Administration) **does** compare Annual Energy Outlook (AEO) projections to what actually happened.

Spec
  eia-aeo2026-slides-2-15.pdf page 3 (score 17.9): Based on the "Total energy consumption from all sectors" chart (left side of the image):

Past Annual Energy Outlook (AEO) projections of total energy consumpti
  eia-aeo2026-slides-2-15.pdf page 7 (score 16.6): Based on the provided image, it is **not possible to directly compare past Annual Energy Outlook (AEO) projections with what actually happened.**

Here's why:


INFO: QueryProcessor: Starting process_query with query text: 'What are the characteristics of trustworthy AI?' for user 1
INFO: Found top 3 matches with scores: [14.696130752563477, 14.358141899108887, 13.47156047821045]
INFO: Query processing completed in 34.14s
INFO: Visualization for match 1 saved to: user_1/match_1.png
INFO: Visualization for match 2 saved to: user_1/match_2.png
INFO: Visualization for match 3 saved to: user_1/match_3.png

What are the characteristics of trustworthy AI?
  nist-ai-rmf-selected-pages.pdf page 8 (score 14.7): Based on the provided image, the characteristics of trustworthy AI systems include:

*   **Valid and Reliable**
*   **Safe**
*   **Secure and Resilient**
*   **
  nist-ai-rmf-selected-pages.pdf page 15 (score 14.4): Based on the provided image, the document **mentions** the "characteristics of trustworthy AI" but **does not explicitly list or define them** within this parti
  nist-ai-rmf-selected-pages.pdf page 10 (score 13.5): Based on the provided image, the characteristics of trustworthy AI are:

1.  **Safety**: Employing safety considerations during the lifecycle to prevent failure
INFO: QueryProcessor: Starting process_query with query text: 'What are the four functions of the AI RMF Core?' for user 1
INFO: Found top 3 matches with scores: [17.484535217285156, 14.83258056640625, 14.143410682678223]
INFO: Query processing completed in 31.75s
INFO: Visualization for match 1 saved to: user_1/match_1.png
INFO: Visualization for match 2 saved to: user_1/match_2.png
INFO: Visualization for match 3 saved to: user_1/match_3.png

What are the four functions of the AI RMF Core?
  nist-ai-rmf-selected-pages.pdf page 14 (score 17.5): According to the text, the four functions of the AI RMF Core are:

1.  **GOVERN**
2.  **MAP**
3.  **MEASURE**
4.  **MANAGE**
  nist-ai-rmf-selected-pages.pdf page 3 (score 14.8): The four functions of the AI RMF Core are:

1.  **GOVERN**
2.  **MAP**
3.  **MEASURE**
4.  **MANAGE**
  nist-ai-rmf-selected-pages.pdf page 6 (score 14.1): Based on the provided image and text, the four functions of the AI RMF Core are **not explicitly listed**.

The text states: "The AI RMF functions, described in
INFO: QueryProcessor: Starting process_query with query text: 'What kinds of harm can AI systems cause?' for user 1
INFO: Found top 3 matches with scores: [15.028825759887695, 14.803064346313477, 13.978117942810059]
INFO: Query processing completed in 33.61s
INFO: Visualization for match 1 saved to: user_1/match_1.png
INFO: Visualization for match 2 saved to: user_1/match_2.png
INFO: Visualization for match 3 saved to: user_1/match_3.png

What kinds of harm can AI systems cause?
  nist-ai-rmf-selected-pages.pdf page 5 (score 15.0): Based on the provided image (Fig. 1), AI systems can cause potential harms in three main categories:

1.  **Harm to People:**
    *   **Individual:** Harm to a 
  nist-ai-rmf-selected-pages.pdf page 4 (score 14.8): According to the provided text, AI systems can cause various kinds of harm, generally referred to as "potential negative impacts," "threats," or "harms."

Speci
  nist-ai-rmf-selected-pages.pdf page 9 (score 14.0): Based on the provided text, AI systems can cause harm that endangers:

*   **Human life** (specifically mentioned as "serious injury or death" in the context of
INFO: QueryProcessor: Starting process_query with query text: 'How do AI risks differ from traditional software risks?' for user 1
INFO: Found top 3 matches with scores: [17.508827209472656, 15.160322189331055, 14.054533004760742]
INFO: Query processing completed in 48.38s
INFO: Visualization for match 1 saved to: user_1/match_1.png
INFO: Visualization for match 2 saved to: user_1/match_2.png
INFO: Visualization for match 3 saved to: user_1/match_3.png

How do AI risks differ from traditional software risks?
  nist-ai-rmf-selected-pages.pdf page 19 (score 17.5): According to the provided text, AI risks differ from traditional software risks in several key ways, often being broader, more complex, and not fully addressed 
  nist-ai-rmf-selected-pages.pdf page 1 (score 15.2): Based on the provided text, AI risks differ from traditional software risks in several unique ways:

1.  **Dynamic Data Dependency:** AI systems are "trained on
  nist-ai-rmf-selected-pages.pdf page 8 (score 14.1): Based on the provided text, AI risks differ from traditional software risks primarily in their **scope, nature, and the complexity of managing them**, especiall
INFO: QueryProcessor: Starting process_query with query text: 'Who are the AI actors across the AI lifecycle?' for user 1
INFO: Found top 3 matches with scores: [13.253778457641602, 13.18555736541748, 12.761420249938965]
INFO: Query processing completed in 41.33s
INFO: Visualization for match 1 saved to: user_1/match_1.png
INFO: Visualization for match 2 saved to: user_1/match_2.png
INFO: Visualization for match 3 saved to: user_1/match_3.png

Who are the AI actors across the AI lifecycle?
  nist-ai-rmf-selected-pages.pdf page 6 (score 13.3): Based on the provided image and text:

1.  The diagram (Figure 2) itself does not explicitly list the "AI actors." Its central core, **"People and Planet,"** br
  nist-ai-rmf-selected-pages.pdf page 2 (score 13.2): According to the provided text, **AI actors** are defined by the Organisation for Economic Co-operation and Development (OECD) as:

"**those who play an active 
  nist-ai-rmf-selected-pages.pdf page 7 (score 12.8): Based on the "Representative Actors" column in the provided image (Fig. 3. AI actors across AI lifecycle stages), the AI actors across the AI lifecycle include:
INFO: QueryProcessor: Starting process_query with query text: 'What does the MEASURE function cover?' for user 1
INFO: Found top 3 matches with scores: [15.201284408569336, 12.675163269042969, 11.935125350952148]
INFO: Query processing completed in 31.80s
INFO: Visualization for match 1 saved to: user_1/match_1.png
INFO: Visualization for match 2 saved to: user_1/match_2.png
INFO: Visualization for match 3 saved to: user_1/match_3.png

What does the MEASURE function cover?
  nist-ai-rmf-selected-pages.pdf page 17 (score 15.2): The MEASURE function, as described in the provided text and Table 3, covers practices related to **measuring AI risks** and **evaluating AI systems for trustwor
  nist-ai-rmf-selected-pages.pdf page 3 (score 12.7): Based on the provided text, the **MEASURE** function is one of four specific functions (along with GOVERN, MAP, and MANAGE) that comprise the "Core" of the Fram
  nist-ai-rmf-selected-pages.pdf page 14 (score 11.9): Based on the provided image, the MEASURE function covers:

*   **Identified risks are assessed, analyzed, or tracked.**

=== 5. Saving the results for the website ===
/content/colpali_export.zip: 58.7 MB; 33 pages, 14 questions, 42 answers

4. Download the results¶

In [6]:
from google.colab import files
files.download("/content/colpali_export.zip")