Building QueryAnswerBird: An LLM-Powered AI Data Analyst with RAG and Text-to-SQL

delivery_hero · E-commerce · 2024 · source Agentic: yes · promotional bias: med · source-backed · extracted with prompt 0.5.5 (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 Text-to-SQL and data discovery

Woowa Brothers needed to raise employee data literacy by helping employees generate, interpret, validate, and discover SQL/data information despite company-specific business terminology, data policies, and metadata complexity.

Constraints:

Architecture

QAB is a Slack-based AI data analyst built on GPT-4o/Azure OpenAI, RAG, LangChain, vector stores, multi-chain routing, and LLMOps. It automatically collects business terminology, table metadata, and extraction code into VectorDBs, applies data-area indexing, routes questions through a Router Supervisor to specialized chains, retrieves the right metadata/DDL/few-shot examples, and generates or explains SQL. Production operations include AB testing with leaderboards, API load balancing, GPT caching, user feedback loops, monitoring dashboards, and CI/CD.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  slack-employee[Slack employee] --> slack-qab-interface[Slack QAB interface]
  slack-qab-interface --> router-supervisor-chain[Router Supervisor chain]
  router-supervisor-chain --> query-generation-chain[Query generation chain]
  router-supervisor-chain --> query-interpretation-chain[Query interpretation chain]
  router-supervisor-chain --> syntax-validation-chain[Syntax validation chain]
  router-supervisor-chain --> data-discovery-guide-chains[Data discovery guide chains]
  query-generation-chain --> retriever[Retriever]
  query-interpretation-chain --> retriever
  data-discovery-guide-chains --> retriever
  retriever --> vectordbs[VectorDBs]
  vectordbs --> unstructured-data-pipeline[Unstructured data pipeline]
  unstructured-data-pipeline --> internal-data-catalog-api[Internal data catalog API]
  retriever --> business-terminology-glossary[Business terminology glossary]
  business-terminology-glossary --> data-governance-organization[Data governance organization]
  retriever --> few-shot-sql-dataset[Few-shot SQL dataset]
  few-shot-sql-dataset --> domain-data-analysts[Domain data analysts]
  query-generation-chain --> gpt-4o[GPT-4o]
  query-interpretation-chain --> gpt-4o
  syntax-validation-chain --> gpt-4o
  data-discovery-guide-chains --> gpt-4o
  gpt-4o --> gpt-cache[GPT cache]
  slack-qab-interface --> feedback-loop[Feedback loop]
  feedback-loop --> gpt-cache
  ab-testing-leaderboard[AB testing leaderboard] --> ci-cd-deployment[CI/CD deployment]
  ab-testing-leaderboard --> monitoring-dashboards[Monitoring dashboards]
  ci-cd-deployment --> monitoring-dashboards
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Slack employee Internal user who asks data-literacy, SQL, and data-discovery questions in Slack. Slack QAB interface
Slack QAB interface Primary user interface for asking questions, receiving answers, and marking responses satisfied or unsatisfied. Slack employee, Router Supervisor chain, Feedback loop
Router Supervisor chain Classifies question purpose in real time and maps requests to the right specialized chain. Slack QAB interface, Query generation chain, Query interpretation chain, Syntax validation chain, Data discovery guide chains
Query generation chain Generates SQL using RAG, ReAct-style reasoning/searching, and company-specific context. Router Supervisor chain, Retriever, GPT-4o
Query interpretation chain Explains SQL queries for employees who need to understand unfamiliar domains or services. Router Supervisor chain, Retriever, GPT-4o
Syntax validation chain Provides validation information about whether generated queries execute correctly or contain errors. Router Supervisor chain, GPT-4o
Data discovery guide chains Answer table, column, log-table, and utilization questions beyond pure query generation. Router Supervisor chain, Retriever, GPT-4o
Retriever Uses chain-specific search algorithms to extract relevant metadata, DDL, business terms, and few-shot examples. VectorDBs, Business terminology glossary, Few-shot SQL dataset, Query generation chain, Query interpretation chain, Data discovery guide chains
VectorDBs Store embedded unstructured data for vector similarity search and data-area indexed updates. Unstructured data pipeline, Retriever
Unstructured data pipeline Automatically collects business terminology, table metadata, extraction code, DDL, and newest data policies. VectorDBs, Internal data catalog API
Internal data catalog API Source for automatically collecting and updating table DDL and data-policy information. Unstructured data pipeline
Business terminology glossary Text-to-SQL glossary built from standard business terminology to interpret domain language correctly. Retriever, Data governance organization
Few-shot SQL dataset Question-query examples and high-quality analyst-written queries used to improve generation. Retriever, Domain data analysts
GPT-4o Foundation model used for question refinement, query generation, interpretation, and validation. Query generation chain, Query interpretation chain, Syntax validation chain, Data discovery guide chains, GPT cache
GPT cache Caches useful responses and expands standardized data knowledge based on feedback. GPT-4o, Feedback loop
Feedback loop Captures satisfied/unsatisfied evaluations and feeds them into caching and improvement. Slack QAB interface, GPT cache
AB testing leaderboard Experiment environment for comparing evaluation data, prompts, retrievers, and chains. CI/CD deployment, Monitoring dashboards
Monitoring dashboards Track response stability, speed, error handling, and operational service quality. AB testing leaderboard, CI/CD deployment
CI/CD deployment Automatically deploys the service and approved best-performing chains. AB testing leaderboard, Monitoring dashboards
Domain data analysts Maintain few-shot SQL examples as extraction criteria and business landscapes change. Few-shot SQL dataset
Data governance organization Maintains standard business terminology used to create the Text-to-SQL glossary. Business terminology glossary

Data flow

Employees ask questions in Slack. The Router Supervisor identifies question purpose and sends each request to the appropriate chain. The retriever uses chain-specific search over VectorDBs, business terminology, table metadata, DDL, and few-shot SQL examples. GPT-4o then refines the question, reasons/searches through ReAct-style prompts, and generates, validates, interprets, or explains data artifacts. Feedback from Slack updates the GPT cache, while AB tests and leaderboards select best-performing prompts/chains for CI/CD deployment with monitoring and operational safeguards.

5 supporting quotes
“When a user asks a question, the Router Supervisor chain identifies the purpose of the question and categorizes it into the appropriate question type in real time.”article, stated
“The questions are then mapped to multi-chains (e.g. query generation, query interpretation, query syntax validation, table interpretation, log table utilization guide, and column and table utilization guide)”article, stated
“When executing multi-chains, utilize search algorithms for each chain to enable the retriever to selectively extract the necessary data.”article, stated
“Employees can easily ask questions and receive answers anytime on the Slack application. * Answers can be evaluated (satisfied/unsatisfied), which will be reflected in the GPT cache, expanding standardized data knowledge to other users. * For query”article, stated
“Answers can be evaluated (satisfied/unsatisfied), which will be reflected in the GPT cache, expanding standardized data knowledge to other users.”article, stated

Why this architecture

The team redesigned the hackathon prototype because a simple prompt against GPT-3.5/GPT-4 was not enough for company-specific Text-to-SQL. RAG provides internal knowledge; vector stores make domain data searchable; multi-chain routing supports several literacy tasks; Slack provides accessibility; and LLMOps infrastructure manages response stability, speed, error handling, experiments, and deployment.

4 supporting quotes
“the initial version had limitations in achieving systemization, efficiency, accessibility, and automation. #### (1) Establishment of an unstructured data pipeline based on vector store * We established a pipeline that can automatically collect”article, stated
“This model can answer general questions but cannot answer correctly to questions that are specific to a particular company because it has not learned data specific to that particular company.”article, stated
“RAG (Retrieval-Augmented Generation) addresses this issue by saving and searching internal data to improve the answer quality of LLM.”article, stated
“We built features and environments to enhance the service operation quality such as API load balancing, GPT caching, feedback loops, and operation monitoring dashboards”article, stated

Models used: OpenAI GPT-4o via Microsoft Azure OpenAI · Microsoft Azure OpenAI GPT-3.5 API in the hackathon prototype · Embedding models · LangChain · Router Supervisor chain

Scale

Alternatives considered (roads not taken)

Keep the hackathon GPT-3.5 prompt prototype

Rejected because: The initial version could not satisfy systemization, efficiency, accessibility, and automation requirements.

“The initial version of the development from Woowa Hackathon 2023 was simple, using prompts and Microsoft Azure OpenAI’s GPT-3.5 API.”article, stated
“However, we designed a new architecture because the initial version had limitations in achieving systemization, efficiency, accessibility, and automation.”article, stated

Generate SQL using only GPT-4

Rejected because: The resulting queries lacked domain/data-policy knowledge, included unnecessary data, and suffered from inconsistent hallucination-prone quality.

“Although we can generate queries using only GPT-4, the queries lack quality to be used for work because they lack knowledge of the domains and data policies of the company”article, stated
“Another problem is the inconsistent quality of the generated queries due to the inherent problem of LLM, hallucination.”article, stated

Use public Text-to-SQL metrics and leaderboards as-is

Rejected because: They did not adequately cover company-specific domain issues or business-priority metric changes.

“there are limitations when it comes to solving various business problems within the company using publicly available metrics and leaderboards.”article, stated
“it is challenging to address domain-specific issues that are not general issues, and it is difficult to update key metrics that are considered important based on the business situation.”article, stated

Use only basic table schemas

Rejected because: The team needed richer metadata with table purpose, characteristics, column descriptions, values, keywords, services, and questions.

“we added detailed information that had not been recorded previously, such as the purpose and characteristics of the table, detailed descriptions of columns, key values, and keywords.”article, stated
“Based on the table metadata, we were able to generate richer table DDL data than before. For the collection of table DDL data, we were able to easily add information and automatically collect the newest data through API, thanks to the well-established”article, stated

Stop at query generation

Rejected because: User questions increasingly involved data discovery, so QAB needed broader data-literacy features.

“we realized that a significant proportion of the questions was about data discovery, in addition to query generation.”article, stated
“This is why we decided to expand QAB’s features beyond Text-to-SQL to cover data discovery. While part 1 of the blog post focused on introducing QAB and the progress of building its Text-to-SQL feature, part 2 will cover the data discovery features of the”article, stated

Patterns

rag-retrieval (context-engineering)

QAB searches internal data, metadata, terminology, DDL, and few-shot examples so GPT-4o can answer company-specific SQL questions.

“RAG (Retrieval-Augmented Generation) addresses this issue by saving and searching internal data to improve the answer quality of LLM.”article, stated
“We added a feature to QAB that generates LLM responses based on domain knowledge using DocumentLoader, Vectorstore, and RAG QA provided by LangChain.”article, stated

query-rewriting (context-engineering)

Ambiguous, short, or unclear user questions are refined before retrieval and SQL generation.

“When a user question is ambiguous, short or unclear, refining the question can solve the problem.”article, stated
“Understanding business terms is essential when narrowing down a question”article, stated

tool-use-orchestration (agent-architecture)

The Router Supervisor selects among specialized chains, and ReAct prompts combine reasoning with retrieval/tool actions.

“the Router Supervisor chain identifies the purpose of the question and categorizes it into the appropriate question type in real time.”article, stated
“The ReAct method is divided into sequential reasoning (chain-of-thought, COT) for problem-solving and tools or actions for performing specific tasks.”article, stated

eval-driven-development (quality)

The team built internal evaluation data, dozens of metrics, leaderboards, weekly approvals, and more than 500 A/B tests.

“we developed our own evaluation metrics and data that serve as the foundation for measuring the internal Text-to-SQL performance”article, stated
“We built an internal leaderboard and conducted more than 500 A/B tests to bring our individual ideas to life.”article, stated

semantic-caching (operations)

GPT caching improves response speed and standardizes useful answers based on satisfaction feedback.

“GPT caching, feedback loops, and operation monitoring dashboards to ensure response stability, speed, and error handling.”article, stated
“Answers can be evaluated (satisfied/unsatisfied), which will be reflected in the GPT cache”article, stated

observability-tracing (operations)

Monitoring dashboards are part of the LLMOps layer for production response stability, speed, and error handling.

“operation monitoring dashboards to ensure response stability, speed, and error handling.”article, stated
“LLMOps (Large Language Model Operations) refers to the operation methods and tools for the deployment, management, and monitoring of LLMs.”article, stated

structured-output-contract (output-control)

Generated answers include SQL validation information so users know whether the query executes or contains errors.

“For query generation, the answer also provides an additional description of whether the generated query executes correctly or contains errors by validating the query.”article, stated

Tradeoffs

Redesign beyond the hackathon prototype

Chose A production architecture with RAG, multi-chain routing, Slack, and LLMOps over Simple GPT-3.5 prompts from the hackathon service.

Rationale: The hackathon architecture could not meet the four product pillars.

“The initial version of the development from Woowa Hackathon 2023 was simple, using prompts and Microsoft Azure OpenAI’s GPT-3.5 API.”article, stated
“we designed a new architecture because the initial version had limitations in achieving systemization, efficiency, accessibility, and automation.”article, stated

Use Slack instead of a web app

Chose Slack-based interface over Web-based method.

Rationale: Slack made the assistant easy and quick to access inside employees' existing messaging workflow.

“Accessibility: Use Slack, a workplace messaging tool, instead of a web-based method, to allow anyone to ask questions easily and quickly.”article, stated
“Employees can easily ask questions and receive answers anytime on the Slack application.”article, stated

Create custom internal metrics

Chose Internal Text-to-SQL evaluation metrics and data over Relying only on Spider, BIRD, or RAGAS-style public metrics.

Rationale: The team needed metrics that could track domain-specific issues and business priorities.

“The best-known leaderboards are YALE Spider and Alibaba BIRD.”article, stated
“there are limitations when it comes to solving various business problems within the company using publicly available metrics and leaderboards.”article, stated

Use leaderboard-gated deployment

Chose Weekly approval of best-performing test results before production over Manual or ad-hoc prompt/configuration deployment.

Rationale: The leaderboard gave the team a repeatable way to improve service performance while encouraging participation.

“The highest-performing results were approved during weekly sync-ups and then deployed to production, gradually enhancing service performance.”article, stated
“the ranking of individual results added a gamification element, which made it more enjoyable to participate.”article, stated

Maintain human-curated few-shot examples

Chose Domain analyst-managed SQL examples over Static or purely automatic example collection.

Rationale: Response quality depends on high-quality examples that track changing extraction criteria and business domains.

“we collected example data such as high-quality queries generated in advance by data analysts and additional queries about key business questions.”article, stated
“Few-show SQL example data must be managed by data analysts specializing in each domain”article, stated

Gotchas (what bit them)

GPT-only SQL looked plausible but was not work-ready.

Root cause: The generated queries lacked domain and data-policy knowledge, retrieval quality, and hallucination control.

Resolution: Use domain-grounded RAG, enriched metadata, search algorithms, prompt engineering, and testing/evaluation.

“the queries lack quality to be used for work because they lack knowledge of the domains and data policies of the company”article, stated
“Another problem is the inconsistent quality of the generated queries due to the inherent problem of LLM, hallucination.”article, stated

Company-specific business terms can mislead retrieval and question refinement.

Root cause: Similar but irrelevant terms may cause the LLM to generate incorrect reformulated questions.

Resolution: Use business-term extraction and a Text-to-SQL glossary managed through data governance.

“Extraction of similar yet irrelevant terms can lead to the LLM generating incorrect questions”article, stated
“A business terminology glossary dedicated to Text-to-SQL was created using the existing standard business terminology glossary.”article, stated

Few-shot quality becomes an operational dependency.

Root cause: Example queries directly affect response quality and business extraction criteria change over time.

Resolution: Collect high-quality analyst queries and have domain-specialized data analysts manage the examples.

“This plays a crucial part in feeding domain knowledge to the queries, so the higher the quality of the example queries, the better the responses will be.”article, stated
“Few-show SQL example data must be managed by data analysts specializing in each domain because of the ever-changing data extraction criteria and rapidly evolving business landscape.”article, stated

Public benchmarks could not encode internal business priorities.

Root cause: Domain-specific issues and key metrics change according to business situation.

Resolution: Build custom evaluation metrics/data while benchmarking public leaderboards.

“it is difficult to update key metrics that are considered important based on the business situation.”article, stated
“we developed our own evaluation metrics and data that serve as the foundation for measuring the internal Text-to-SQL performance”article, stated

The service still had business-logic and question-understanding accuracy gaps.

Root cause: Employees' questions and domains exposed limitations beyond initial query generation.

Resolution: Continue improvement using feedback, question histories, and broader data discovery features.

“there was some feedback saying that it has room to improve in terms of the accuracy of the business logic and understanding of the question.”article, stated
“we are currently carrying out tasks to improve QAB’s performance through various methods and tests, taking into account different feedback and question histories.”article, stated

Evaluation

The team built internal Text-to-SQL metrics and evaluation data, ran step-by-step tests from syntax understanding to execution accuracy with complex domain knowledge, built an automated evaluation system, measured dozens of detailed metrics, conducted more than 500 A/B tests, and promoted the best leaderboard results through weekly sync-ups into production.

Metrics: Internal Text-to-SQL performance · Query syntax understanding · Query execution accuracy · Complex-domain understanding · Actual user questions · Dozens of detailed metrics · A/B test leaderboard rank · Response stability · Response speed · Error handling · 30 seconds to 1 minute response time

4 supporting quotes
“Testing phases range from evaluating the understanding of query syntax to evaluating the accuracy of query execution results that incorporate complex domain knowledge.”article, stated
“we are testing to evaluate how well the Text-to-SQL feature understands complex domains and how accurate the query execution results are”article, stated
“we developed dozens of metrics so that detailed elements can all be measured.”article, stated
“We built an internal leaderboard and conducted more than 500 A/B tests to bring our individual ideas to life.”article, stated

Outcomes

Concrete scale includes about 95% employee data use, more than half struggling with SQL, January 2024 task-force formation, six months of development, three roadmap steps with two-week sprints, more than 500 A/B tests, two months to query generation/interpretation, 30-second-to-1-minute responses, and expanding test participants/target organizations.

5 supporting quotes
“At the hackathon, it was presented as a service that automatically extracts and visualizes data without the need for coding and won first place.”article, stated
“For the last six months, the task force has developed QAB even further so that it can generate queries and interpret queries, validate query syntax, explore tables”article, stated
“We were able to develop a query generation and interpretation feature in just two months through QAB’s basic architecture and Text-to-SQL feature.”article, stated
“Employees who newly joined the company or are in charge of different service domains say that QAB’s query generation and interpretation feature helped them greatly”article, stated
“This is why we decided to expand QAB’s features beyond Text-to-SQL to cover data discovery.”article, stated