July 27, 202612 min read

ENGINEERING CASE STUDY: BUILDING A SUB-100MS HYBRID VECTOR-GRAPH RETRIEVAL ENGINE FOR ENTERPRISE DATA

Muhammad Talha Sultan

Lead Engineer, Innvo Labs

When enterprise software systems scale, data is rarely stored in a single uniform format. Organizations operate across unstructured contract PDFs, structured SQL tables, and complex entity relationship charts detailing corporate hierarchies, transaction histories, and compliance rules.

When an enterprise client approached Innvo Labs to build an AI decision-support platform over 2.5 million financial compliance documents, early baseline tests with standard vector search (RAG) fell short. While vector search correctly identified semantically similar paragraphs, it was blind to multi-hop entity relations—such as identifying whether a subsidiary company shared beneficial ownership with a flagged entity listed five corporate layers away.

To solve this, we engineered a unified **Hybrid Vector-Graph Retrieval Engine (GraphRAG)** that executes simultaneous dense vector retrieval and graph traversal, returning combined contexts in under 85ms (p95).

Here is the complete engineering case study of how we architected, benchmarked, and deployed the system.

1. The Bottleneck of Vector-Only RAG

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).

2. Architectural Pipeline & Query Execution

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.

3. Database Indexing & Latency 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.

4. Production Results & Benchmarks

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 Takeaways

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.

05 / Contact

LET'S TALK

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.