Giter VIP home page Giter VIP logo

llm-text-to-sql-architectures's Introduction

LLM-Text-to-SQL-Architectures

A comprehensive guide and implementation of architectural patterns that utilize Large Language Models (LLMs) for the efficient generation of SQL from natural language text.

For comprehensive details on the architectural patterns mentioned below, please refer to the accompanying article on Medium. This piece delves into the utilization of LLMS for enhanced BigQuery interactions. You can access the article via this link.

Architectural Patterns for Text-to-SQL: Leveraging LLMs for Enhanced BigQuery Interactions

Table of Contents

Introduction ๐Ÿ“˜

This repository offers an in-depth exploration into Text-to-SQL conversion, emphasizing the role of LLMs in enhancing the SQL generation process. With the advent of LLMs, there is a promising opportunity to streamline the translation of natural language to SQL. We explore various architectural patterns that leverage the capabilities of LLMs in this exciting field.

Architectural Patterns ๐Ÿ—๏ธ

Pattern I: Intent Detection and Entity Recognition with Text-to-SQL

Utilizing LLMs to identify intent, extract entities, and subsequently generate SQL.

Architecture (100-Foot View)
Click on image to enlarge

Pattern II: LLM Flow with Retrieval-Augmented Generation (RAG)

Incorporating Retriever-Augmented Generation (RAG) with table and column metadata to pinpoint relevant database schema elements, allowing LLMs to formulate queries based on natural language questions.

Architecture (100-Foot View)
Click on image to enlarge

Pattern III: Using SQL Agents

Adopting an autonomous agent-based approach where a BigQuery SQL agent, equipped with an ODBC connection, iteratively attempts and refines SQL queries with minimal external guidance.

Architecture (100-Foot View)
Click on image to enlarge

Pattern IV: Direct Schema Inference with Self-Correction

Implementing a self-correcting mechanism where the LLM receives direct schema input, generates an SQL query, and upon execution failure, uses the error feedback to self-correct and retry until successful. This pattern also explores using the Code-Chat Bison model to potentially reduce costs and improve latency.

Architecture (100-Foot View)
Click on image to enlarge

Pattern V: Direct Schema Inference, Self-Correction & Optimization

Similar to Pattern IV but employs a stochastic approach with a temperature setting of 1. It runs multiple trials and selects the query that executes the fastest.

Architecture (100-Foot View)
Click on image to enlarge

Getting Started ๐Ÿš€

  1. Clone the Repository:

    git clone https://github.com/your_username/LLM-Text-to-SQL-Architectures.git
  2. Navigate to the directory:

    cd LLM-Text-to-SQL-Architectures
  3. Set up a virtual environment:

    python3 -m venv .venv
    source .venv/bin/activate
  4. Install dependencies:

    pip install -r requirements.txt

Follow the individual pattern READMEs for detailed setup and usage instructions.

Challenges and Limitations โš ๏ธ

This section discusses the potential pitfalls, challenges, and areas for improvement in the application of LLMs for Text-to-SQL conversion.

See Medium article: Architectural Patterns for Text-to-SQL: Leveraging LLMs for Enhanced BigQuery Interactions

Contributing ๐Ÿค

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated. Check out CONTRIBUTING.md for guidelines on how to submit pull requests.

License ๐Ÿ“„

This project is licensed under the MIT License - see the LICENSE.md file for details.

llm-text-to-sql-architectures's People

Contributors

arunpshankar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.