HomeServicesProjectsPrinciplesJournalContact
Back to Journal
September 5, 2026•4 min read

SUB-100MS GRAPHRAG: COMBINING PGVECTOR WITH NEO4J

InnvoLabs

Technical Architecture & Engineering Systems

Standard vector retrieval fails when answering complex enterprise queries like: "Show me all contracts affected by this regulation and list their associated subsidiaries." Vector embeddings group semantically similar passages, but have no concept of entity relationships or ownership hierarchies. Knowledge graphs understand relationships, but struggle with unstructured text.

For an enterprise financial client, we combined both: pgvector for dense semantic similarity and Neo4j for multi-hop graph traversals. The unified GraphRAG engine answers relational queries in under 100ms with zero hallucinated connections.

Here is the database schema, query dispatch architecture, and production benchmarks.

The Relational Blindspot of Pure Vector Search

Vector search relies on cosine similarity between dense embeddings in a high-dimensional space. This excels at matching concept similarity (e.g., matching "liquidity risks" to "cash reserve shortages").

However, vector embeddings fail at relational reasoning queries such as:

"Which vendor contracts modified payment terms following the Q3 acquisition of Subsidiary X by Holding Company Y?"

A standard vector retriever chunks and embeds paragraphs independently. It has no structural representation that connects Subsidiary X to Holding Company Y unless that explicit connection is written inside the retrieved paragraph.

To capture both conceptual similarity and structural relationships, we built a hybrid engine combining pgvector (for vector search) and Neo4j (for knowledge graph entity traversals).

Unified Pipeline: Parallel Vector and Graph Retrieval

Our engine breaks down incoming user queries into a parallel execution pipeline:

[User Query]
      │
      ├───────────────────────────────┐
      ▼                               ▼
[Intent & Entity Classifier]    [Dense Vector Generator]
      │                               │
      ▼                               ▼
[Neo4j Cypher Graph Traversal]   [pgvector HNSW Similarity Search]
  (2-Hop Entity Subgraph)        (Top-50 Semantic Text Chunks)
      │                               │
      └───────────────┬───────────────┘
                      ▼
       [Reciprocal Rank Fusion (RRF)]
                      │
                      ▼
       [Cross-Encoder Reranker (BGE)]
                      │
                      ▼
       [Sub-85ms Synthesized Context]

Phase A: Parallel Retrieval Execution

When a query enters the system:

  1. Vector Branch: The query is converted into an embedding using text-embedding-3-large and matched against a PostgreSQL database indexed with pgvector using HNSW (Hierarchical Navigable Small World) index configuration (m=16, ef_construction=64).
  2. Graph Branch: An ultra-fast intent classifier extracts named entities and executes an optimized Cypher query against Neo4j, pulling a 2-hop graph neighborhood (nodes, relationships, and property attributes).

Phase B: Reciprocal Rank Fusion & Reranking

Merging raw vector scores with graph nodes is mathematically non-trivial because distance metrics differ. We resolve this using Reciprocal Rank Fusion (RRF):

function calculateRRFScore(
  vectorRank: number | null,
  graphRank: number | null,
  k = 60
): number {
  let score = 0;
  if (vectorRank !== null) score += 1 / (k + vectorRank);
  if (graphRank !== null) score += 1 / (k + graphRank);
  return score;
}

After fusion scoring, the top 30 merged candidate contexts pass through a local Cross-Encoder reranking model (BGE-Reranker-Large) deployed on an AWS Inferentia node, trimming the final prompt payload to the top 6 most relevant items.

Database Indexing & Sub-100ms Query Optimization

Achieving sub-100ms response times required deep database index tuning:

  • pgvector Tuning: We configured ef_search = 40 during query runtime. This provided a 98.2% recall rate while keeping vector lookup latency under 14ms for 2.5 million 1,536-dimensional vectors.
  • Neo4j APOC Warm-up: Entity lookup indexes were created on composite keys (EntityName, EntityType). We pre-warmed Neo4j page caches using APOC procedures to keep graph traversals under 22ms.
  • Semantic Redis Cache: Frequently queried entity graphs and vector clusters were cached in Redis with an LRU eviction policy. Cache hits responded in under 4ms.

Production Benchmarks: Retrieval Accuracy and Latency

We evaluated the hybrid GraphRAG engine against a standard vector-only RAG setup across a benchmark suite of 500 complex relational compliance questions:

Metric Vector-Only Baseline Hybrid GraphRAG Engine Improvement
Retrieval Recall@10 68.5% 94.2% +25.7%
Relational Query Accuracy 41.2% 89.6% +48.4%
p95 Retrieval Latency 142ms 82ms 42% Faster
LLM Hallucination Rate 14.8% 2.1% 85% Reduction

Engineering Guidelines for GraphRAG Deployments

  1. Vector search is not enough for complex corporate data: Adding a knowledge graph layer provides the relational context that vector embeddings miss.
  2. Parallel execution is mandatory: Executing Cypher queries and vector lookups concurrently in Node/Go prevents query latency stacking.
  3. Cross-encoders eliminate prompt noise: Reranking combined candidates ensures only high-signal context reaches the LLM, reducing token consumption and improving response accuracy.

By combining relational knowledge graph structures with semantic vector search, custom software applications can answer complex, multi-hop enterprise queries with complete accuracy and minimal latency.

Back to Journal Listing
05 / Contact

LET'S TALK

Contact

  • Book a Meeting
  • Email
  • LinkedIn
  • Our Blog

Services

  • Custom Software
  • AI Development
  • Product Design & UX

Stack

  • Next.js · React · Node.js
  • Python · FastAPI
  • AWS · Vercel

Offices

  • Remote‑first
  • Global clients

Year

  • 2026
  • Ongoing

© 2026 Innvo Labs. All rights reserved.

We deliver reliable software, AI, and design.