MS-RAGS(ALL-IN-ONE) Docs

Component Selection Map

Build the pipeline in this order. Do not start with the fanciest option. Start with the simplest working configuration, test real questions, then add stronger components only where the failure is visible.

1

Model

Choose the LLM that can fit your retrieved context, answer style, latency budget, privacy needs, and provider credentials.

2

Extractor

Choose how documents become text. Weak extraction creates weak answers even with the best model.

3

Chunking

Split text so each chunk is small enough to retrieve but complete enough to answer.

4

Embeddings

Choose vector dimensions before creating the vector DB collection. Changing embeddings means re-ingestion.

5

Retrieval

Start dense. Add keyword, hybrid, MMR, parent-child, or self-query only when the retrieved chunks show the need.

6

Quality layers

Add query enhancement, reranking, compression, evaluation, and traces after baseline retrieval works.

FilesExtractorChunksEmbeddingsVector DB
Retrievaldense, hybrid, MMR, parent-child, multi-vector, graph traversal
Qualityquery enhancement, reranking, compression, evaluation
Outputlive answer, traces, pipeline.py, requirements.txt, .env

LLM Providers

Providers are used for generation, query enhancement, LLM-based reranking, summary compression, and some evaluation flows. MS-RAGS(ALL-IN-ONE) keeps credentials in memory during the session and never writes secret values into saved pipeline configs or generated source code.

ProviderVariablesBest use
OpenAIOPENAI_API_KEY, optional OPENAI_ORG_IDBest general hosted default.
AnthropicANTHROPIC_API_KEYCareful reasoning and long-form answers.
CohereCOHERE_API_KEYEmbeddings and reranking.
HuggingFaceHUGGINGFACEHUB_API_TOKENHosted token-only embeddings or local model ecosystem.
Google GeminiGOOGLE_API_KEYGoogle cloud workflows.
Mistral AIMISTRAL_API_KEYMultilingual and EU-friendly hosted use.
GroqGROQ_API_KEYFast inference.
Together AITOGETHER_API_KEYHosted open models.
ReplicateREPLICATE_API_TOKENModel experimentation.
Azure OpenAIAZURE_OPENAI_API_KEY, AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_DEPLOYMENT_NAMEAzure enterprise deployments.
AWS BedrockAWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, optional AWS_REGIONAWS enterprise deployments.
OllamaOLLAMA_MODEL_NAME, optional OLLAMA_API_KEY, optional OLLAMA_BASE_URLChat models can use local Ollama or Ollama Cloud; embeddings must use local or self-hosted Ollama.

Supported Model Guide

Context-window rule: the final prompt includes system instructions, the user question, retrieved chunks, and any query enhancement or compression output. Pick a model whose context window can hold that full prompt with room for the answer. Context windows change, so check the official provider link before production.
ProviderMS-RAGS(ALL-IN-ONE) default or inputPlanning context windowRecommended whenWatch out for
OpenAIgpt-4o by default; users can pass another OpenAI chat model in generated code.Plan around 128k for gpt-4o; newer OpenAI models may differ.Best first hosted choice, strong general QA, good tool ecosystem.Hosted API sends prompt/context to OpenAI. Long context increases cost and latency.
Anthropicclaude-3-5-sonnet-20241022.Plan around 200k for Claude Sonnet-family RAG prompts.Long-form answers, careful reasoning, policy/legal/research style responses.Extra retrieval, self-checking, or compression calls can multiply cost.
Coherecommand-a-03-2025 by default; versioned Command R models can also be used.Plan around long-context retrieval prompts and verify the exact context window on Cohere's official model page before production use.Enterprise RAG, reranking plus generation workflows, multilingual retrieval apps.Avoid removed unversioned aliases such as command-r-plus; use current/versioned model IDs.
Hugging Facemeta-llama/Meta-Llama-3-8B-Instruct by default.Plan around 8k for Llama 3 8B Instruct unless your endpoint says otherwise.Token-only hosted open models or custom inference endpoints.Model availability, rate limits, and context windows vary by endpoint.
Google Geminigemini-1.5-pro.Plan around 1M-2M depending on the Gemini 1.5 Pro configuration and current limits.Very large document context, Google ecosystem, multimodal-adjacent workflows.Huge context is not a replacement for good retrieval; still chunk and rerank.
Mistral AImistral-large-latest.Plan around 128k for Mistral Large-class prompts.Multilingual or EU-friendly hosted RAG, balanced quality and latency.Use model-specific limits before selecting chunk count and top_k.
Groqllama-3.3-70b-versatile.Plan around 128k for Llama 3.3 70B Versatile, then verify the Groq model page.Low-latency generation where fast answers matter.Speed does not fix bad retrieval; inspect chunks before tuning model choice.
Together AImeta-llama/Meta-Llama-3-8B-Instruct-Turbo.Plan around 8k for Llama 3 8B Instruct variants unless the endpoint exposes more.Hosted open-model experimentation and cost-sensitive prototypes.Smaller models need cleaner context and stricter prompts.
Replicatemeta/meta-llama-3-8b-instruct.Plan around 8k for this Llama 3 8B Instruct version.Testing model variants before committing to a provider.Version pins matter; provider model pages can change.
Azure OpenAIUser-provided AZURE_OPENAI_DEPLOYMENT_NAME.Use the context window of the deployed Azure model, often 128k for GPT-4o deployments.Azure enterprise, private networking, existing Azure governance.Deployment name is not always the public model name; document it clearly.
AWS Bedrockanthropic.claude-3-5-sonnet-20241022-v2:0.Plan around 200k for Claude 3.5 Sonnet on Bedrock where available.AWS enterprise deployments and Bedrock governance.Model availability varies by region and account permissions.
OllamaOLLAMA_MODEL_NAME, such as local llama3 or cloud gpt-oss:120b.Model/runtime dependent. Local defaults may be lower than the model maximum; check ollama show <model> and num_ctx.Local/private runs and Ollama Cloud chat.Ollama Cloud currently supports chat only. Embedding models such as nomic-embed-text must run on local or self-hosted Ollama.

Embedding Models

Important: embedding dimensions must match the vector DB collection or index. If the user changes embedding model, use a new collection or re-ingest.

OpenAI

text-embedding-3-small is the recommended hosted default. text-embedding-3-large is better quality but larger and more expensive.

Cohere

Use embed-english-v3.0 for English and embed-multilingual-v3.0 for multilingual retrieval.

HuggingFace Local

Use all-MiniLM-L6-v2 for CPU speed, all-mpnet-base-v2 for stronger general quality, BGE/E5 for advanced local retrieval.

HuggingFace Hosted

Use HuggingFaceEndpointEmbeddings with HUGGINGFACEHUB_API_TOKEN when users want token-only hosted embeddings with no local download.

Google and Mistral

Use when you want the embedding provider to match your LLM/cloud provider.

Ollama

Use local embedding models like nomic-embed-text, or cloud-compatible Ollama settings when credentials are supplied.

Embedding Model Catalogue

ModelProviderDimensionsUse whenWhere it runs
text-embedding-3-smallOpenAI1536Best first hosted embedding for cost, speed, and solid retrieval.Hosted API
text-embedding-3-largeOpenAI3072Higher retrieval quality matters more than vector size/cost.Hosted API
text-embedding-ada-002OpenAI1536Legacy projects already use it and need compatibility.Hosted API
embed-english-v3.0Cohere1024English-only retrieval with Cohere stack.Hosted API
embed-multilingual-v3.0Cohere1024Multilingual documents or users ask in more than one language.Hosted API
all-MiniLM-L6-v2Hugging Face384Fast local CPU baseline, demos, small corpora.Local or HF hosted endpoint
all-mpnet-base-v2Hugging Face768Better local semantic quality for general documents.Local or HF hosted endpoint
multi-qa-mpnet-base-dot-v1Hugging Face768Question-answer retrieval where queries are natural-language questions.Local
BAAI/bge-small-en-v1.5Hugging Face384Fast English local retrieval with BGE behavior.Local
BAAI/bge-base-en-v1.5Hugging Face768Balanced local quality and resource use.Local
BAAI/bge-large-en-v1.5Hugging Face1024Best English BGE quality when GPU/RAM budget allows.Local
BAAI/bge-m3Hugging Face1024Multilingual, dense+sparse, advanced retrieval experiments.Local
intfloat/e5-small-v2Hugging Face384Resource-constrained local systems.Local
intfloat/e5-base-v2Hugging Face768General-purpose local retrieval.Local
intfloat/e5-large-v2Hugging Face1024Higher-quality E5 retrieval with enough compute.Local
intfloat/e5-mistral-7b-instructHugging Face4096High-quality local/GPU instruction embeddings.Local, GPU recommended
hkunlp/instructor-base, large, xlHugging Face768Task-instruction-aware retrieval.Local
models/text-embedding-004Google Gemini768Google provider alignment and task-type embeddings.Hosted API
mistral-embedMistral AI1024Mistral provider alignment and multilingual retrieval.Hosted API
Ollama user modelOllamaModel-dependentPrivate/local embeddings such as nomic-embed-text or mxbai-embed-large.Local or Ollama-compatible endpoint

Embedding Technical Notes

ChoiceTechnical behaviorRisk to explain to users
Hosted embeddingsDocuments are sent to the provider API and vectors are returned.Requires network and credentials; may have data governance implications.
Local HuggingFaceModel weights are downloaded and inference runs on the user's machine. MS-RAGS disables the fragile Xet transfer path by default and, if a partial cache breaks loading, asks permission before cleaning only that model cache and retrying.First run may be slow and disk-heavy; CPU models can be slower.
Hosted HuggingFace endpointUses HuggingFaceEndpointEmbeddings and HUGGINGFACEHUB_API_TOKEN.Token-only setup is easier, but endpoint availability and rate limits matter.
Ollama local/cloudNo API key defaults to local http://localhost:11434; API key defaults to https://ollama.com for chat. The framework normalizes /v1 to the root base URL.Ollama Cloud is chat-only; embedding models must use local or self-hosted Ollama.
Dimension changesVector dimensions are fixed by the embedding model.Changing models requires a new collection or full re-ingestion.

Extractors And Loaders

SourceLoadersRecommendation
PDFPyPDFLoader, UnstructuredPDFLoader, PDFPlumberLoader, CamelotLoader, TabulaLoader, LlamaParseLoaderStart with PyPDFLoader. Use PDFPlumber/Camelot for tables. Use LlamaParse for complex paid parsing.
WordUnstructuredWordDocumentLoader, Docx2txtLoader, LlamaParseLoaderUse Unstructured for structure, Docx2txt for simple text.
CSV/ExcelCSVLoader, UnstructuredCSVLoader, UnstructuredExcelLoader, PandasDataFrameLoaderUse CSVLoader for row-level retrieval, Pandas for custom preprocessing.
PPTXUnstructuredPowerPointLoader, LlamaParseLoaderUse Unstructured unless slides are complex.
HTML/URLsBSHTMLLoader, UnstructuredHTMLLoader, WebBaseLoader, AsyncHtmlLoader, FireCrawlLoader, ApifyWebScraperUse WebBaseLoader for simple pages, FireCrawl/Apify for rendered sites.
Markdown/JSON/XMLUnstructuredMarkdownLoader, JSONLoader, UnstructuredXMLLoader, TextLoaderUse format-aware loaders when metadata matters.
ePub/RTFUnstructuredEPubLoader, UnstructuredRTFLoaderUse for books, manuals, rich text exports, and legacy text archives.
YouTubeYoutubeLoaderUse when transcripts are available and accurate.
ImagesUnstructuredImageLoaderVerify OCR quality before production ingestion.
CodeGenericLoader, TextLoaderUse GenericLoader with code-aware chunking for repository search.
SQL/MongoDBSQLDatabaseLoader, MongoDBAtlasLoaderUse when source knowledge lives in databases.

Extractor Decision Guide

ExtractorWhat it doesWhen to useWhy choose itWhere to be careful
PyPDFLoaderReads PDF text quickly using a simple parser.Clean digital PDFs with normal text flow.Fast, free, good first PDF default.Weak on scanned PDFs, complex tables, multi-column layouts.
UnstructuredPDFLoaderParses PDFs into text elements with layout awareness.Mixed PDF layouts, scanned/OCR workflows, messy enterprise documents.Better structure than simple extraction. MS-RAGS checks for Poppler before ingestion when PDF sources are selected.Needs Poppler for many PDFs and Tesseract for local OCR quality; choose LlamaParse if you prefer cloud parsing.
PDFPlumberLoaderExtracts PDF text with stronger layout/table inspection.Reports, invoices, PDFs with columns or tables.Good when table position and text layout matter.Still needs manual sample review.
CamelotLoaderSpecialized PDF table extraction.PDFs where the answer lives inside tables.Better table recovery than plain text loaders.Works best on digital PDFs with clear table lines/structure; Ghostscript is recommended.
TabulaLoaderJava-based PDF table extraction.Table-heavy PDFs where Tabula performs better than Camelot.Useful alternate table parser.Requires Java and table quality varies by PDF structure.
LlamaParseLoaderCloud parser for complex documents.High-value PDFs, DOCX, PPTX, scanned or layout-heavy documents.Best when extraction quality matters more than cost.Requires credentials and sends documents to a cloud parser.
UnstructuredWordDocumentLoaderParses Word documents with structure.Policies, manuals, reports with headings.Keeps document hierarchy more useful for chunking.Inspect lists, tables, and images.
Docx2txtLoaderSimple DOCX-to-text extraction.Clean Word docs where plain text is enough.Lightweight and easy.Less structure and metadata.
CSVLoaderTurns CSV rows into documents.FAQ tables, product catalogs, structured row-level data.Good when each row is a retrievable fact.Bad if rows require joins or complex aggregation.
PandasDataFrameLoaderLoads tabular data through pandas.You need preprocessing, filtering, computed columns, or custom row text.Maximum control over table-to-document conversion.Requires careful schema decisions.
UnstructuredExcelLoaderExtracts Excel sheets into text/documents.Simple spreadsheet knowledge bases.Handles workbook/sheet structure.Formula values and merged cells should be reviewed.
UnstructuredPowerPointLoaderExtracts slide text.Training decks, sales decks, course slides.Preserves slide-level source metadata.Speaker notes, diagrams, and images may need extra extraction.
BSHTMLLoaderExtracts text from HTML with BeautifulSoup.Local static HTML pages.Simple and predictable.Does not execute JavaScript.
WebBaseLoaderFetches web pages with requests and parses text.Simple public pages and documentation sites.Good first URL loader.Rendered apps, auth, and dynamic content may fail.
AsyncHtmlLoaderFetches many HTML pages concurrently.Multiple URLs where speed matters.Faster batch ingestion.Respect rate limits and robots policies.
FireCrawlLoaderCloud web extraction with cleaned markdown.JavaScript-rendered websites or multi-page crawling.Cleaner RAG-ready web text.Requires credentials and sends URLs/content to a service.
ApifyWebScraperActor-based cloud scraping.Complex sites, repeatable crawl jobs, scalable scraping.Operational web extraction platform.Credential, cost, and site-permission considerations.
YoutubeLoaderLoads YouTube transcripts.Video knowledge where transcripts are available.Good for courses, interviews, talks.Transcript accuracy controls answer quality.
UnstructuredImageLoaderOCR text from images.Scanned images, screenshots, photographed pages.Adds image text to RAG corpus.OCR noise must be sampled before production.
UnstructuredEPubLoaderExtracts text from ePub books and manuals.Books, long guides, educational content, and packaged documentation.Keeps book-style content available for chunking.Review chapters, navigation text, and boilerplate before ingestion.
UnstructuredRTFLoaderExtracts text from RTF rich text documents.Legacy reports, exported notes, and older office documents.Useful when the source is not DOCX or plain text.Formatting artifacts can appear in old RTF exports.
GenericLoaderLanguage-aware source code loading.Repository search, API docs, code understanding.Pairs well with code-aware chunking.Generated/vendor folders should be excluded.
SQLDatabaseLoaderTurns SQL rows into documents.Knowledge lives in relational tables.Useful for internal business data.Do not expose sensitive columns accidentally.
MongoDBAtlasLoaderLoads MongoDB collection documents.Product content or records already live in MongoDB.Preserves document-native source shape.Choose fields carefully and avoid private data.

Chunk Splitters

Recursive Character

Recommended default. Keeps paragraphs and sentences where possible.

Fixed Size

Consistent size, weaker semantic boundaries.

Semantic

Uses embeddings to detect topic changes.

Sentence

Preserves full sentence boundaries for precise domains.

Paragraph

Good for articles, books, and reports.

Token Based

Best when token budgets must match model windows.

Markdown/HTML Aware

Preserves document or web structure as metadata.

Code Aware

Splits source code by language-specific boundaries.

Agentic

LLM-driven chunk boundaries for high-value documents.

Document Aware

Uses headings and hierarchy for structured manuals.

Chunk Splitter Decision Guide

SplitterWhatWhenWhyWhere it can fail
Recursive CharacterSplits by paragraph, sentence, word, then character fallback.Default for most text/PDF/Markdown docs.Stable, simple, strong baseline.May cut tables or code awkwardly.
Fixed SizeSplits every N characters/tokens.Need predictable chunk size for experiments.Easy to compare and debug.Can break semantic boundaries.
SemanticUses embeddings to detect topic changes.Long prose where topics shift naturally.Better semantic chunk boundaries.Costs more because it needs embeddings during splitting.
SentenceKeeps full sentences together.Legal, medical, policy, or precise domains.Reduces partial-sentence retrieval.Can create tiny or uneven chunks.
ParagraphKeeps paragraphs as primary units.Reports, articles, books, manuals.Natural author-defined context.Long paragraphs may exceed retrieval budget.
Token BasedSplits by model tokenizer budget.Strict context-window management.Prevents prompt overflow.Tokenizer mismatch can cause surprises.
Markdown/HTML AwareUses headings and document structure.Docs sites, READMEs, manuals, HTML pages.Preserves section metadata.Bad markup creates bad hierarchy.
Code AwareSplits by functions/classes/language syntax.Repository search and code assistants.Keeps code units meaningful.Generated/minified files should be filtered out.
AgenticUses an LLM to decide chunk boundaries.Small, high-value corpora where quality beats speed.Can produce human-like sections.Slow and costly for large ingestion.
Document AwareUses headings, pages, sections, and hierarchy.Policies, PDFs, manuals, and structured docs.Best for preserving source organization.Requires reliable extracted structure.

Chunking Parameters

ParameterMeaningRecommendation
chunk_sizeMaximum chunk length in characters or tokens depending on splitter.Start around 800-1200 characters for general docs or 400-800 tokens for token-based splitting.
chunk_overlapRepeated text between adjacent chunks.Use 10-20 percent of chunk size. Too much overlap increases cost and duplicate retrieval.
separatorsPriority boundaries for recursive splitting.Keep paragraph and sentence boundaries before falling back to words or characters.
tokenizerTokenizer used to count tokens for token-based splitting.Match the tokenizer to the model family where possible.
languageProgramming language for code-aware splitting.Choose the actual source language so functions/classes are preserved.

Retrieval, Enhancement, Reranking, Compression

Retrieval

Dense vector is the simple default. BM25/TF-IDF help exact terms. Hybrid combines semantic and keyword. MMR adds diversity. Self-query uses metadata filters.

Query Enhancement

Use rewriting for clarity, expansion for recall, HyDE for language mismatch, multi-query/fusion for ambiguous questions, and decomposition for complex questions.

Reranking

Use Cohere for hosted reranking, BGE/Cross-Encoder for local quality, FlashRank for CPU-friendly deployments, LLM scoring for flexible but expensive judgment.

Compression

Use embeddings filters for cheap pruning, redundancy removal for duplicates, LLM extraction/summary for noisy long chunks, and contextual compression for production retrieval wrappers.

Retrieval Strategy Reference

StrategyHow it worksWhen to use
Dense VectorEmbeds the query and ranks chunks by vector similarity.Default semantic search.
BM25Ranks by term frequency and document frequency.Error codes, exact names, product IDs, legal phrases.
TF-IDFLightweight keyword scoring based on term importance.Small local corpora and interpretable keyword baselines.
HybridCombines vector and keyword scores using alpha.Production docs where exact terms and meaning both matter.
MMRBalances relevance with diversity.When retrieved chunks are too repetitive.
EnsembleCombines multiple retrievers with weights that sum to 1.0.Advanced users with measured complementary retrievers.
Parent-ChildRetrieves small child chunks, maps them to parent IDs, and returns larger parent context.Long PDFs, reports, policies, legal docs, and research docs where surrounding context matters.
Multi-VectorBuilds a local FAISS representation index from compact chunk representations and returns the original chunks.Documents where short representations, titles, or first lines retrieve better than noisy full text.
Self-QueryLLM generates structured metadata filters.Corpora with reliable metadata fields.
Time-WeightedCombines dense similarity with ms_rag_ingested_at recency metadata.Frequently updated knowledge bases, support tickets, changelogs, and policy updates.

Parent-Child state

MS-RAGS(ALL-IN-ONE) creates parent document IDs and child chunk IDs during ingestion. Saved sessions rebuild this state from original sources before runtime starts.

Multi-Vector model

Uses the selected embedding model to build a separate local FAISS representation index. Synthetic representation vectors are not written into Pinecone, Qdrant, Chroma, or other production stores.

Time metadata

Every chunk gets ms_rag_ingested_at. If timestamps are missing, MS-RAGS(ALL-IN-ONE) raises a setup error instead of silently pretending time-weighted retrieval is active.

Keyword storeWhy it existsRecommended use
SQLitePersists raw chunk text locally for BM25/TF-IDF/hybrid.Single-server production and development.
PostgreSQLStores chunk text and metadata beside production app data.Managed Postgres deployments.
ElasticsearchProvides production full-text search for keyword retrieval.Enterprise search and large corpora.
OpenSearchOpenSearch/AWS-compatible full-text keyword storage.AWS/OpenSearch deployments.

Query Enhancement Reference

TechniqueWhat it doesWhen to useWhy it helpsRisk
Query rewritingRephrases the user query into a clearer retrieval query.User questions are vague, conversational, or messy.Improves match between user wording and document wording.Can remove important user intent if the rewrite is too aggressive.
Query expansionAdds related terms, synonyms, acronyms, and domain phrases.Documents use many names for the same concept.Improves recall.Can retrieve too much broad/noisy context.
HyDEGenerates a hypothetical answer/document and retrieves against it.Questions are abstract and direct search misses context.Bridges wording mismatch.Hypothetical text can drift from the corpus.
Multi-queryCreates several query variants and retrieves for each.One phrasing misses useful evidence.Improves recall for ambiguous questions.More retrieval calls and deduplication work.
Step-backAsks a broader conceptual question first.Questions need principles plus facts.Adds background context before final answer.Unnecessary for exact lookup questions.
DecompositionBreaks a complex question into smaller sub-questions.Multi-hop or comparison questions.Finds evidence for each part separately.More LLM/retrieval calls and harder trace review.
RAG-FusionMerges rankings from several generated queries.Recall and ranking quality matter more than speed.Balances multiple retrieval perspectives.Higher latency and tuning complexity.

Reranking Reference

RerankerWhatWhenWhyTradeoff
Cohere RerankHosted reranking model scores retrieved chunks.Production systems need better final chunk ordering.Strong quality without local model hosting.Requires Cohere credentials and sends chunk text to Cohere.
Cross-EncoderLocal model scores query+chunk pairs together.You want local/private reranking.Better relevance than pure vector similarity.Slower than embeddings; CPU can be expensive.
BGE RerankerLocal or hosted BGE-style reranking.Open-source reranking quality is needed.Good balance for support/docs RAG.Model setup and GPU/CPU sizing matter.
ColBERTLate-interaction ranking approach.Advanced retrieval experiments and high recall/ranking needs.Strong matching between query terms and document tokens.More complex storage and serving.
FlashRankLightweight CPU-friendly reranking.You need cheap reranking without a large service.Easy operational footprint.May not beat stronger hosted/local rerankers.
LLM scoringAsks the LLM to score or filter chunks.Domain-specific relevance rules are hard to encode.Flexible and explainable if prompted well.Slowest and most expensive option.

Context Compression Reference

CompressorWhat it doesWhen to useWhy it helpsRisk
Embeddings filterDrops chunks below similarity threshold.Retrieved context includes weakly related chunks.Cheap pruning before LLM calls.Threshold too high can remove useful evidence.
Redundancy filterRemoves near-duplicate chunks.Overlap or repeated boilerplate appears in results.Saves context budget.Can remove repeated but important evidence if tuned poorly.
LLM extractionExtracts only relevant spans from chunks.Chunks are long but contain a small relevant section.Improves answer focus.Extra LLM cost and possible missed facts.
LLM summarySummarizes retrieved chunks before final answer.Context is too long for the answer model.Fits more evidence into the model window.Summaries can lose citations or details.
Contextual compression retrieverWraps retrieval with filtering/extraction.You want compression as a reusable retrieval layer.Keeps the main RAG chain cleaner.Debug traces must show both original and compressed context.
Lost-in-the-middle reorderReorders chunks to improve attention to important context.Many chunks are passed to a long-context model.Places key evidence near prompt positions models attend to better.Does not fix irrelevant retrieval.

Evaluation And Monitoring Reference

Tool or methodWhat it measuresWhen to useProduction reason
RAGASFaithfulness, answer relevancy, and no-reference context precision using an evaluator LLM. Step 15 asks for OPENAI_API_KEY and an evaluator model such as gpt-4o-mini; visible lexical fallback metrics are used if the evaluator API/package fails.You need automated RAG quality metrics.Detects retrieval and hallucination regressions without hiding evaluator credential or package problems.
DeepEvalLLM evaluation metrics using the configured evaluator model and OpenAI key.You want CI-style evals around known questions.Blocks low-quality generated pipelines before release and reports clean fallback metrics if the evaluator cannot run.
TruLensModern TruLens package validation when compatible, plus TruLens-prefixed groundedness scores with visible fallback warning when its LangChain adapter is incompatible.You want TruLens-compatible local scoring and a path to deeper feedback workflows.Helps inspect answer/context grounding without silently pretending an optional adapter loaded.
LangSmithTrace debugging, datasets, evaluation runs.LangChain-heavy teams need trace-level debugging.Makes complex chains and agents observable.
LangfuseOpen-source LLM observability and prompt traces.You want self-hostable or vendor-flexible observability.Tracks prompts, latency, tokens, and errors.
Arize PhoenixOpenInference/Phoenix trace export when the collector endpoint is configured, plus Phoenix-prefixed scores.You need rich inspection of retrieval and model behavior.Useful for production debugging and review.
ARESARES-compatible retrieval/generation scores. The external ares-ai package is optional and intentionally separate from production installs because current releases pin older OpenAI/Anthropic SDKs.You want ARES-style RAG quality signals for a live query.Keeps package-backed status separate from local fallback metrics and avoids Docker dependency conflicts.
RAGBenchHugging Face datasets tooling check plus RAGBench-compatible single-query scores.You want benchmark-style metrics while testing local generated pipelines.Works without pretending to run the full external benchmark suite.
OpenTelemetryVendor-neutral traces and spans.You already run observability infrastructure.Connects MS-RAGS(ALL-IN-ONE) phases to dashboards and alerts.

Failure Modes And Fixes

Good answer exists but is not retrieved

Improve chunking, use query rewriting, enable hybrid retrieval, increase top_k, or add RAG-Fusion.

Retrieved chunks are relevant but noisy

Add reranking, MMR, contextual compression, embeddings filters, or smaller chunks.

Answers hallucinate

Use stricter system prompts, Self-RAG/Corrective RAG, faithfulness evaluation, and source-citation UX in generated code.

Costs are too high

Reduce top_k, use cheaper embeddings, remove unnecessary multi-query calls, and use embeddings filters before LLM compression.

Evaluation

Use RAGAS for faithfulness and context metrics with an explicit evaluator LLM, DeepEval for package-backed answer checks, TruLens-compatible groundedness scores, LangSmith, Langfuse, or Arize Phoenix for tracing, ARES/RAGBench benchmark-compatible signals, CI/CD gates for release protection, and monitoring export for production dashboards. Optional evaluator import incompatibilities or invalid evaluator credentials produce visible warnings and lexical fallback metrics.