Skip to main content

Overview

PageIndex RAG is a cloud-based retrieval architecture that delegates document indexing and retrieval to PageIndex’s managed API service. Instead of maintaining local embeddings and vector databases, you upload documents to PageIndex and query them via API. This approach offers:
  • No local vector database: PageIndex manages all indexing and storage
  • Simplified architecture: Focus on prompts and answer generation, not retrieval infrastructure
  • Advanced retrieval features: Access to PageIndex’s “thinking” mode for deeper search
  • Async retrieval: Submit queries and poll for completion

How It Works

Pipeline Steps

  1. Submit Query: Send query to PageIndex API with document ID
  2. Async Retrieval: PageIndex processes the query asynchronously
  3. Poll for Completion: Wait for retrieval to complete (typically 2-5 seconds)
  4. Extract Contexts: Parse retrieved nodes and relevant content snippets
  5. Answer Generation: Use OpenAI LLM to generate answer from PageIndex context
PageIndex uses an asynchronous retrieval model. You submit a query, receive a retrieval_id, and poll until the retrieval completes. The default timeout is 120 seconds with 2-second polling intervals.

Key Features

  • Managed service: No vector database maintenance or embedding management
  • Async retrieval: Non-blocking query submission with polling
  • Structured results: Retrieval returns hierarchical nodes with relevance-ranked snippets
  • Thinking mode: Optional deeper retrieval for complex queries
  • No embedding costs: PageIndex handles all embedding and search internally
  • Cloud-first: Built for cloud-native, distributed applications

Implementation Details

Environment Configuration

Client Initialization

Core Processing Function

Async Retrieval with Polling

Context Extraction from PageIndex Results

Usage with query_for_evaluation()

Return Structure

When to Use This Approach

Best For

  • Rapid prototyping: Skip vector database setup and focus on prompts
  • Cloud-native applications: Built for distributed, serverless architectures
  • Dynamic documents: PageIndex handles re-indexing when documents change
  • Multiple document sets: Easily switch between different doc_ids
  • Managed infrastructure: Prefer API-first over self-hosted databases
  • Advanced retrieval: Access to PageIndex’s proprietary retrieval algorithms

Advantages Over Local Vector Stores

  • No infrastructure: No ChromaDB, Pinecone, or vector database to maintain
  • No embedding costs: PageIndex handles embeddings internally
  • Automatic updates: Re-index documents without managing embeddings
  • Scalability: PageIndex scales retrieval infrastructure automatically
  • Advanced features: Access to “thinking” mode and future PageIndex capabilities

Limitations

  • External dependency: Requires internet connection and PageIndex service availability
  • API latency: Network round-trips add ~1-2 seconds vs. local retrieval
  • Cost model: Pay per query (vs. one-time embedding cost for local)
  • Less control: Cannot customize retrieval algorithms or embedding models
  • Data privacy: Documents stored on PageIndex’s servers (check compliance requirements)
PageIndex stores your documents on their servers for indexing and retrieval. Ensure this meets your data privacy and compliance requirements before using for sensitive medical or personal data.

Performance Characteristics

Speed

  • Query submission: ~0.1-0.3 seconds
  • PageIndex retrieval: ~2-5 seconds (async processing)
  • Polling overhead: ~0-2 seconds (depends on timing)
  • Answer generation: ~1-2 seconds (OpenAI LLM)
  • Total: ~4-8 seconds (higher latency than local methods)

Cost

  • PageIndex API: Varies by plan (check PageIndex pricing)
  • No embedding costs: Included in PageIndex API
  • OpenAI LLM: ~$0.002-0.005 per query (same as other methods)
  • Total: PageIndex cost + LLM cost

Quality

  • Retrieval quality: Depends on PageIndex’s algorithms (proprietary)
  • Comparable to semantic search: Generally good for well-structured documents
  • Thinking mode: May improve complex queries (experimental)
  • Context structure: Hierarchical nodes with relevance-ranked snippets

PageIndex Thinking Mode

PageIndex offers an optional “thinking” mode for deeper retrieval:
Thinking mode may take longer (5-10 seconds) but can provide more comprehensive retrieval for complex, multi-faceted queries. Use it when retrieval quality is more important than speed.

Error Handling

The implementation includes robust error handling:

Comparison with Other Architectures

Multi-Document Support

PageIndex makes it easy to query different document sets:

Document Upload and Management

While retrieval is handled via this code, document upload is done separately:
See PageIndex documentation for document upload details.

Metrics and Observability

The implementation tracks detailed metrics:
Cost tracking includes only LLM costs. PageIndex API costs are billed separately through your PageIndex account.

Source Files

  • Implementation: ~/workspace/source/src/rag/pageindex.py:142-206
  • Async polling: ~/workspace/source/src/rag/pageindex.py:75-96
  • Context extraction: ~/workspace/source/src/rag/pageindex.py:99-129
  • Evaluation interface: ~/workspace/source/src/rag/pageindex.py:209-288