Back to work

ML · Internship

Text-to-SQL LLM

ML Intern · Reliance Jio

Built an AI-powered SQL chatbot that converts natural language questions into executable SQL and displays results in a Streamlit UI.

PDF not loading? Open it in a new tab.
Overview

Built an AI-powered SQL chatbot during my Jio internship that allows users to ask questions in natural language and automatically converts them into SQL queries. The system connects to a user-provided MySQL database, understands the database schema, generates the correct SQL query using an LLM, runs the query, and displays the result in a Streamlit web interface.

Technically, I used Streamlit for the frontend, LangChain for LLM orchestration and prompt engineering, Ollama for local LLM integration, SQLDatabase for database connectivity, FAISS and OllamaEmbeddings for semantic similarity search, and Pandas for displaying query results as downloadable dataframes. The project also used structured output parsing to force the LLM response into a reliable SQL query format.

I implemented two different query-generation pipelines: one optimized for faster runtime, and another optimized for higher accuracy. The faster version directly generates SQL using the user question, relevant database details, and example queries, while the more accurate version adds an extra LLM step to describe table data before generating the final SQL query.

Tech Stack: Python, Streamlit, LangChain, Ollama, SQL, MySQL, Pandas, FAISS, OllamaEmbeddings, Pygwalker, ChromaDB

Key Features

  • Converted natural language questions into executable SQL queries
  • Connected dynamically to MySQL databases using database name and URI
  • Generated table descriptions and examples automatically for better LLM context
  • Used embeddings and FAISS similarity search to retrieve relevant examples
  • Displayed query results in Streamlit as interactive, downloadable dataframes
  • Compared two LLM pipelines based on speed vs. accuracy tradeoffs
Stack
PythonLangChainOllamaStreamlitSQLNLP