{"id":1908,"date":"2026-03-13T15:00:14","date_gmt":"2026-03-13T15:00:14","guid":{"rendered":"https:\/\/blog.ibvl.in\/index.php\/2026\/03\/13\/unlocking-the-power-of-data-how-we-built-text-to-sql-with-agentic-rag-at-rocket-mortgage\/"},"modified":"2026-03-13T15:00:14","modified_gmt":"2026-03-13T15:00:14","slug":"unlocking-the-power-of-data-how-we-built-text-to-sql-with-agentic-rag-at-rocket-mortgage","status":"publish","type":"post","link":"https:\/\/blog.ibvl.in\/index.php\/2026\/03\/13\/unlocking-the-power-of-data-how-we-built-text-to-sql-with-agentic-rag-at-rocket-mortgage\/","title":{"rendered":"Unlocking the power of data: How we built text-to-SQL with agentic RAG at Rocket Mortgage"},"content":{"rendered":"<p>Picture this: your company sits on tens of petabytes of data. To put that into perspective, if I had a penny for each byte and stacked them up, I&#8217;d have enough to reach Pluto and back, with some change left over. That\u2019s the reality we face at Rocket Mortgage, and it&#8217;s probably not too different from what your organization is facing.\ud83d\udca1All that data represents a goldmine of insights, but the challenge has always been making it accessible to the people who need it most (executives, analysts, and decision-makers who understand the business but don\u2019t necessarily code SQL in their sleep.)That\u2019s why we built Rocket Analytics, and today I want to take you behind the scenes of how we created a text-to-SQL application using agentic RAG (Retrieval-Augmented Generation). This tool fundamentally changes how our teams interact with data, letting them focus on what they do best: asking strategic and thoughtful questions, while the system handles the technical heavy lifting.What Rocket Analytics actually doesHere\u2019s how it works in practice: a user asks a natural language question, such as:\u201cGive me the count of loans for the past six months.\u201dBehind the scenes, the system:Converts the question into a SQL queryExecutes it against the relevant databaseReturns the results in a clean, understandable format\ud83d\udca1But the real magic comes when users ask follow-up questions. They can request insights based on the initial results, or generate dashboards highlighting actionable patterns and trends.During a recent demo, someone went from raw loan counts to a comprehensive dashboard showing:Total loans closedAverage daily loansMaximum daily loan datesTrend analysis\u2014all within seconds. For executives and stakeholders in the mortgage industry, where speed of decision-making is crucial, this capability is transformative.The architecture behind the magicRocket Analytics relies on several key components, each playing a critical role in delivering accurate results.Query transformation: Making questions understandableThe journey starts when a user inputs their question. Large language models, while powerful, don\u2019t inherently understand our specific business context or data structures. Ask ChatGPT, for example:\u201cCan you give me the top ten days for loan production?\u201dIt won\u2019t know exactly what you mean.Our query transformation module converts natural language into explicit, actionable instructions. That same question becomes:\u201cWrite a SQL query to get the top ten days based on loan closing.\u201dThis step is crucial because we never pass actual data to the model\u2014only metadata about our database structures.Building and managing the knowledge baseBefore queries can be answered, we need a comprehensive knowledge base. We:Convert database metadata into embeddings using Amazon TitanStore them in a FAISS (Facebook AI Similarity Search) vector storeInclude information about all tables, schemas, relationships, and business contextThis knowledge base is the foundation that allows the system to understand which tables might be relevant for any given question.Intelligent retrieval: Finding the right data sourcesWhen a question comes in, we perform a hybrid search:Semantic similarity search identifies potentially relevant tablesKeyword triggers ensure critical tables are included even if semantic search alone misses themFor example, a knowledge base with 15 tables might be narrowed down to 4\u20135 most relevant. This ensures the LLM is not overwhelmed and reduces errors.Re-ranking for precisionOnce candidate tables are retrieved, we use Cohere\u2019s re-ranker model (BART-based) to refine selection. This classification system evaluates the likelihood of each document being relevant to the user\u2019s question.This step is essential for preventing hallucinations, ensuring the LLM generates accurate SQL queries based only on relevant metadata.Prompt engineering: The art and scienceCrafting prompts involves multiple layers:Standard guidelines: Always answer within context; use exact table and column namesAdaptive guidelines: Few-shot examples for tricky question typesDomain-specific context: Helps the model understand mortgage-industry terminologyA typical prompt looks like:\ud83d\udca1\u201cGiven the below two tables and their detailed metadata information, please answer the question at the end of the prompt, keeping the below guidelines in mind\u2026\u201dThis carefully crafted prompt ensures accuracy while guiding the model through complex queries.Execution and post-processingOnce the LLM generates a SQL query:Execute it against the appropriate databasePost-process results to make them user-friendlyUsers can consume results as-is or ask follow-up questionsFor instance, a user reviewing six months of loan data can then ask:\u201cCan you show me some insights?\u201dThe system will automatically generate visualizations and highlight actionable trends, all within seconds.The agentic framework: Orchestrating complexitySo far, we\u2019ve described a single agent handling queries in one domain. But organizations often need cross-domain insights.Our agentic framework introduces:A main orchestrator agentSub-agents specialized in domains like sales, marketing, and operationsEach sub-agent has its own knowledge base and optimized promptsCurrently, each agent operates within domain constraints. The next step is multi-agent coordination, enabling cross-domain queries without manual integration.Performance optimization: Speed and cost matterTwo strategies have made a big difference:Semantic cachingAvoids redundant processing by reusing tables and prompts for semantically similar questionsRequires careful tuning to handle subtleties like \u201cpast six months\u201d vs. \u201cpast ten days\u201dPrompt cachingCaches static prompt componentsReduces computation and improves latency and cost efficiencyThese optimizations help Rocket Analytics scale across teams without slowing down queries.Measuring success: How we know it\u2019s workingWe evaluate the system with several key metrics:Relevance: Are retrieved tables truly relevant? Checked using LLM-as-a-judgeHallucination detection: Compares outputs against a golden datasetToxicity screening: Ensures all responses are professionalMultiple iterations per query give a reliable performance overview and help catch edge cases.Real-world impact: Who benefits and how?Rocket Analytics helps teams across the organization:Sales &amp; MarketingAnalyze campaign effectivenessIdentify seasonal trendsCompare strategies across segmentsOperationsMonitor performance metricsOptimize processesFinanceGenerate reports instantlyAnalyze trendsPreviously, these insights took days to produce via analysts; now they\u2019re available in seconds.The human element: Trust but verifyAI accelerates insight, but human oversight is critical:Human-in-the-loop checkpoints for high-stakes queriesRegular audits to catch drift or emerging errorsEnsures speed and accuracy without compromising trustLooking ahead: The evolution continuesOur roadmap includes:Multi-agent coordination for cross-domain insightsContinuous performance improvementsExpanded domain coverage for more teamsBy democratizing data access, Rocket Analytics enables any team member to make data-driven decisions, without SQL expertise.Final thoughtsBuilding a text-to-SQL system with agentic RAG has taught us:AI can augment human intelligence, not replace itSpeed, accuracy, and accessibility matter more than sheer complexityThoughtful implementation and user-centered design are keyBy removing technical barriers, Rocket Analytics empowers more people to explore, analyze, and act on data, creating a competitive advantage.The goal isn\u2019t to build the most sophisticated AI but to build the most useful AI.Arjun Barli, Staff Data Scientist at Rocket Mortgage, gave this presentation at our  Agentic AI Summit, New York, 2025. <\/p>\n","protected":false},"excerpt":{"rendered":"<div>Your company\u2019s data holds answers, but accessing them is often the hard part. Here\u2019s how Rocket Mortgage built a text-to-SQL system with agentic RAG to make data accessible to everyone.<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[1,755,23,22],"tags":[3],"class_list":["post-1908","post","type-post","status-publish","format-standard","hentry","category-ai-and-ml","category-ai-infrastructure","category-articles","category-membership-content","tag-ai"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Unlocking the power of data: How we built text-to-SQL with agentic RAG at Rocket Mortgage - Imperative Business Ventures Limited<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.ibvl.in\/index.php\/2026\/03\/13\/unlocking-the-power-of-data-how-we-built-text-to-sql-with-agentic-rag-at-rocket-mortgage\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Unlocking the power of data: How we built text-to-SQL with agentic RAG at Rocket Mortgage - Imperative Business Ventures Limited\" \/>\n<meta property=\"og:description\" content=\"Your company\u2019s data holds answers, but accessing them is often the hard part. Here\u2019s how Rocket Mortgage built a text-to-SQL system with agentic RAG to make data accessible to everyone.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.ibvl.in\/index.php\/2026\/03\/13\/unlocking-the-power-of-data-how-we-built-text-to-sql-with-agentic-rag-at-rocket-mortgage\/\" \/>\n<meta property=\"og:site_name\" content=\"Imperative Business Ventures Limited\" \/>\n<meta property=\"article:published_time\" content=\"2026-03-13T15:00:14+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/blog.ibvl.in\/index.php\/2026\/03\/13\/unlocking-the-power-of-data-how-we-built-text-to-sql-with-agentic-rag-at-rocket-mortgage\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/blog.ibvl.in\/index.php\/2026\/03\/13\/unlocking-the-power-of-data-how-we-built-text-to-sql-with-agentic-rag-at-rocket-mortgage\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/blog.ibvl.in\/#\/schema\/person\/55b87b72a56b1bbe9295fe5ef7a20b02\"},\"headline\":\"Unlocking the power of data: How we built text-to-SQL with agentic RAG at Rocket Mortgage\",\"datePublished\":\"2026-03-13T15:00:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/blog.ibvl.in\/index.php\/2026\/03\/13\/unlocking-the-power-of-data-how-we-built-text-to-sql-with-agentic-rag-at-rocket-mortgage\/\"},\"wordCount\":1112,\"keywords\":[\"AI\"],\"articleSection\":[\"AI and ML\",\"AI Infrastructure\",\"Articles\",\"Membership content\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blog.ibvl.in\/index.php\/2026\/03\/13\/unlocking-the-power-of-data-how-we-built-text-to-sql-with-agentic-rag-at-rocket-mortgage\/\",\"url\":\"https:\/\/blog.ibvl.in\/index.php\/2026\/03\/13\/unlocking-the-power-of-data-how-we-built-text-to-sql-with-agentic-rag-at-rocket-mortgage\/\",\"name\":\"Unlocking the power of data: How we built text-to-SQL with agentic RAG at Rocket Mortgage - Imperative Business Ventures Limited\",\"isPartOf\":{\"@id\":\"https:\/\/blog.ibvl.in\/#website\"},\"datePublished\":\"2026-03-13T15:00:14+00:00\",\"author\":{\"@id\":\"https:\/\/blog.ibvl.in\/#\/schema\/person\/55b87b72a56b1bbe9295fe5ef7a20b02\"},\"breadcrumb\":{\"@id\":\"https:\/\/blog.ibvl.in\/index.php\/2026\/03\/13\/unlocking-the-power-of-data-how-we-built-text-to-sql-with-agentic-rag-at-rocket-mortgage\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blog.ibvl.in\/index.php\/2026\/03\/13\/unlocking-the-power-of-data-how-we-built-text-to-sql-with-agentic-rag-at-rocket-mortgage\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/blog.ibvl.in\/index.php\/2026\/03\/13\/unlocking-the-power-of-data-how-we-built-text-to-sql-with-agentic-rag-at-rocket-mortgage\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/blog.ibvl.in\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Unlocking the power of data: How we built text-to-SQL with agentic RAG at Rocket Mortgage\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/blog.ibvl.in\/#website\",\"url\":\"https:\/\/blog.ibvl.in\/\",\"name\":\"Imperative Business Ventures Limited\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/blog.ibvl.in\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/blog.ibvl.in\/#\/schema\/person\/55b87b72a56b1bbe9295fe5ef7a20b02\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/blog.ibvl.in\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4d20b2cd313e4417a599678e950e6fb7d4dfa178a72f2b769335a08aaa615aa9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4d20b2cd313e4417a599678e950e6fb7d4dfa178a72f2b769335a08aaa615aa9?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"https:\/\/blog.ibvl.in\"],\"url\":\"https:\/\/blog.ibvl.in\/index.php\/author\/admin_hcbs9yw6\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Unlocking the power of data: How we built text-to-SQL with agentic RAG at Rocket Mortgage - Imperative Business Ventures Limited","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.ibvl.in\/index.php\/2026\/03\/13\/unlocking-the-power-of-data-how-we-built-text-to-sql-with-agentic-rag-at-rocket-mortgage\/","og_locale":"en_US","og_type":"article","og_title":"Unlocking the power of data: How we built text-to-SQL with agentic RAG at Rocket Mortgage - Imperative Business Ventures Limited","og_description":"Your company\u2019s data holds answers, but accessing them is often the hard part. Here\u2019s how Rocket Mortgage built a text-to-SQL system with agentic RAG to make data accessible to everyone.","og_url":"https:\/\/blog.ibvl.in\/index.php\/2026\/03\/13\/unlocking-the-power-of-data-how-we-built-text-to-sql-with-agentic-rag-at-rocket-mortgage\/","og_site_name":"Imperative Business Ventures Limited","article_published_time":"2026-03-13T15:00:14+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blog.ibvl.in\/index.php\/2026\/03\/13\/unlocking-the-power-of-data-how-we-built-text-to-sql-with-agentic-rag-at-rocket-mortgage\/#article","isPartOf":{"@id":"https:\/\/blog.ibvl.in\/index.php\/2026\/03\/13\/unlocking-the-power-of-data-how-we-built-text-to-sql-with-agentic-rag-at-rocket-mortgage\/"},"author":{"name":"admin","@id":"https:\/\/blog.ibvl.in\/#\/schema\/person\/55b87b72a56b1bbe9295fe5ef7a20b02"},"headline":"Unlocking the power of data: How we built text-to-SQL with agentic RAG at Rocket Mortgage","datePublished":"2026-03-13T15:00:14+00:00","mainEntityOfPage":{"@id":"https:\/\/blog.ibvl.in\/index.php\/2026\/03\/13\/unlocking-the-power-of-data-how-we-built-text-to-sql-with-agentic-rag-at-rocket-mortgage\/"},"wordCount":1112,"keywords":["AI"],"articleSection":["AI and ML","AI Infrastructure","Articles","Membership content"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/blog.ibvl.in\/index.php\/2026\/03\/13\/unlocking-the-power-of-data-how-we-built-text-to-sql-with-agentic-rag-at-rocket-mortgage\/","url":"https:\/\/blog.ibvl.in\/index.php\/2026\/03\/13\/unlocking-the-power-of-data-how-we-built-text-to-sql-with-agentic-rag-at-rocket-mortgage\/","name":"Unlocking the power of data: How we built text-to-SQL with agentic RAG at Rocket Mortgage - Imperative Business Ventures Limited","isPartOf":{"@id":"https:\/\/blog.ibvl.in\/#website"},"datePublished":"2026-03-13T15:00:14+00:00","author":{"@id":"https:\/\/blog.ibvl.in\/#\/schema\/person\/55b87b72a56b1bbe9295fe5ef7a20b02"},"breadcrumb":{"@id":"https:\/\/blog.ibvl.in\/index.php\/2026\/03\/13\/unlocking-the-power-of-data-how-we-built-text-to-sql-with-agentic-rag-at-rocket-mortgage\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.ibvl.in\/index.php\/2026\/03\/13\/unlocking-the-power-of-data-how-we-built-text-to-sql-with-agentic-rag-at-rocket-mortgage\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/blog.ibvl.in\/index.php\/2026\/03\/13\/unlocking-the-power-of-data-how-we-built-text-to-sql-with-agentic-rag-at-rocket-mortgage\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blog.ibvl.in\/"},{"@type":"ListItem","position":2,"name":"Unlocking the power of data: How we built text-to-SQL with agentic RAG at Rocket Mortgage"}]},{"@type":"WebSite","@id":"https:\/\/blog.ibvl.in\/#website","url":"https:\/\/blog.ibvl.in\/","name":"Imperative Business Ventures Limited","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.ibvl.in\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blog.ibvl.in\/#\/schema\/person\/55b87b72a56b1bbe9295fe5ef7a20b02","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.ibvl.in\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4d20b2cd313e4417a599678e950e6fb7d4dfa178a72f2b769335a08aaa615aa9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4d20b2cd313e4417a599678e950e6fb7d4dfa178a72f2b769335a08aaa615aa9?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/blog.ibvl.in"],"url":"https:\/\/blog.ibvl.in\/index.php\/author\/admin_hcbs9yw6\/"}]}},"_links":{"self":[{"href":"https:\/\/blog.ibvl.in\/index.php\/wp-json\/wp\/v2\/posts\/1908","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ibvl.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ibvl.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ibvl.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ibvl.in\/index.php\/wp-json\/wp\/v2\/comments?post=1908"}],"version-history":[{"count":0,"href":"https:\/\/blog.ibvl.in\/index.php\/wp-json\/wp\/v2\/posts\/1908\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ibvl.in\/index.php\/wp-json\/wp\/v2\/media?parent=1908"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ibvl.in\/index.php\/wp-json\/wp\/v2\/categories?post=1908"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ibvl.in\/index.php\/wp-json\/wp\/v2\/tags?post=1908"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}