Skip to main content

HMS Case Study

#industry #finance #lifesciences #other

Text-to-SQL: Retrieve Company Data via Chat

An SQL chatbot enables business users to ask quantitative questions about internal data, track queries, and process the results directly.

Management Summary

Until now, accessing databases and data warehouses at the international financial institution required knowledge of SQL. HMS developed a text-to-SQL solution that translates natural-language questions into SQL queries and displays the results via an interactive interface. For KPI calculations, the LLM can call deterministic functions that deliver precise and reproducible results.

Project summary

#finance
Internationale Finanzinstitution

Internationale Finanzinstitution

Branche: Banken
Projektstart: 06/2023
Schwerpunkt: Generative & Agentic AI
Use Case: Data & Analytics Assistants

Projektziel

Datenbankabfragen ohne eigene SQL-Kenntnisse ermöglichen

Wichtigste Kernfunktionen

  • Übersetzung quantitativer Geschäftsfragen in ausführbare SQL-Abfragen
  • Modulare Trennung von Chatbot-Oberfläche und LLM-Backend
  • Visualisierung, Bearbeitung und Export der ermittelten Abfrageergebnisse

Tech Stack

python langchain gpt models mlflow postgresql generative ai react

Good prompts alone are not enough for text-to-SQL. Queries must be systematically verified, and precise calculations must be executed deterministically.

Christoph Bergen

CoE Lead for GenAI at HMS

The Starting Point

The company used data from relational databases and data warehouses for KPI calculations, reports, and exploratory analyses. However, direct access was limited to a small group of employees who were proficient in both the data model and SQL.

Quantitative inquiries and ad-hoc analyses therefore required the assistance of individuals with SQL skills. This was particularly true for detailed analyses of management reports, where source data or aggregated KPIs needed to be examined interactively.

Simply expanding existing reports was not sufficient for this purpose. The possible questions were too varied and often arose only during the analysis itself.

The HMS Solution

An SQL Chatbot for Quantitative Business Questions

HMS developed and implemented the complete text-to-SQL application, including the LLM backend, user interface, and functions for further processing the results.

Translating Business Queries into SQL

Users ask quantitative questions in natural language. The LLM interprets the input, generates an appropriate SQL query, and executes it against the connected relational database. Advanced users can view the generated SQL code.

Process Query Results

The interface provides the retrieved data and supports its visualization, aggregation, editing, and export. Using a “bring-your-own-data” feature, users can also upload their own data and analyze it on the fly.

Modularly Connecting the Front End and LLM Back End

The chatbot interface and LLM backend were implemented as separate modules. The reference implementation uses React, Python, LangChain, Azure OpenAI, and PostgreSQL. The model integration can be customized within Azure OpenAI.

Perform Exact Calculations Using Tools

For KPI calculations, the LLM can call explicit code functions. These deterministic tools handle tasks that require reproducible results. MLflow supports the optimization and validation of LLM-based workflows.

Customer Benefits

Broader Data Access Through Text-to-SQL

The application extends access to relational enterprise data beyond the traditional group of SQL experts.

More Direct

Formulating Business Queries Without SQL

Business users access internal data through a chat interface. No prior knowledge of the query language is required.

More understandable

View Generated Database Queries

The underlying SQL statement remains visible to advanced users. This allows answers to be technically verified and categorized.

More reliable

Calculate KPI Values in a Reproducible Manner

Explicit code functions provide exact results for defined calculations. The LLM selects and controls the appropriate tool.

The solution thus supports both exploratory data queries and detailed analyses of key metrics from management reports.

Our Strengths, Your Benefits

Integrating LLM and Data Access

HMS was responsible for the complete technical implementation, from LLM control to the user interface. In this project, we combined generative AI with traditional software engineering and relational database systems.

What You Can Expect from HMS

With text-to-SQL, the language model, database access, and result validation must function as an integrated system. To achieve this, HMS combines LLM engineering, backend development, and interaction design.

  • Implementation of the complete text-to-SQL application
  • Modular separation of the user interface, LLM backend, and database connection
  • Methodical prompt engineering and systematic verification of queries and results
Christoph Bergen
Christoph Bergen
CoE Lead GenAI

Sie möchten ein ähnliches Projekt umsetzen?

Sprechen Sie mit HMS darüber, wie sich Ihre Daten-, KI- oder Softwarelösung fachlich einordnen, technisch umsetzen und in Ihre bestehende Systemlandschaft integrieren lässt.

Projekt besprechen

Next Steps and Further Study

Read more

Generative & Agentic AI

Learn how generative and agentic AI help companies efficiently leverage knowledge, automate processes, and productively deploy intelligent applications.

Learn more about Generative & Agentic AI

Read more

Other Projects

Discover more case studies related to generative AI, intelligent document analysis, AI assistants, and agentic AI.

Our Projects