Development Story of InsightLens, a Text2SQL-Based Data Analysis Service
Key point
InsightLens uses RAG and LLMs to turn natural language into executable SQL.
Details
Data requests within a company are prone to being slowed down by repeated communication between business teams unfamiliar with SQL and analytics teams. InsightLens was developed as a Text2SQL service that turns natural language questions into executable SQL to reduce this bottleneck.
At its core is RAG (Retrieval-Augmented Generation). After refining a question, it retrieves past Q&A, table schemas, and policy data from a Vector Store, and injects that grounding into the prompt so the model generates SQL with fewer schema hallucinations, join relationship errors, and missing domain rules.
A 2-week PoC conducted before development showed that the generation capability of frontier models themselves was sufficient, but the variable that determined performance was the quality of the reference data. Since the Q&A data came in inconsistent formats and the schema documentation lacked descriptions and code value definitions, the team carried out dataset standardization and preprocessing alongside data augmentation based on LLaMA-3.3-70B-Instruct.
The system was built with Python, LangChain, and LangGraph, and supports both Claude and OpenAI as LLMs. OpenSearch is used as the Vector Store, leveraging both lexical search and semantic search, with a reranker added to strengthen retrieval quality.
The agent operates through a flow of conversation history lookup, intent classification, question refinement, keyword extraction, Q&A search, schema lookup, and SQL generation. Jira integration preserves the existing request workflow while providing fast initial responses, and the service shows the explanation, expected results, and reference data alongside the generated query.
The most important design element is a feedback loop that improves with use. When a verified query is registered as ground-truth data, it accumulates back into the Vector Store to improve the quality of responses to similar questions later, and the system responds politely to out-of-scope questions to keep its focus on the SQL generation domain.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.