Back to Insights
// // insight

Enterprise RAG Architecture Blueprint: Ingestion Pipelines, Vector Sizing, Token Cost Controls, and Implement…

Enterprise RAG architecture routes enterprise documents through an ETL parsing pipeline into a hybrid search index—combining dense vector embeddings with sparse text search. A cross-encoder reranker filters top candidates before delivering enriched context to an LLM under strict token budget controls, prompt caching layers, and database-level role-based access controls (RBAC).

Published September 10, 2026 · Reviewed by the NextGen engineering team

Enterprise RAG (Retrieval-Augmented Generation) architecture routes enterprise documents through an ETL parsing pipeline into a hybrid search index—combining dense vector embeddings with sparse text search. A cross-encoder reranker filters top candidates before delivering enriched context to an LLM under strict token budget controls, prompt caching layers, and database-level role-based access controls (RBAC).

The Production Enterprise RAG Topology

A naive RAG script takes a PDF, calls an embedding API, pushes vectors into a free-tier database, and dumps the top five chunks into a system prompt. That pattern fails in production within two weeks due to authorization leaks, slow response times, hallucinated answers from outdated document chunks, and runaway API bills.

Production enterprise RAG requires a four-tier architecture designed for continuous sync, predictable latency, and granular access control:

[ Data Sources ] -> [ Ingestion & Parsing ] -> [ Hybrid Indexing ] -> [ Retrieval & Rerank ] -> [ LLM Inference ]
  Confluence           Unstructured / Docling    Qdrant / pgvector       Cohere / BGE            Claude / OpenAI
  SharePoint           Semantic Chunking         BM25 / SPLADE           Metadata RBAC           Prompt Caching
  Postgres / S3        Token Counter             HNSW Vectors            Reciprocal Rank Fusion  Guardrails
  1. Ingestion & Parsing Tier: Extract text, tables, and image metadata from unstructured files. Apply document-level security attributes during parsing, chunk the text logically, and emit chunk-level payload packets.
  2. Indexing & Storage Tier: Persist raw text, structured metadata, and vector embeddings. Run dense vector indexes alongside sparse lexical indexes for key-value and exact phrase matching.
  3. Retrieval & Reranking Tier: Intercept user queries, check caller identity against metadata security filters, run parallel dense/sparse queries, merge candidates via Reciprocal Rank Fusion (RRF), and score relevance with a cross-encoder model.
  4. Orchestration & Inference Tier: Assemble final system prompts, apply cached tokens, enforce maximum context limits, call the target LLM, and stream sanitized outputs through response guardrails.

Building this infrastructure reliably requires specialized technical execution. Engineering leaders frequently engage our custom AI development services to design and ship these backend pipelines without pulling internal product teams off core roadmaps.

Vector Database Sizing and Memory Calculations

Vector databases store dense embeddings as floating-point arrays. Storing millions of vectors in memory without calculating operational overhead leads to server out-of-memory crashes or unexpected cloud infrastructure charges.

To size a vector node accurately, calculate raw vector memory, add index overhead (such as Hierarchical Navigable Small World, or HNSW), and multiply by your replication and safety margin factors.

Vector Memory Formula

Total RAM = (Number of Vectors * Dimensions * 4 bytes) * Index Overhead Factor * Safety Multiplier

Where:

  • Number of Vectors: Total document chunks indexed.
  • Dimensions: Model output length (1,536 for text-embedding-3-small, 3,072 for text-embedding-3-large).
  • 4 bytes: Standard 32-bit floating-point representation (fp32). If using half-precision (fp16) or scalar quantization (int8), this drops to 2 bytes or 1 byte.
  • Index Overhead Factor: HNSW graphs require additional memory to maintain node links. Use 1.25 for standard configurations (M=16, ef_construction=200).
  • Safety Multiplier: Reserve headroom for system process memory, query execution buffers, and continuous ingestion inserts. Use 1.50.

Real-World Memory Sizing Example

For an enterprise dataset yielding 10 million document chunks using text-embedding-3-large (3,072 dimensions) without quantization:

  • Raw Float32 Data: 10,000,000 * 3,072 * 4 bytes = 122.88 GB
  • With HNSW Index Overhead (1.25x): 122.88 GB * 1.25 = 153.60 GB
  • Total Node RAM Target (1.50x multiplier): 153.60 GB * 1.50 = 230.40 GB RAM

Applying Scalar Quantization (int8) reduces raw vector memory by 75% down to 30.72 GB, bringing total system RAM requirements down to ~57.6 GB with minimal retrieval accuracy loss.

Vector DatabaseHosting TopologyScaling ModelRBAC & Multi-Tenancy SupportRecommended Production Use
QdrantSelf-hosted / CloudHorizontally sharded clustersPayload tenant key filteringHigh-throughput, low-latency custom RAG
pgvectorSelf-hosted / Managed RDSVertical / Read replicasNative Postgres Row-Level Security (RLS)Existing Postgres footprints under 5M vectors
PineconeServerless CloudAutomatic horizontal scalingNamespace & metadata filteringZero-ops infrastructure with variable load
MilvusDistributed KubernetesMicroservice shardingOrganization & collection partitioningMassive enterprise datasets (>50M vectors)

Ingestion Pipelines and Access Control (RBAC)

Ingestion is an ETL job that runs continuously as source files change. File parsers must extract embedded tables, headers, and code snippets rather than stripping documents to flat ASCII text.

Document Added -> Read Permissions -> Parse Structure -> Chunk Content -> Generate Vector -> Write Payload
  (SharePoint)     (Group IDs)        (Docling/Tables)   (512 Tokens)    (Embeddings API)   (Vector DB + Meta)

Chunking Strategies

  • Fixed-size chunking: Splitting by raw token counts (e.g., 512 tokens with 64-token overlap) is fast but breaks code blocks, bullet points, and table structures across arbitrary boundaries.
  • Semantic structural chunking: Splitting by Markdown headers (H1, H2, H3), HTML section tags, or paragraph breaks preserves logical context. Tables should be serialized into Markdown or JSON strings before embedding so row context remains intact.

Security and RBAC Metadata

Vector databases do not know who is running a query. If user A searches for salary benchmarks, the vector DB returns the closest mathematical vectors—even if those vectors came from executive compensation files.

Security must be enforced at the query execution level using metadata payload filters. During ingestion, extract access control lists (ACLs) directly from the source system and attach them as array metadata on every chunk:

{
  "chunk_id": "doc_9921_chunk_04",
  "document_id": "doc_9921",
  "source_url": "https://sharepoint.internal/hr/comp-2025.pdf",
  "text": "Executive engineering bands start at Level 7...",
  "tenant_id": "org_enterprise_01",
  "allowed_roles": ["hr_admin", "executive_board"],
  "allowed_users": ["user_8832", "user_1029"]
}

When execution engines process a query, they append compulsory filtering clauses matching the caller’s verified JWT payload:

-- Conceptual payload query in Qdrant/pgvector
tenant_id == "org_enterprise_01" AND (
  allowed_roles IN ["engineering_lead"] OR 
  allowed_users IN ["user_4012"]
)

Filtering must happen inside the vector index lookup (pre-filtering), not after vector results return (post-filtering). Post-filtering leads to empty result sets if top-K matches belong to unauthorized documents.

Hybrid Retrieval and Reranking Mechanics

Vector distance metrics (cosine similarity, dot product) search for broad semantic meaning. They perform poorly when users search for specific error codes (ERR_502_BAD_GATEWAY), part numbers (SKU-992-B), or internal product names.

Production systems solve this by combining dense vector search with sparse lexical search (BM25) and passing combined candidates through a reranking cross-encoder.

Reciprocal Rank Fusion (RRF)

RRF combines dense and sparse candidate lists into a single ranked list without requiring score normalization.

RRF_Score(d) = (1 / (60 + Dense_Rank(d))) + (1 / (60 + Sparse_Rank(d)))

Reranking Latency and Accuracy Math

Passing 50 candidate chunks into an LLM context window creates noise and wastes tokens. A cross-encoder model accepts (Query, Chunk) pairs and calculates deep semantic alignment.

  • Step 1: Retrieve Top-50 vector candidates and Top-50 BM25 candidates. Total: ~80 unique document chunks. (Latency: 15–30ms)
  • Step 2: Combine via RRF and select the top 30 candidates.
  • Step 3: Pass 30 candidates into a lightweight cross-encoder (bge-reranker-large or Cohere Rerank API). (Latency: 60–120ms)
  • Step 4: Send the top 5 reranked chunks to the LLM context prompt.

Adding 100ms of reranking latency saves 1,000 to 4,000 unnecessary context tokens per call while eliminating off-target context chunk pollution.

Token Cost Controls and Prompt Caching

Context windows have expanded to over one million tokens, but filling large context windows on every query is slow and expensive.

Request 1: [ System Prompt + 10k Docs Context ] + User Query 1 -> Standard Prompt Cost
Request 2: [ System Prompt + 10k Docs Context ] + User Query 2 -> 90% Discounted (Cached)

Context Window Cost Scaling

Operations StrategyPrompt Tokens per QueryDaily Query VolumeMonthly Token Cost (Anthropic Claude 3.5 Sonnet)
Unoptimized Naive RAG (20 chunks, no reranking, no caching)12,000 tokens10,000 queries/day$1,080.00 / day ($32,400 / month)
Reranked RAG (5 top chunks via cross-encoder)3,000 tokens10,000 queries/day$270.00 / day ($8,100 / month)
Reranked + Prompt Caching (Static instructions + shared knowledge base chunks cached)3,000 tokens (300 uncached, 2,700 cached)10,000 queries/day$40.50 / day ($1,215 / month)

Engineering Token Optimization Controls

  1. System Prompt & Context Caching: Place static instruction blocks, output schemas, and base document contexts at the beginning of API requests. Anthropic and OpenAI offer up to 90% cost discounts on prompt cache hits when prefixes exceed threshold lengths (1,024 tokens for Claude).
  2. Context Pruning and Trimming: Strip unnecessary whitespace, remove HTML tag attributes, and run context compressors to eliminate low-information phrases prior to prompt injection.
  3. Hard Ceiling Guardrails: Set strict token upper limits programmatically based on user query intent. Simple lookup queries do not require multi-chunk context payloads.

Engineering teams migrating legacy RAG deployments to modern production setups often pair vector optimizations with custom application builds. Take a look at our specialized LLM development services to review how we design low-latency prompt pipelines and implement cost control guardrails.

Implementation Math: Timelines, Team Staffing, and Budget Breakdown ($120k–$500k)

Building a production-ready enterprise RAG platform involves infrastructure engineering, ETL pipelines, security integration, vector tuning, and evaluation frameworks.

Phase 1: ETL & Security (Weeks 1-6)    -> Data connectors, parsing pipelines, RBAC tags
Phase 2: Retrieval Engine (Weeks 5-12)  -> Vector DB, hybrid search, rerankers, evaluation
Phase 3: LLM Integration (Weeks 9-18)   -> Prompt routing, caching, guardrails, orchestration
Phase 4: Hardening & Scale (Weeks 15-24) -> Load testing, monitoring, deployment pipelines

Cost Tier Breakdown

Tier 1: Core Departmental RAG System ($120,000 – $180,000)

  • Scope: 1–3 static internal data sources (e.g., Confluence, Notion, local S3 PDF buckets).
  • Users/Scale: Single internal department (~200 users), simple RBAC filters.
  • Timeline: 10 to 12 weeks.
  • Stack: Managed vector database (Pinecone/Qdrant Cloud), hybrid search, open-source reranker, commercial LLM APIs.

Tier 2: Multi-Tenant Enterprise Application ($220,000 – $350,000)

  • Scope: Real-time bi-directional sync with enterprise SaaS sources (Salesforce, SharePoint, Google Drive, SQL DBs).
  • Users/Scale: Multi-tenant customer application or enterprise-wide deployment (1,000+ users).
  • Timeline: 14 to 18 weeks.
  • Stack: Self-hosted/Dedicated vector clusters (Qdrant/pgvector on AWS EKS), custom document parsing services, automated evaluation suites (Ragas/TruLens), active prompt caching infrastructure.

Tier 3: High-Throughput / Compliance-Heavy RAG Platform ($350,000 – $500,000)

  • Scope: On-premises or VPC isolated installation, strict SOC2/HIPAA compliance, strict latency SLAs (<500ms total roundtrip), dynamic context routing, multi-model failover.
  • Users/Scale: High query volume (>100k daily queries), multi-region active-active database replication.
  • Timeline: 20 to 24 weeks.
  • Stack: Dedicated Kubernetes clusters, self-hosted open-source cross-encoders, fine-tuned domain embeddings, air-gapped LLM deployments (vLLM on H100/A10G nodes).

Recommended Staffing Ratio (16-Week Mid-Tier Build)

  • Lead Architect / Systems Lead (1.0 FTE): End-to-end topology, security model, RBAC mapping, vector DB schema design.
  • Senior AI/ML Engineer (1.0 FTE): Embedding model selection, hybrid retrieval tuning, cross-encoder integration, evaluation framework setup.
  • Senior Data/ETL Engineer (1.0 FTE): Source platform connectors, document parsing pipelines, incremental update syncs, vector database payload writing.
  • Full-Stack Developer (0.5 FTE): Chat UI components, source document attribution linking, system admin control panel.

What This Means for Your Team

Enterprise RAG is a systems engineering problem, not a prompt engineering trick. Text extraction quality, vector database index sizing, RBAC metadata filtering, and retrieval reranking dictate performance far more than choice of base LLM.

Before writing code or provisioning vector infrastructure:

  1. Audit document formats: Identify whether target documents are clean text or table-heavy PDFs requiring visual document layout parsers.
  2. Define data authorization rules: Map corporate identity groups to document metadata before choosing a vector database.
  3. Run database size projections: Compute RAM targets using dimensional floating-point formulas to avoid under-provisioning hardware.
  4. Establish hybrid retrieval pipelines: Budget for lexical search (BM25) and cross-encoder reranking from day one to deliver acceptable context precision.

If you are planning an enterprise RAG build or fixing an unstable internal prototype, contact our engineering team directly. We will review your architecture, evaluate your retrieval pipeline data, and lay out an execution timeline tailored to your infrastructure.

More answers in Insights or see AI development services.

// let's build something

Start your project request

Tell us what you're building — engineering capacity, AI, QA, cloud, or a fixed-scope software engagement. Our NYC team responds within one business day.

// what to expect
  • Response within 1 business day
  • 30-minute discovery conversation
  • Recommended engagement model & pricing
  • NYC-focused — in-person available
Start Project Request

Inbound sales only. All form information is encrypted in transit.