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

delivery_hero · E-commerce · 2024 · source Agentic: yes · promotional bias: med · summary-only (no fetched source) · 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 data literacy and Text-to-SQL analytics

Woowa Brothers needed an internal AI data analyst that could help employees generate, understand, validate, and explore SQL without requiring every user to master company-specific data schemas and business terminology.

Constraints:

Architecture

QueryAnswerBird is a Slack-integrated AI data analyst built with GPT-4, LangChain, RAG, vector stores, enriched metadata, business terminology, few-shot SQL examples, a router-supervisor multi-chain architecture, and LLMOps infrastructure. The system retrieves domain context from unstructured data, table metadata, data catalogs, business glossaries, and analyst-maintained question-query examples, then routes each question to specialized chains for query generation, interpretation, syntax validation, table interpretation, or utilization guidance. Production operations include internal leaderboards, hundreds of A/B tests, monitoring dashboards, API load balancing, GPT caching, feedback loops, and CI/CD deployment.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  slack-user[Slack user] --> slack-integration[Slack integration]
  slack-integration --> 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 --> table-guide-chains[Table guide chains]
  query-generation-chain --> retriever[Retriever]
  query-interpretation-chain --> retriever
  table-guide-chains --> retriever
  retriever --> vector-stores[Vector stores]
  vector-stores --> data-catalog-apis[Data catalog APIs]
  retriever --> business-terminology-glossary[Business terminology glossary]
  business-terminology-glossary --> data-governance-organization[Data governance organization]
  retriever --> few-shot-sql-examples[Few-shot SQL examples]
  few-shot-sql-examples --> data-analysts[Data analysts]
  query-generation-chain --> gpt-4[GPT-4]
  query-interpretation-chain --> gpt-4
  syntax-validation-chain --> gpt-4
  table-guide-chains --> gpt-4
  gpt-4 --> gpt-cache[GPT cache]
  slack-integration --> feedback-loop[Feedback loop]
  feedback-loop --> gpt-cache
  experiment-leaderboard[Experiment leaderboard] --> ci-cd-pipeline[CI/CD pipeline]
  experiment-leaderboard --> monitoring-dashboards[Monitoring dashboards]
  ci-cd-pipeline --> monitoring-dashboards
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Slack user Employee asking natural-language data questions inside the existing workplace messaging workflow. Slack integration
Slack integration User-facing interface that receives questions, returns generated answers, and captures response feedback. Slack user, Router Supervisor chain, Feedback loop
Router Supervisor chain Classifies user questions by purpose and routes them to specialized data-literacy chains. Slack integration, Query generation chain, Query interpretation chain, Syntax validation chain, Table guide chains
Query generation chain Generates SQL from natural-language questions using retrieved metadata, terms, examples, and GPT-4. Router Supervisor chain, Retriever, GPT-4
Query interpretation chain Explains SQL queries and data usage to improve employee understanding. Router Supervisor chain, Retriever, GPT-4
Syntax validation chain Checks whether generated SQL executes correctly or contains errors. Router Supervisor chain, GPT-4
Table guide chains Provide table, column, and log-table utilization guidance for data discovery questions. Router Supervisor chain, Retriever, GPT-4
Retriever Selectively extracts relevant table metadata, DDL, terminology, and few-shot examples using chain-specific search algorithms. Vector stores, Business terminology glossary, Few-shot SQL examples, Query generation chain, Query interpretation chain, Table guide chains
Vector stores Store embedded business terminology, table metadata, extraction code, and enriched descriptions for similarity search. Retriever, Data catalog APIs
Data catalog APIs Provide latest data policies and metadata updates to the unstructured data pipeline. Vector stores
Business terminology glossary Standardizes domain-specific vocabulary used in user questions and SQL generation. Retriever, Data governance organization
Few-shot SQL examples Analyst-maintained question-query examples that inject domain knowledge into query generation. Retriever, Data analysts
GPT-4 Foundation model used to generate, interpret, refine, and validate data-analysis responses. Query generation chain, Query interpretation chain, Syntax validation chain, Table guide chains, GPT cache
GPT cache Caches common or similar responses to reduce latency, cost, and repeated API calls. GPT-4, Feedback loop
Experiment leaderboard A/B testing and ranking environment for prompts, retrievers, chains, and evaluation datasets. CI/CD pipeline, Monitoring dashboards
Monitoring dashboards Operational visibility into performance, errors, response times, and production health. Experiment leaderboard, CI/CD pipeline
CI/CD pipeline Automatically deploys approved high-performing chains and service changes. Experiment leaderboard, Monitoring dashboards
Feedback loop Uses satisfied/unsatisfied response feedback to improve cache behavior and standardized knowledge. Slack integration, GPT cache
Data analysts Domain specialists who maintain few-shot SQL examples as business logic changes. Few-shot SQL examples
Data governance organization Maintains business terminology standards used by the Text-to-SQL glossary. Business terminology glossary

Data flow

An employee asks a question in Slack. The Router Supervisor classifies the question and dispatches it to the right specialized chain. Chain-specific retrievers pull table metadata, enriched DDL, business terminology, and few-shot SQL examples from vector stores and curated knowledge bases. GPT-4 then generates or interprets SQL, validates syntax, or explains table usage. User feedback flows back into the cache and knowledge loop, while A/B testing, leaderboards, monitoring, load balancing, and CI/CD govern which prompts, retrievers, and chains reach production.

5 supporting quotes
“The new architecture comprises several sophisticated components working in concert to deliver high-quality responses consistently.”summary, stated
“When users ask questions, a Router Supervisor chain identifies the question's purpose and categorizes it into appropriate question types in real-time.”summary, stated
“Questions then map to specialized chains including query generation, query interpretation, query syntax validation, table interpretation, log table utilization guides, and column/table utilization guides.”summary, stated
“The system dynamically selects and combines these algorithms based on question characteristics. For few-shot SQL examples specifically, the algorithm selects the most similar examples to the user's question and adds related examples when appropriate. These”summary, stated
“The Slack integration includes response evaluation functionality where users can mark answers as satisfied or unsatisfied, creating a feedback loop that improves the system over time.”summary, stated

Why this architecture

The architecture addresses the gap between generic GPT-4 SQL ability and company-specific data reality. RAG, enriched metadata, business terminology, and few-shot examples provide domain grounding. Multi-chain routing avoids forcing one prompt to solve all data-literacy tasks. Slack integration lowers adoption friction, while testing, leaderboards, caching, monitoring, load balancing, and CI/CD make the system operable as a production LLM service.

5 supporting quotes
“while GPT-4 can generate high-quality SQL queries in general contexts, it lacks the domain-specific knowledge and understanding of company data policies necessary for production use”summary, stated
“daily through their established data catalog APIs. The data augmentation strategy represents a key differentiator in their approach. Drawing inspiration from the NeurIPS 2023 paper "Data Ambiguity Strikes Back: How Documentation Improves GPT's Text-to-SQL," the team enriched table metadata beyond”summary, stated
“During multi-chain execution, the system utilizes search algorithms customized for each chain, enabling the retriever to selectively extract necessary data.”summary, stated
“Rather than building a separate web application, the team integrated QAB directly into Slack, their existing workplace messaging platform.”summary, stated
“For production operations, the team implemented several critical features to ensure response stability, speed, and error handling.”summary, stated

Models used: GPT-4 · Microsoft Azure OpenAI GPT-3.5 API in hackathon prototype · Embedding models for vectorization · LangChain chains · Router Supervisor chain

Scale

Alternatives considered (roads not taken)

Rely on generic GPT-4 SQL generation

Rejected because: Generic GPT-4 lacks company-specific metadata, business terminology, and data-policy context.

“while GPT-4 can generate high-quality SQL queries in general contexts, it lacks the domain-specific knowledge and understanding of company data policies necessary for production use”summary, stated

Use the simple GPT-3.5 hackathon prompt architecture

Rejected because: The team redesigned the architecture to meet systemization, efficiency, accessibility, and automation goals.

“The initial hackathon version used simple prompts with Microsoft Azure OpenAI's GPT-3.5 API, but the team redesigned the architecture completely”summary, stated

Use a separate web application

Rejected because: Slack reduced adoption friction by placing QAB in employees' existing workflow.

“Rather than building a separate web application, the team integrated QAB directly into Slack, their existing workplace messaging platform.”summary, stated

Evaluate only with public leaderboards

Rejected because: Public benchmarks could not capture company-specific business priorities and domain problems.

“public leaderboards like YALE Spider, Alibaba BIRD, and metrics frameworks like RAGAS Score provide valuable evaluation approaches, they have limitations for solving company-specific business problems.”summary, stated

Use static schema metadata only

Rejected because: The team enriched metadata with purpose, characteristics, columns, key values, keywords, services, and example questions.

“While existing metadata was well-structured, they added detailed descriptions of table purpose and characteristics, comprehensive column descriptions, key values, keywords, commonly used services, and example questions”summary, stated

Patterns

rag-retrieval (context-engineering)

QAB retrieves table metadata, DDL, business terminology, policies, and few-shot examples to ground SQL generation in company context.

“The team established an unstructured data pipeline based on vector stores to address this knowledge gap.”summary, stated
“For extracting information necessary for query generation, the system combines various information types including table and column metadata, table DDL, and few-shot SQL examples.”summary, stated

query-rewriting (context-engineering)

The system refines ambiguous or short user questions before retrieval and generation.

“When user questions are ambiguous, short, or unclear, the system first refines the question.”summary, stated
“Understanding business terms is essential during this refinement stage”summary, stated

tool-use-orchestration (agent-architecture)

The Router Supervisor dispatches questions to specialized chains for generation, interpretation, validation, and table guidance.

“The team developed a RAG-based multi-chain structure to provide various data literacy features beyond simple query generation.”summary, stated
“Each chain can provide the best possible answer for its specific question type.”summary, stated

eval-driven-development (quality)

Internal datasets, metrics, leaderboards, and over 500 A/B tests governed prompt, retriever, and chain deployment.

“The team built an automated testing and evaluation system enabling anyone to easily evaluate performance.”summary, stated
“Critically, the team established an internal leaderboard and conducted over 500 A/B tests to iterate on various ideas.”summary, stated

semantic-caching (operations)

GPT caching reuses common or similar query responses, reducing latency and API cost while incorporating user feedback.

“GPT caching stores and reuses responses for common or similar queries, reducing latency and API costs while improving consistency.”summary, stated
“The caching system integrates with user feedback—when users evaluate answers as satisfactory or unsatisfactory, this feedback influences the cache, expanding standardized data knowledge to other users and creating a virtuous cycle of improvement.”summary, stated

observability-tracing (operations)

Monitoring dashboards track system performance, error rates, response times, and operational health.

“The team built operation monitoring dashboards providing visibility into system performance, error rates, response times, and other key metrics.”summary, stated
“This monitoring infrastructure enables proactive identification and resolution of issues before they significantly impact users.”summary, stated

structured-output-contract (output-control)

QAB produces SQL plus validation/explanation outputs and uses structured prompt categories for refinement and generation.

“For query generation specifically, responses include validation of whether the generated query executes correctly or contains errors”summary, stated
“The team applied sophisticated prompt engineering techniques, dividing prompts into question refinement and query generation categories”summary, stated

Tradeoffs

Use Slack as the interface

Chose Slack-integrated assistant over Separate web application.

Rationale: Employees could ask questions in their existing workflow without switching tools.

“This accessibility choice reduces friction for adoption—employees can ask questions and receive answers anytime within their existing workflow without switching contexts.”summary, stated

Use RAG and enriched metadata

Chose Domain-grounded retrieval over internal metadata, policies, terminology, and examples over Pure foundation-model prompting.

Rationale: Company-specific SQL requires context that the base model does not know.

“The team established an unstructured data pipeline based on vector stores to address this knowledge gap.”summary, stated
“The data augmentation strategy represents a key differentiator in their approach.”summary, stated

Use specialized chains

Chose Router Supervisor and multiple task-specific chains over A single query-generation chain.

Rationale: The product needed data-literacy features beyond generating SQL, including interpretation, validation, and table guides.

“provide various data literacy features beyond simple query generation.”summary, stated
“Each chain can provide the best possible answer for its specific question type.”summary, stated

Use internal leaderboards and A/B testing

Chose Quantitative competition among prompts, retrievers, chains, and datasets over Ad-hoc prompt deployment.

Rationale: The team wanted systematic performance improvement and approval before production deployment.

“The highest-performing results received approval during weekly sync-ups before deployment to production”summary, stated
“creating a systematic process for gradually enhancing service performance.”summary, stated

Cache common GPT responses

Chose GPT caching integrated with feedback over Calling the LLM from scratch for every common or similar query.

Rationale: Caching can reduce latency and API costs while improving consistency for repeated questions.

“GPT caching stores and reuses responses for common or similar queries, reducing latency and API costs while improving consistency.”summary, stated

Gotchas (what bit them)

Foundation models lacked company-specific data semantics.

Root cause: GPT-4 can generate SQL generally but does not know internal table policies, business terminology, or data marts.

Resolution: Ground generation through RAG over enriched metadata, business glossaries, and few-shot examples.

“it lacks the domain-specific knowledge and understanding of company data policies necessary for production use in a business environment.”summary, stated
“This enriched metadata feeds into DDL data generation that provides much richer context than standard table schemas.”summary, stated

Business terminology varies across services and organizations.

Root cause: Terms used differently across teams can cause miscommunication and incorrect SQL interpretation.

Resolution: Use a dedicated Text-to-SQL business terminology glossary maintained through data governance.

“This standardization prevents miscommunication arising from terms being used differently across services and organizations.”summary, stated
“The glossary integrates into the retrieval pipeline to ensure proper interpretation of domain-specific language.”summary, stated

Public Text-to-SQL metrics did not fully fit internal business needs.

Root cause: Public leaderboards and frameworks struggle with domain-specific priorities and company-specific data problems.

Resolution: Build custom internal evaluation datasets, metrics, and leaderboards.

“Public metrics struggle with domain-specific issues and cannot adapt to business-specific priorities.”summary, stated
“the team developed custom evaluation metrics and datasets serving as the foundation for measuring internal Text-to-SQL performance”summary, stated

Few-shot examples and terminology require ongoing human maintenance.

Root cause: Business logic and data extraction criteria change over time across domains.

Resolution: Have domain-specialist data analysts maintain and update examples and glossary data.

“The quality of these examples directly impacts response quality”summary, stated
“data analysts specializing in each domain maintain and update examples as business logic and data extraction criteria evolve.”summary, stated

The case study leaves production failure rates under-specified.

Root cause: The source is promotional and does not quantify detailed error rates or production performance against evaluation datasets.

Resolution: Treat reported outcomes as directional and rely on the described evaluation/monitoring machinery rather than unsupported accuracy claims.

“the case study is written as promotional content for both recruiting and showcasing technical capabilities, so claims should be interpreted with appropriate skepticism.”summary, stated
“they don't quantify error rates, false positive/negative rates, or provide detailed metrics on actual production performance versus their evaluation datasets.”summary, stated

Evaluation

The team moved beyond public benchmarks by building internal Text-to-SQL datasets, custom metrics, automated testing, dozens of detailed metrics, internal leaderboards, and over 500 A/B tests. High-performing configurations were approved in weekly sync-ups before production deployment, while LangServe Playground supported rapid prompt and chain checks.

Metrics: Custom Text-to-SQL performance metrics · Query syntax understanding · Query execution-result accuracy · Complex-domain understanding · Actual user questions · Dozens of detailed metrics · Internal leaderboard rank · Over 500 A/B tests · System performance · Error rates · Response times

4 supporting quotes
“The evaluation approach progresses through multiple stages, from evaluating understanding of query syntax to assessing accuracy of query execution results incorporating complex domain knowledge.”summary, stated
“The team built an automated testing and evaluation system enabling anyone to easily evaluate performance.”summary, stated
“The system includes dozens of metrics to measure detailed performance aspects comprehensively.”summary, stated
“Critically, the team established an internal leaderboard and conducted over 500 A/B tests to iterate on various ideas.”summary, stated

Outcomes

The source reports 95% employee data use, more than half struggling with SQL, a 2023 first-place hackathon result, a January 2024 task force, six months of production development, over 500 A/B tests, typical 30-60 second responses, two-month implementation of query generation/interpretation features, and three two-week sprint steps.

5 supporting quotes
“Following strong internal demand, the company established the Langineer Task Force in January 2024 to develop a production-grade system over six months.”summary, stated
“The team successfully developed query generation and interpretation features within two months through their architecture and Text-to-SQL implementation.”summary, stated
“Employees newly joining the company or handling different service domains reported that QAB's features greatly helped them understand their work.”summary, stated
“feedback indicated room for improvement in accuracy of business logic understanding and question interpretation.”summary, stated
“they discovered that a significant proportion of questions concerned data discovery”summary, stated