Finance ops · Production

Q4 Inc. builds a RAG and SQL generation Q&A chatbot on Amazon Bedrock for investor relations data

The problem

Investor Relations Officers at Q4's customers needed an intuitive, fast way to query diverse financial datasets including CRM, ownership records, and stock market data via natural language, but standard LLM approaches — pre-training, fine-tuning, and RAG with embeddings — all produced suboptimal or prohibitively expensive results for numerical and structured financial data.

First attempt

Pre-training was resource-intensive and cost-prohibitive, requiring continuous incremental training as new time-series data arrived. Fine-tuning showed initial success but suffered from model hallucination on nuanced queries. RAG with semantic search and embeddings was suboptimal for numerical data because embeddings from numbers struggled with similarity ranking and returned incorrect information.

Workflow diagram · grounded in source
1
User question received
trigger
“we start with the input stage, where we receive the user question in natural language”
2
SQL generation via LLM
ai_action
“To generate SQL, we use SQLDatabaseChain, which relies on Amazon Bedrock for access to our desired LLM”
3
SQL query run against database
integration
“we can run the SQL query against the database and retrieve the relevant context”
4
LLM summarization of results
ai_action
“we can send the user's original question, the context retrieved, and a set of instructions back to the LLM to produce a final summarized response. The goal of the last step is to have the LLM summarize the results and provide a contextua…”
5
Answer delivered to user
output
“We then present the generated summary to the user as an answer to the initial question, all aligned with the context extracted from our dataset”
Reported outcome

The SQL generation approach satisfied all functional and non-functional requirements: Q4 was satisfied with the SQL quality for both simple and complex queries, and the end-to-end latency came within the acceptable range of single-digit seconds.

Reported metrics
End-to-end query response latencysingle-digit seconds
Reported stack
Amazon BedrockLangChainSQLDatabaseChainClaude V2Claude InstantTitan Text Express
Source
https://aws.amazon.com/blogs/machine-learning/how-q4-inc-used-amazon-bedrock-rag-and-sqldatabasechain-to-address-numerical-and-structured-dataset-challenges-building-their-qa-chatbot?tag=soumet-20
Read source ↗

Frequently asked questions

What did this team achieve with this AI workflow?

The SQL generation approach satisfied all functional and non-functional requirements: Q4 was satisfied with the SQL quality for both simple and complex queries, and the end-to-end latency came within the acceptable ra…

What tools did this team use?

Amazon Bedrock, LangChain, SQLDatabaseChain, Claude V2, Claude Instant, Titan Text Express.

What results were reported?

End-to-end query response latency: single-digit seconds (source-reported, not independently verified).

What failed first in this deployment?

Pre-training was resource-intensive and cost-prohibitive, requiring continuous incremental training as new time-series data arrived.

How is this finance ops AI workflow structured?

User question received → SQL generation via LLM → SQL query run against database → LLM summarization of results → Answer delivered to user.