Ai4
Enterprise text-to-SQL reliability requires dedicating 80% of engineering effort to metadata curation and scoping queries to curated domain views rather than expanding LLM context windows.
AI-assisted summary of Research to Reality: Robust NLP to Analytics with LLMs at Scale With Asurion — original source. Check the original for full context.
Source published:
Detailed notes
## Background Published by Ai4 on YouTube on August 26, 2025, this presentation features Karthik Raparthi, Lead ML/Data Engineer at Asurion. According to the page description, the talk covers how Asurion transformed NLP research into an enterprise-grade text-to-SQL system that cut query development time by 50x while addressing metadata sparsity, deterministic generation, and user trust.
## TL;DR Karthik Raparthi details Asurion's multi-phase evolution from failed zero-shot and brittle few-shot prompting to an enterprise retrieval-augmented generation (RAG) platform that translates plain-English business prompts into SQL queries, tabular data, and visual charts. To overcome severe enterprise challenges, Asurion automated metadata enrichment across thousands of tables using historical query logs and decomposed requests into modular units—such as explicit KPIs, metrics, filters, and dimensions—ensuring deterministic query generation. The production system incorporates an automated self-healing retry loop, OpenSearch hybrid search, strict read-only guardrails, and role-based domain scoping to narrow table candidates to roughly 20 curated enterprise views. In the closing Q&A, Raparthi elaborates on managing multi-turn session memory with DynamoDB and powering dynamic visualizations via LLM-generated Python scripts and PyGWalker.
## Atmosphere & style The presentation carries the pragmatic, battle-tested tone of a senior engineer recounting real-world lessons from the trenches rather than hyping unproven AI promises. Raparthi delivers a clear, systematically structured walkthrough that balances frank admissions of early failures with tangible architectural blueprints. The atmosphere feels like an intimate industry breakout session, marked by focused technical depth, practical problem-solving, and thoughtful, candid interactions during the audience Q&A.
## Key takeaways - [00:04](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=4s) Asurion supports over 300 million global subscribers across 15 countries, operating at a massive scale that requires efficient data access for operational decisions. - [01:09](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=69s) Business users face data access bottlenecks due to lack of SQL fluency, forcing them to rely on data engineers and wait hours, days, or weeks for analytical queries. - [02:14](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=134s) Zero-shot prompting completely failed for enterprise text-to-SQL generation, while few-shot prompting failed to scale across diverse domain requirements. - [02:14](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=134s) Standard RAG improved schema awareness, but LLMs still struggled with analytical queries until business metrics, KPIs, and filter logic were explicitly modeled. - [03:47](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=227s) The production platform provides an automated retry mechanism that feeds database error messages back into the LLM up to three times to self-heal failed SQL queries. - [04:56](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=296s) Phase 1 architecture incorporated dual-intent routing to separate knowledge documentation requests from SQL data queries, along with read-only security guardrails. - [04:56](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=296s) Implementing the text-to-SQL solution delivered a 50x acceleration in query turnaround time across the enterprise. - [07:51](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=471s) Data curation and metadata modeling account for 80% of the total effort in building reliable NLP-to-analytics systems, compared to only 20% for LLM execution and UI. - [07:51](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=471s) Asurion used LLMs to reverse-engineer historical SQL logs to fill missing metadata, pruning table candidates from over 1,000 down to roughly 20 domain views. - [07:51](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=471s) To achieve deterministic reporting, complex user queries are decomposed into atomic business units (KPIs, metrics, filters, and dimensions) tied to pre-defined formulas. - [12:11](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=731s) Accuracy was drastically improved by restricting the retrieval search scope to federated domain boundaries and curated enterprise views based on user authentication. - [12:11](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=731s) To prevent context dilution during multi-turn conversations, DynamoDB session history is strictly capped to the last five conversational turns. - [12:11](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=731s) Visualizations are generated dynamically using either LLM-generated Python rendering code or the embedded PyGWalker drag-and-drop tool for user exploration.
## Detailed walkthrough ### [00:04](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=4s) Introduction and Company Background
Karthik Raparthi, Lead ML/Data Engineer at Asurion, introduces the presentation on taking natural language processing (NLP) to analytics from "research to reality" at enterprise scale. Asurion operates as a global tech-care company supporting over 300 million subscribers across approximately 15 countries. The company handles services spanning mobile repairs, major appliances, and connected home ecosystems, supported by roughly 9,000 experts and 24/7 live chat operations.
```mermaid flowchart LR accTitle: Asurion Scale Overview A["Asurion Tech Care"] --> B["300M+ Global Subscribers"] A --> C["15 Countries"] A --> D["9,000 Experts & 24/7 Support"] A --> E["Mobile, Appliances & Connected Home"] ```
The presentation focuses on the operational challenges and multi-phase architecture behind building an enterprise-grade text-to-SQL platform that bridges the gap between non-technical business stakeholders and complex enterprise data warehouses.
---
[01:09](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=69s) The Business Problem: Technical Bottlenecks in Data Access
Business users routinely need answers to data-driven and analytical questions to make critical operational decisions. However, they frequently run into technical barriers. While business users possess deep domain expertise, they often lack SQL fluency and must rely on data engineers or analysts to write queries for them.
This reliance creates severe bottlenecks. Business stakeholders often wait days, weeks, or even hours for routine data requests, introducing friction and delays into decision-making cycles. Asurion set out to build an AI assistant capable of translating plain English business prompts into accurate SQL queries, summarized insights, and visual analytics within minutes or seconds.
---
[02:14](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=134s) The Prompting Evolution: Zero-Shot, Few-Shot, and RAG
Asurion's journey began with standard prompting techniques before arriving at a robust retrieval-augmented generation (RAG) architecture:
```mermaid flowchart TD accTitle: NLP to Analytics Prompting Evolution A["Phase 0: Zero-Shot Prompting<br/>(No context provided)"] -->|Complete failure / Irrelevant SQL| B["Phase 0.5: Few-Shot Prompting<br/>(Hardcoded SQL examples)"] B -->|Fails to scale across domain variety| C["Phase 1: Standard RAG<br/>(Table/column descriptions & terminology)"] C -->|Lacks metric & filter awareness| D["Phase 2: KPI-Driven RAG + Feedback Loop<br/>(Deterministic modular units)"] ```
- **Zero-Shot Prompting:** The initial experiment provided plain prompts to the LLM without database context. This failed entirely, producing inaccurate or completely irrelevant SQL queries. - **Few-Shot Prompting:** In-context SQL examples were added to guide the model. While effective for narrow test cases, few-shot prompting broke down at scale because manually curating and fitting hundreds of domain-specific SQL examples into prompt windows was unsustainable. - **Standard Table/Column RAG:** Retrieval-Augmented Generation was introduced to dynamically retrieve table descriptions, column definitions, and business terminology. This significantly improved relevance, but the LLM still struggled with complex analytical queries because it lacked explicit awareness of business metrics, key performance indicators (KPIs), and filtering logic.
---
[03:47](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=227s) User Interface and Self-Healing Query Execution
The production user interface allows users to enter a plain-English question (such as *"What are the insights for my claims?"*) and returns an executive summary, supporting tabular data, and dynamic chart visualizations.
Under the hood, the system exposes full context and query execution mechanics: - **Chain-of-Thought & Context Attribution:** Users and analysts can inspect the generated SQL query, see the underlying tables used, and review the retrieval relevancy scores returned by the RAG vector store. - **Self-Healing Retry Mechanism:** If the database engine returns an error upon executing the generated SQL, the system enters an automated retry loop. It feeds the error message back to the LLM to debug and fix the query in real time, capped at a limit of three retries. - **Continuous User Feedback:** Feedback collection widgets (thumbs up/down and text notes) allow business users and analysts to flag incorrect intent, wrong schemas, or bad outputs, continuously enriching the downstream semantic retrieval cache.
---
[04:56](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=296s) Phase 1 Architecture: Intent Routing, Hybrid Search, and Guardrails
The Phase 1 architecture integrates query routing, hybrid vector retrieval, and database execution:
```mermaid flowchart TD accTitle: Phase 1 System Architecture User["Business User Query (Plain English)"] --> Intent["Intent Classification & Security Guardrails"] Intent -->|"Document Intent (Definitions, Churn rate, TAT)"| DocAgent["Knowledge Document Agent"] Intent -->|"Data Intent (Analytics / Metrics)"| ContextAgent["Context Gathering Agent"]
subgraph UKF["Unified Knowledge Foundation (OpenSearch Vector Store)"] Tables["Table & Column Descriptions"] Terms["Business Terminology & Synonyms"] Examples["Few-Shot Query Examples"] KPIs["KPI Definitions & Documentation"] end
UKF <-->|"Hybrid Search"| ContextAgent ContextAgent --> SQLGen["SQL Generation Agent"] SQLGen --> DBEngine["Database Execution Engine"] DBEngine -->|"Execution Error"| Retry{"Retry Loop (Max 3)"} Retry -->|Fix Query| SQLGen DBEngine -->|"Success"| Insights["Insights, Tabular Data & Visualizations"] Insights --> Feedback["Continuous Feedback Loop"] Feedback --> UKF ```
- **Dual-Intent Routing:** The orchestrator determines whether an incoming prompt is a *documentation question* (e.g., explaining business definitions such as *"What is churn rate?"* or *"What is turnaround time?"*) or a *data query* requiring SQL generation. - **Security Guardrails:** Hard constraints prevent prompt injection attacks and restrict database operations strictly to read-only `SELECT` statements. - **Hybrid Search Context Retrieval:** OpenSearch runs hybrid semantic and keyword search across table descriptions, column schemas, few-shot examples, and business glossaries. - **Measurable Business Impact:** The deployment delivered an estimated 50x acceleration in query turnaround time, shrinking data delivery cycles from days or weeks down to immediate answers.
---
[07:51](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=471s) The Phase 2 Shift: Solving Metadata Sparsity and Non-Determinism
Despite the success of Phase 1, Asurion identified core bottlenecks preventing enterprise reliability:
``` Total Effort Breakdown in NLP-to-Analytics: [████████████████░░░░] 80% Data Curation & Metadata Modeling [░░░░░░░░░░░░░░░░████] 20% LLM Execution, Semantic Search & UI ```
1. **Metadata Sparsity (80% of the effort):** Enterprise data environments suffer from missing or inconsistent documentation. The term "customer" might be represented across dozens of disconnected tables with varying business definitions. To solve this, Asurion used LLMs to reverse-engineer historical SQL logs and generate standardized table descriptions, column-level annotations, and domain synonyms. This contextual pruning narrowed search candidate spaces from over 1,000 tables down to roughly 20 domain-specific tables. 2. **Deterministic Query Generation:** LLMs are inherently non-deterministic, posing risks when analytical queries must return identical underlying numbers. Asurion addressed this by modularizing queries into atomic business units: decomposing requests into explicit **KPIs**, **metrics**, **filters**, and **dimensions**. Rather than relying on the LLM to guess business logic, pre-defined KPI calculations stored within the vector knowledge store guide deterministic SQL synthesis.
```mermaid flowchart TD accTitle: Phase 2 KPI-Driven Architecture A["Plain English User Prompt"] --> B["Atomic Parsing:<br/>KPIs, Metrics, Filters, Dimensions"] B --> C["Pre-Defined Domain Vector Store<br/>(Curated Enterprise Views & KPI Formulas)"] C --> D["Deterministic SQL Synthesis Engine"] D --> E["Identical Business Results Across Query Variations"] ```
---
[11:05](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=665s) Key Takeaways and Architectural Best Practices
- **Metadata as a Mandatory Foundation:** Metadata cannot be treated as a "nice-to-have." Organizations must establish mandatory data modeling pipelines and automated quality checks whenever a new data mart or domain is introduced. - **Modular Query Decomposition:** Complex business queries must be broken down into discrete components (KPI formulas, dimension slices, and predicate filters) before prompt assembly to guarantee consistency. - **Enterprise Data Democratization:** Standardizing data access empowers non-technical business users to self-serve insights while freeing data engineering resources from ad-hoc query backlogs.
---
[12:11](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=731s) Audience Q&A: Accuracy, Multi-Turn Context, and Visualization Tools
#### Query Accuracy and Enterprise Scoping An audience member noted that a 90% accuracy rate still implies a 10% error margin, questioning whether that is sufficient for deterministic reporting. Karthik agreed that "90% is good but not good enough," explaining that initial naive implementations hovered around an unacceptable 40–50% accuracy.
To improve reliability, Asurion scoped query generation to federated domain boundaries (such as HR, Finance, or Sales) rather than searching across the entire enterprise warehouse. When an authenticated user logs in, the engine restricts its search scope strictly to the ~20 curated enterprise views relevant to their department.
```mermaid flowchart LR accTitle: Federated Domain Access Scoping User["Authenticated User"] --> Role{"Federated Domain Check"} Role -->|"Finance"| FinTables["Finance Data Mart (~20 Views)"] Role -->|"HR"| HRTables["HR Data Mart (~20 Views)"] Role -->|"Sales"| SalesTables["Sales Data Mart (~20 Views)"] ```
#### Table Selection Across Fragmented Views When asked how the system selects canonical tables among hundreds of user-generated views and aggregated variants, Karthik explained that the text-to-SQL bot is deliberately pointed at curated **Enterprise Views** and pre-aggregated data marts containing formal KPI definitions.
#### Multi-Turn Memory Management Addressing multi-turn conversational follow-ups, Karthik explained that the platform uses DynamoDB to store conversational history. To prevent context dilution—where prolonged conversations degrade LLM attention and retrieval relevance—the context window is strictly capped to the last five conversational turns within an active session.
#### Dynamic Data Visualization When asked whether chart generation is dynamic or pre-scripted, Karthik clarified that two methods are supported: - **LLM-Generated Python Code:** The LLM dynamically produces backend Python code to render charts based on query results. - **Interactive UI with PyGWalker:** The interface embeds PyGWalker, an open-source visual exploration tool that lets users drag and drop fields to dynamically build custom charts.
## Notable quotes > [03:47](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=227s) What are the insights for my claims?
> [04:56](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=296s) What is churn rate?
> [04:56](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=296s) What is turnaround time?
> [12:11](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=731s) 90% is good but not good enough — Karthik Raparthi
> [07:51](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=471s) customer
> [04:56](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=296s) SELECT
> [00:04](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=4s) research to reality — Karthik Raparthi
> [11:05](https://www.youtube.com/watch?v=iPiyDfpyJAA&t=665s) nice-to-have
## Mentioned Karthik Raparthi, Asurion, Ai4, OpenSearch, DynamoDB, PyGWalker, Python, SQL
## Video description Karthik Raparthi, Lead ML/Data Engineer, Asurion
Abstracts
In this talk, I will reveal how we transformed natural language processing from promising research into a production-grade text-to-SQL system that cut query development time by 50x. I will share the journey of scaling our NLP solution beyond simple demos to handle thousands of tables and complex business terminologies across a global enterprise. You'll learn our practical approach to solving the core challenges of metadata sparsity, deterministic query generation, and building user trust in AI-generated SQL. Join me to discover proven methods for democratizing data access that will help you avoid common pitfalls and accelerate your own text-to-SQL implementation.
[Source](https://www.youtube.com/watch?v=iPiyDfpyJAA)