Scaling RAG Accuracy from 49% to 86% in Finance Q&A Assistant

amazon_finance · Finance · 2024 · source Agentic: no · promotional bias: med · source-backed · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: enterprise finance Q&A

Amazon Finance Automation needed to reduce hours-to-days analyst response time for Accounts Payable and Accounts Receivable policy questions while maintaining accuracy in a finance operations context.

Constraints:

Architecture

Amazon Finance Automation built a Bedrock RAG assistant using OpenSearch as the vector store, Amazon Titan embeddings, a Bedrock foundation model generator, diversity and lost-in-the-middle rankers, Bedrock Guardrails for PII/prompt-injection protection, and a validation engine that returns an explicit 'I don't know' when generated answers do not align with retrieved context.

Diagram confidence: explicit (topology described by the source).

flowchart LR
  A["Analyst chat UI"] --> B["RAG orchestrator"]
  B --> C["OpenSearch vector store"]
  D["Titan embeddings"] --> C
  C --> E["Diversity ranker"]
  E --> F["Lost-in-the-middle ranker"]
  F --> G["Bedrock generator"]
  B --> H["Bedrock Guardrails"]
  G --> I["Validation engine"]
  I --> B
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Analyst chat UI Interface where AP/AR analysts ask finance policy questions. RAG orchestrator
RAG orchestrator Coordinates retrieval, ranking, generation, guardrails, validation, and response. Analyst chat UI, OpenSearch vector store, Diversity ranker, Lost-in-the-middle ranker, Bedrock generator, Bedrock Guardrails, Validation engine
OpenSearch vector store Stores embedded policy and SOP chunks. RAG orchestrator, Titan embeddings, Diversity ranker
Titan embeddings Embedding model used for retrieval and context relevance improvements. OpenSearch vector store
Diversity ranker Rearranges vector results to avoid skew toward particular documents or sections. RAG orchestrator, Lost-in-the-middle ranker
Lost-in-the-middle ranker Places highly relevant results toward prompt positions the LLM is more likely to use. Diversity ranker, Bedrock generator
Bedrock generator Foundation model that generates answers from retrieved context. Lost-in-the-middle ranker, Validation engine
Bedrock Guardrails Detects PII and prompt injection. RAG orchestrator
Validation engine Checks response alignment with retrieved context and falls back when alignment fails. Bedrock generator, RAG orchestrator

Data flow

A finance analyst submits a query; the RAG pipeline retrieves relevant policy/SOP documents from an OpenSearch-backed knowledge base using Titan embeddings; rankers arrange retrieved context; a Bedrock foundation model generates the answer; guardrails and validation check PII, prompt injection, and answer-context alignment before the UI returns a cited response or fallback.

3 supporting quotes
“When a user submits a query, RAG works by first retrieving relevant documents from a knowledge base, then generating a response with the LLM from the retrieved documents.”article, stated
“Knowledge base – We used Amazon OpenSearch Service as the vector store for embedding documents.”article, stated
“Guardrails – We used Amazon Bedrock Guardrails to detect personal identifiable information (PII)”article, stated

Why this architecture

The team used RAG because analysts needed answers grounded in finance policy documents, then improved retrieval, prompting, and embeddings only after SME/manual evaluation showed initial accuracy was too low.

3 supporting quotes
“analysts must engage in a time-consuming process of reaching out to subject matter experts (SMEs) and go through multiple policy documents”article, stated
“found only 49% of the responses were correct. This was far below the expectation, and the solution needed improvement.”article, stated
“Through continual evaluation and iterative improvement, we have addressed challenges of hallucinations, document ingestion issues, and context retrieval inaccuracies.”article, stated

Models used: Amazon Titan Multimodal Embeddings G1 · Amazon Titan Text Embeddings G1 · Amazon Bedrock foundation model · LLM-as-judge evaluation model

Scale

Alternatives considered (roads not taken)

Manual SME/policy lookup

Rejected because: It took hours to days and was especially hard for new hires.

“analysts, especially the new hires, don’t have immediate access to the necessary information.”article, stated

Fixed-size document chunks

Rejected because: They created incomplete contexts because chunks ignored logical document structure.

“Add document semantic chunking to improve accuracy from 49% to 64%”article, stated

ROUGE/METEOR as the main automatic evaluator

Rejected because: Word-matching scores ignored semantic meaning and diverged from human evaluation by about 30%.

“these scores merely use word-matching algorithms and ignore the semantic meaning of the text”article, stated

Patterns

rag-retrieval (retrieval)

The assistant retrieves finance policy/SOP context from a vector knowledge base before generation.

“The solution is based on a Retrieval Augmented Generation (RAG) pipeline running on Amazon Bedrock”article, stated

llm-as-judge (evaluation)

A Bedrock foundation model scored generated answers against expected answers with accuracy, acceptability, factualness, and reasoning citations.

“* LLM-based score – We used an FM offered by Amazon Bedrock to score the RAG performance. We designed specialized LLM prompts to evaluate the RAG performance by comparing the generated answer with the expected answer.”article, stated

eval-driven-development (evaluation)

The team used measured error sources to drive semantic chunking, prompt engineering, and embedding-model changes.

“After implementing the document segmentation approach, we still saw lower relevance scores for retrieved contexts”article, stated

safety-policy-enforcement (safety)

Guardrails and validation prevent PII leakage, prompt injection, and hallucinated responses.

“6. Guardrails – We used Amazon Bedrock Guardrails to detect personal identifiable information (PII) and safeguard against prompt injection attacks.”article, stated

Tradeoffs

RAG infrastructure

Chose OpenSearch vector store initially over Bedrock Knowledge Bases from the start.

Rationale: OpenSearch supported the initial knowledge base, while migration to managed Knowledge Bases was planned to reduce cluster management.

“We’re planning to migrate to Amazon Bedrock Knowledge Bases to eliminate cluster management and add extensibility to our pipeline.”article, stated

Fallback behavior

Chose explicit I don't know when context is incomplete over force an answer without enough retrieved context.

Rationale: Finance policy answers should not be hallucinated.

“I don't know, I don't have the complete context needed to answer this question.”article, stated

Evaluation automation

Chose LLM-based judge after SME calibration over continued fully manual SME evaluation.

Rationale: Manual evaluation was not sustainable, while LLM judging aligned more closely with human analysis than ROUGE/METEOR.

“However, manually evaluating the RAG isn’t sustainable—it requires hours of effort from finance operations and engineering teams.”article, stated

Gotchas (what bit them)

Initial RAG accuracy was far below production expectations.

Root cause: Retrieval, chunking, prompting, and embedding choices all affected answer correctness.

Resolution: Use an evaluation loop to improve semantic chunking, prompts, and embeddings.

“The SMEs manually evaluated the RAG responses one by one, and found only 49% of the responses were correct. This was far below the expectation, and the solution needed improvement.”article, stated

Traditional NLP metrics missed semantic answer quality.

Root cause: ROUGE and METEOR match words rather than meaning.

Resolution: Use LLM-based evaluation aligned with SME judgments.

“The variance of this approach was approximately 5% compared to human analysis, so we decided to stick to this approach of evaluation.”article, stated

Retrieved context relevance stayed low after chunking.

Root cause: Embedding model choice still caused incorrect contexts to rank highly.

Resolution: Switch to Amazon Titan Text Embeddings G1.

“After implementing the document segmentation approach, we still saw lower relevance scores for retrieved contexts (55–65%), and the incorrect contexts were in the top ranks for more than 50% of cases. This indicated that there was still room for improvement.”article, stated

Evaluation

The team used SME-labeled expected answers, ROUGE/METEOR comparisons, LLM-as-judge scoring, context relevance metrics, and staged accuracy measurements after each RAG improvement.

Metrics: RAG accuracy · acceptability · factualness · context relevance · context coverage · correctness · completeness · helpfulness

“We generated a set of LLM-based metrics, including accuracy, acceptability, and factualness, and the citation representing the evaluation reasoning.”article, stated
“It provides retrieval evaluation metrics such as context relevance and context coverage. It also provides retrieve and generate evaluation metrics such as correctness, completeness, and helpfulness, as well as responsible AI metrics such as harmfulness and answer refusal.”article, stated

Outcomes

This is a high-stakes enterprise finance RAG system with transparent staged accuracy reporting rather than a perfect-accuracy claim.

“By implementing the prompt engineering approaches, we improved RAG accuracy from 64% to 76%.”article, stated
“Finally, by adopting the Amazon Titan Text Embeddings G1 model, we improved the overall accuracy from 76% to 86%.”article, stated