[Code Review] Production-Grade RAG Assistant: Hybrid Search, RRF, Parent-Child Chunking, and Promptfoo Evals (Python/FastAPI/Postgres)

Reddit r/AI_Agents Tools

Summary

A developer shares a production-grade RAG assistant built with Python/FastAPI featuring hybrid retrieval (pgvector + Postgres FTS fused via RRF), parent-child chunking, cross-encoder reranking, and Promptfoo-based evals, and is seeking code review and architecture feedback.

Hi everyone, I recently built an end-to-end Enterprise RAG Assistant in Python/FastAPI aimed at answering grounded questions over complex, multi-page financial filings (10-Ks) and legal contracts. I’ve set up a full hybrid retrieval and evaluation pipeline, but I’d love to get a fresh pair of eyes on the architecture and codebase to see where I can improve it. GitHub Repo: [link in comments] Key Architecture Highlights: Ingestion & Parsing: Table-aware parsing using pdfplumber (reconstructs fragmented multi-column PDF tables). Retrieval Pipeline: Parent-child chunking (~200 token children, ~700 token parents) + Hybrid search (Dense pgvector + Sparse Postgres full-text search) fused via Reciprocal Rank Fusion (RRF) and re-ranked with a cross-encoder (bge-reranker-base). Guaranteed Ranking Slots: Implemented custom guaranteed slots (RERANK_GUARANTEED_PER_LIST) to prevent cross-encoders from under-scoring short text fragments like signature lines or table rows. Evals: Automated no-LLM retrieval eval script (Recall@K, MRR) + Promptfoo end-to-end testing suite (20 assertions checking context-faithfulness and numeric precision). Guardrails: Multi-tenant isolation (X-Tenant-ID), PII redaction, and citation/numeric output guards. Specific Feedback I'm Looking For: Cross-Encoder Latency & Optimization: How would you optimize or scale the cross-encoder step for higher concurrent load? Table Extraction Edge Cases: Are there cleaner patterns or libraries you’ve used for split-table reconstruction without cluttering the token budget? Python / FastAPI Code Organization: Any feedback on code structure, async execution, or configuration patterns in backend/app/ would be super helpful. Thanks in advance for taking a look! Feedback on PRs or issues directly on GitHub is also very welcome.
Original Article

Similar Articles

Building a RAG Pipeline for Semantic Code Search

Lobsters Hottest

JetBrains developers share field notes on building a production-grade RAG pipeline for semantic code search (Air Context), covering parsing, chunking, and vectorization as Part 1 of a series aimed at giving LLM coding agents precise, citable evidence from large codebases.

Production Grade RAG pipeline That Admits "I Don't Know"

Reddit r/ArtificialInteligence

介绍如何用 Postgres + pgvector、FastAPI、Gemini、Celery 和 Redis 构建生产级 RAG 流水线:答案引用来源、在不知道时拒绝回答,并在数据库层面强制执行行级安全。