
Key Takeaways
RAG is most valuable when connected to a workflow and a schema.
Store page level provenance and citations from day one.
Use MongoDB Atlas Vector Search with tenant scoped filters.
Add evaluation and monitoring so quality does not drift silently.
Retrieval augmented generation (RAG) is most valuable when it is attached to a real workflow: intake, search, extraction, and decision support. This post outlines a practical architecture that pairs AWS storage and compute with MongoDB Atlas Vector Search to power grounded Q and A over documents, with auditable citations.
What teams usually get wrong about RAG
Common failure modes:
Treating RAG as a chatbot, not a workflow component
Indexing messy text without page level provenance
No evaluation plan, which makes quality feel random
No access control model, which becomes a security problem
The core requirement: citations and traceability
If a user asks "why" or "where did this come from", your system should point to:
Document ID
Page number
Bounding box or paragraph span
Extraction timestamp and model versions
That is how you keep RAG usable for operations, not just demos.
Reference architecture (AWS plus MongoDB)
Ingestion
Upload PDF to S3
Extract text using Textract or an OCR pipeline
Normalize into page chunks with stable IDs
References:
Amazon S3: https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html
AWS Textract: https://docs.aws.amazon.com/textract/latest/dg/what-is.html
Storage and indexing
Use MongoDB as the system of record:
Store chunk text and metadata
Store embeddings per chunk
Use Atlas Vector Search for kNN retrieval
References:
Atlas Vector Search docs: https://www.mongodb.com/docs/atlas/atlas-vector-search/
MongoDB schema design guide: https://www.mongodb.com/docs/manual/core/data-modeling-introduction/
Query flow
User question enters API
Retrieve top k chunks with tenant scoped filter
Assemble prompt with citations
Call LLM
Return answer plus sources
Chunking strategy that works in practice
Chunking is a product decision. Recommended baseline:
Chunk per page, then split by headings or paragraph length
Keep chunk size consistent, for example 300 to 800 tokens
Add overlap when sections run long
Metadata you should store per chunk:
tenantIddocumentIdpageNumberchunkIndexsourceType(OCR, native PDF text)hashfor dedupe
Embeddings choices
Pick an embedding model that fits your latency and cost constraints. Two practical rules:
Use one embedding model consistently so similarity scores are comparable
Re embed only when you change the model or chunking
You also need an evaluation set. See:
OpenAI Evals cookbook: https://github.com/openai/evals
Security model: tenant isolation and least privilege
At minimum:
Use per tenant filters in your vector query
Enforce authorization server side, never in the UI
Encrypt documents at rest, and use private networking where possible
References:
AWS shared responsibility model: https://aws.amazon.com/compliance/shared-responsibility-model/
OWASP Top 10: https://owasp.org/www-project-top-ten/
Evaluation: make RAG measurable
Add simple, repeatable tests:
Retrieval quality: does the correct page appear in top k
Groundedness: do answers cite retrieved chunks
Task success: did a user reach the next workflow step
Useful overview:
RAG evaluation survey paper (Stanford): https://arxiv.org/abs/2308.15062
Where Lid Vizion fits
We typically help teams:
Build ingestion pipelines on AWS
Store structured outputs and workflow state in MongoDB
Add RAG safely, with citations and tenant scoped retrieval
zation in the API layer for every request.
FAQs
Q: Can we do RAG without embeddings? You can start with keyword search, but embeddings usually improve semantic matching. Many teams use both, keyword search for precision and vector for recall.
Q: Does Vector Search replace a full search product? Not always. Atlas Search provides rich filtering and ranking. Vector Search can be combined with it for hybrid retrieval.
Q: How do we avoid leaking data across tenants? Enforce tenant filtering inside the database query, and validate authori
Q: What should we link to internally? A: Link to relevant solution pages like Computer Vision or Document Intelligence, and only link to published blog URLs on the main domain. Avoid staging links.