Kamal Soft
Contact sales
Data pipelines and knowledge management
RAG Pipelines
RAG Pipelines2026-09-0510 min read

RAG Pipelines in Production: What We Learned Shipping 15+ Enterprise Knowledge Systems

H

Hassan Kamal

Founder, Kamal Soft

We have built RAG pipelines for a clinical wound assessment system, a legal contract review platform, a 180,000-listing automotive marketplace, and a logistics enterprise that processes 2 million documents. Each taught us something the previous one did not.

Here is an honest account of what works, what does not, and where teams consistently waste time.

Chunking Is Not an Afterthought

Every RAG system makes a chunking decision early. Most teams pick a chunk size, apply it uniformly, and move on. That is a mistake. The right chunking strategy depends on your document structure, your query patterns, and what your LLM needs to answer questions correctly.

For legal contracts, recursive character splitting with 512-token chunks and 50-token overlap preserves clause context reasonably well. For clinical notes, sentence-level chunking with metadata enrichment (patient ID, visit date, section header) performs better because clinicians ask specific questions about specific data points. For large policy documents, hierarchical chunking — section level for navigation, paragraph level for retrieval — combines the benefits of both.

Hybrid Retrieval Outperforms Pure Vector Search

Pure vector search is good at semantic similarity. BM25 (keyword search) is good at exact match. Neither alone is as good as both together. For every enterprise RAG system we build now, hybrid retrieval is the default — typically 60-70% semantic weight with 30-40% BM25 weight, tuned per use case.

The cases where this matters most: exact identifiers (contract numbers, product codes, patient IDs) where vector search can miss on specificity, and jargon-heavy domains where embeddings trained on general text have weaker semantic representations.

Re-Ranking Is Where You Recover From Retrieval Errors

Retrieval returns a candidate set. Re-ranking selects the best candidates from that set for the final context window. A cross-encoder re-ranker (Cohere Rerank or a custom fine-tuned model) consistently improves answer quality by 15-25% in our evaluations because it scores query-document relevance jointly rather than independently.

The cost tradeoff is real — re-ranking adds latency and API cost. For latency-critical applications, run retrieval + re-ranking asynchronously and stream the UI while the pipeline completes. For batch workloads, it is almost always worth it.

Evaluation Is Underinvested In

Most teams evaluate their RAG system by asking it questions manually and deciding if the answers look right. That is not evaluation — it is anecdote. A proper RAG evaluation suite measures retrieval precision and recall (are the right chunks being retrieved?), answer faithfulness (does the answer come from the retrieved context?), and answer relevance (does it actually answer the question?).

  • •RAGAS is the standard open-source evaluation framework and a reasonable starting point
  • •Build a golden dataset of 50-100 question/answer pairs specific to your domain
  • •Run evaluation on every significant change to chunking, retrieval, or generation
  • •Track metrics over time to catch accuracy drift before users notice

Query Rewriting Is Underused

Real user queries are messy. They are vague, context-dependent, poorly formed, and assume knowledge the retrieval system does not have. Query rewriting — using an LLM to reformulate the user's query before retrieval — consistently improves recall. HyDE (Hypothetical Document Embeddings), where you generate a hypothetical answer and embed that for retrieval instead of the query, is particularly effective for question-answering use cases.

The teams that ship the best RAG systems are not the ones that chose the best vector database. They are the ones that invested the most time in evaluation — building a systematic way to measure whether the system is actually working.

RAGLLMKnowledge BaseEnterprise AIVector DatabaseLangChain

Ready to build with these technologies?

Our team builds production AI systems using everything discussed in this article.

Talk to our team