When an enterprise client says "we want an AI that understands our company documents", most firms point to the ChatGPT or Claude API as the answer. That answer is a small part of the problem. The real architecture is built from questions about how 10,000 uploaded PDFs are chunked, which embedding model is chosen, the index parameters of the vector database, whether retrieval is hybrid or purely semantic, how hallucination is prevented and how results are monitored.
1. Document Ingestion Layer
A RAG system's success rate doesn't begin with model choice — it begins with how you collect documents. Sources are typically scattered: SharePoint, Google Drive, email archives, ERP attachments, scanned PDFs, legacy Word files. Writing a parser per source and converting everything into one canonical format (Markdown + metadata) simplifies every subsequent step.
2. Chunking Strategy
How you chunk a document directly determines retrieval quality and token cost. Fixed 512-token chunks often break semantic integrity. A better approach: first split on heading hierarchy (h2/h3 boundaries), prepend each chunk with the document's breadcrumb path, then sub-split long chunks via semantic similarity. The goal: every chunk reads meaningfully on its own.
3. Embedding Model Choice
Choose an embedding model by evaluating language, document type, data residency, latency and cost together. Benchmark managed and open-source models on the same representative query set, and validate any batch-inference gain on your own hardware and data volume.
4. Vector DB: Qdrant vs Pinecone vs pgvector
- pgvector: Keeps infrastructure simple for PostgreSQL teams; test capacity with your data size and query load.
- Qdrant: Open-source and self-hostable; benchmark filtering and index settings on real data.
- Pinecone: Offers managed operations; evaluate data residency, contract and cost separately.
- Weaviate / Milvus: Offer broad feature sets; account for operating effort and team skills.
5. Hybrid Search: Vector + Keyword
Pure semantic search can be weak on exact lookups such as product codes, order numbers or contract clauses. Test BM25 alongside dense retrieval and combine results with a method such as reciprocal rank fusion; measure the benefit on a representative evaluation set rather than assuming it.
6. The Re-ranking Stage
Re-score the initial candidate set with a cross-encoder such as Cohere Rerank or BGE-Reranker, then narrow the context sent to the LLM. Candidate and final-result counts are not a fixed recipe; tune them against latency, token budget and recall/precision on a representative evaluation set. Skipping re-ranking can increase the risk of plausible-looking but irrelevant context.
7. Prompt Engineering & Citation Forcing
Telling the LLM merely to use the documents is not enough; require explicit references for verifiable claims. Citations alone do not guarantee correctness, so evaluate whether each cited passage actually supports the answer.
8. Hallucination Detection & Guardrails
A production RAG system must tell users when it isn't sure. Use an NLI-based (Natural Language Inference) verifier to score whether the LLM answer is consistent with retrieved sources. Below threshold? Reject with "insufficient source" rather than answering.
9. Monitoring & Continuous Improvement
Design monitoring together with data minimisation, redaction, access control and retention. Avoid storing personal or confidential content unnecessarily; track measures such as evaluation scores, anonymised feedback and error classes. A RAG system is not static, and its representative test set should be updated regularly.
Practical outcomes cannot be selected by model name alone. Chunking, access control, retrieval, re-ranking, source verification and evaluation must be designed together, with success criteria defined before implementation.

