Notes
All notes

PageIndex and Vectorless RAG (AI Engg #17)

Your RAG answers “what does section 4.2 say about refunds?” with a paragraph from section 7 — same words, wrong meaning. The embeddings matched, the answer did not. That is the failure VectifyAI’s PageIndex was built for: an open-source, vectorless, reasoning-based document index that throws away chunk-embed-search and lets an LLM read a document the way a human analyst does — through a table of contents, deciding where to look. It works with any LLM, including Google’s Gemini.

This chapter is the seventeenth part of the AI Engineering course. It covers why similarity is not relevance, how PageIndex builds a hierarchical tree index, the reasoning loop at query time, what changes operationally versus the vector pipeline from Chapter 10, and when to reach for it. Sources: the PageIndex GitHub (VectifyAI), docs at docs.pageindex.ai, the pageindex.ai blog, and the 2026 community write-ups and benchmarks.

The wound: similarity is not relevance

Chapter 10 built the vector pipeline: chunk → embed → cosine search → rerank → generate. It works until the corpus is long, structured, and domain-specific — contracts, handbooks, financial filings — where:

\[ \text{high cosine}(q, d) \;\not\!\!\implies\; d \text{ answers } q \]

PageIndex flips the framing: the document gets a structural tree, the LLM picks which nodes to read, and the answer comes from reasoning over structure — not from nearest neighbours.

\begin{tikzpicture}[font=\rmfamily, >=stealth,
  b/.style={draw, thick, rounded corners=4pt, minimum width=2.2cm, minimum height=0.68cm, font=\rmfamily\small, align=center},
  a/.style={->, thick}]
  \node[b, fill=blue!10] (c) at (-3.3,0) {chunk + embed};
  \node[b, fill=blue!10] (s) at (-1.1,0) {cosine top-$k$};
  \node[b, fill=red!12] (w) at (1.1,0) {wrong section};
  \node[b, fill=orange!16] (t) at (3.3,0) {tree + reason};
  \node[b, fill=green!14] (r) at (5.5,0) {right section};
  \draw[a] (c) -- (s); \draw[a] (s) -- (w);
  \draw[a] (t) -- (r);
  \node[font=\rmfamily\small, text=black!60, anchor=north] at (-2.2,-0.55) {vector RAG};
  \node[font=\rmfamily\small, text=black!60, anchor=north] at (4.4,-0.55) {PageIndex};
\end{tikzpicture}

What PageIndex is

PageIndex is a document index for reasoning-based RAG. At ingest it does not embed anything. Instead it asks an LLM to analyse the document’s structure and generate a hierarchical tree: document → sections → subsections/pages, where each node carries a title, a page range (start_index, end_index), and a short summary. Think of it as an AI-generated table of contents with pointers into the raw text.

At query time there is no similarity search. The answering model is shown node summaries and titles, reasons about which nodes could answer the question, reads the shortlisted nodes’ full text, and iterates — expanding down the tree — until it can answer with citations.

\begin{tikzpicture}[font=\rmfamily, >=stealth,
  b/.style={draw, thick, rounded corners=3pt, minimum width=2.0cm, minimum height=0.62cm, font=\small\ttfamily, align=center},
  a/.style={->, thick}]
  \node[b, fill=blue!10] (d) at (0,0) {doc: handbook};
  \node[b, fill=orange!14] (s1) at (-2.4,-1.3) {sec 4: refunds};
  \node[b, fill=orange!14] (s2) at (0,-1.3) {sec 5: shipping};
  \node[b, fill=orange!14] (s3) at (2.4,-1.3) {sec 7: exclusions};
  \node[b, fill=green!12] (p1) at (-2.4,-2.6) {4.2: how to claim};
  \draw[a] (d) -- (s1); \draw[a] (d) -- (s2); \draw[a] (d) -- (s3);
  \draw[a] (s1) -- (p1);
  \node[font=\rmfamily\small, text=black!60, anchor=north] at (0,-3.2) {each node: title + summary + page range};
\end{tikzpicture}

The loop is agentic under the hood: the model controls its own retrieval — pick nodes, read, decide whether to expand deeper or answer. Releases even parallelise it: node summaries are generated concurrently and tree expansion proposes waves of nodes at once.

Index time vs query time

The pipeline from Chapter 10 changes shape completely:

# shape of the index: a tree of nodes, not a matrix of vectors
tree = {
    "title": "Refund handbook",
    "summary": "Policies, procedures, exclusions...",
    "start_index": 0, "end_index": 412,
    "children": [
        {"title": "4. Refunds", "summary": "Eligibility and process",
         "start_index": 120, "end_index": 230, "children": [
            {"title": "4.2 How to claim", "summary": "Form, timeline, payout",
             "start_index": 180, "end_index": 210, "children": []}]},
    ],
}

# shape of a query: reason over summaries, then read (pseudo-SDK)
def answer(question, tree, llm):
    shortlist = llm.pick_nodes(question, tree)   # returns node IDs
    context = [read(node) for node in shortlist]  # full text, not chunks
    while llm.wants_more(question, context):
        shortlist = llm.expand(question, context, tree)
        context += [read(node) for node in shortlist]
    return llm.answer(question, context)          # with node citations

Production details (from the docs and cookbooks): keep the raw text addressable by node range so citations resolve; log the picked node IDs per query (show_process / events in the docs) because the retrieval trace is your debuggability; version the tree with the document, since a re-parse after edits changes node boundaries.

Why it wins on structured documents

Three properties, each a direct answer to a vector-RAG pain:

The price: where the costs moved

Nothing is free; PageIndex trades one set of bills for another:

\[ \text{vector RAG: cheap index, cheap lookup, weak relevance} \iff \text{PageIndex: costly index, reasoning lookup, strong relevance} \]

Mitigations from the ecosystem: parse with a small/cheap model (summaries do not need a frontier reasoner), answer with the strong one; expand nodes in parallel waves; keep a hybrid — PageIndex for the long documents, vectors for the wide tail.

Where it fits beside vector RAG

PageIndex does not delete Chapter 10; it gives the router from Chapter 5 a second index to choose:

# route by query shape: completeness/structure -> tree, fuzzy lookup -> vectors
def retrieve(question, page_index, vector_index):
    if wants_all_clauses(question) or is_long_structured(question):
        return page_index.reasoned_search(question)   # tree walk + citations
    return vector_index.top_k(question, k=5)          # ANN lookup as before

What this means for an AI engineer

The durable lessons outlive any single framework:

Pitfalls

QQuestionSelf-check

What does PageIndex store instead of vectors, and how does a query get answered? When would you choose it over vector RAG?

ASolution

PageIndex stores a hierarchical tree — titles, summaries, and page ranges per node — built by an LLM at ingest, with no embeddings or vector database. At query time the model reasons over node summaries, shortlists node IDs, reads their full text, optionally expands deeper, and answers with node citations. Choose it for long structured documents and completeness questions where similarity fails; keep vectors (or a hybrid) for massive corpora, fuzzy lookup, and tight latency budgets.

Next: DeepSeek’s Papers and Playbook (AI Engg #18) — what the DeepSeek papers changed about training, inference cost, and open-weights strategy.