Skip to content

sharathdoes/text2sql-spaces

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Text2Sql using RAG & Finetuning microsoft/phi-2

Overview

  1. LoRA-based Fine-tuning for optimizing language models.
  2. RAG (Retrieval-Augmented Generation) System for efficient text-to-SQL conversion using vector stores and NeonDB.

1. Fine-tuning Module

This module utilizes LoRA (Low-Rank Adaptation) to fine-tune the Phi-2 model efficiently. Key features include:

Features

  • Uses LoRAConfig for lightweight fine-tuning with optimal performance.
  • Fine-tunes the microsoft/phi-2 model with quantization enabled for CPU efficiency.
  • LoRA configuration settings ensure control over trainable parameters, scaling factor, and dropout rate for effective adaptation.

2. RAG (Retrieval-Augmented Generation) System

This module extracts text from document files to generate SQL queries using vector stores and a conversational AI system. image

Features

  • Supports .pdf, .docx, and .txt document types for schema extraction.
  • Utilizes PGVector for efficient vector storage and retrieval of schema details and sample queries.
  • Uses the Groq API to generate SQL queries based on provided schemas and example queries.
  • Implements retry logic to handle API failures and ensure stability.

Key Libraries Used

  • gradio (for UI)
  • pdfplumber, docx, json (for text extraction)
  • langchain_postgres (for PGVector storage)

Installation

  1. Clone the repository:
git clone <repository-url>
cd finetunee
  1. Install dependencies:
pip install -r requirements.txt

API Keys & Database Configuration

  • Ensure your Groq API Key and NeonDB Connection String are correctly set in the environment variables for secure access.

Releases

No releases published

Packages

 
 
 

Contributors