Developing a Custom QA Chatbot: Challenges with Training GPT-3.5-Turbo and Exploring Alternative Models and Libraries

Hello everyone,

I’m currently working on developing a Question-Answering (QA) chatbot and am seeking guidance. My intention is to train the GPT model using data from multiple SQL tables, helping it understand how to structure the data and what specific information to request when tasked with creating a trigger or a client, among other tasks. To achieve this, I need to organize the data into manageable chunks.

I’ve explored two options so far:

  1. I created a dictionary of Pandas DataFrames, each representing data from a different table in the database. This was done by iterating through a list of table names and executing SQL queries to fetch all records from each table.
dataframes = {}
for table in tables:
    query = f"SELECT * FROM `{table}`"
    dataframes[table] = conn.executeQuery(query)

Then, I constructed a DataFrame, mi_dataframe , with each column containing a list of DataFrames derived from the dictionary, where each key-value pair represents a table name and its corresponding DataFrame.

dct = {k:[v] for k,v in dataframes.items()}
mi_dataframe = pd.DataFrame.from_dict(dct)

Finally, I divided the information into chunks using a hardcoded approach for page_content .

def recorrer_chunks(chunk_size, chunk_overlap):
        df_chunks = pd.read_csv("C:\\Users\\jdelreym\\Desktop\\CALMA - Orange\\chunks.csv", sep=',', on_bad_lines='skip')
        loader = DataFrameLoader(df_chunks, page_content_column="monitor")
        data = loader.load()
        document_chunks = split_texts(texts=data, chunk_size=chunk_size, chunk_overlap=chunk_overlap)
        return document_chunks 

chunks_db = recorrer_chunks(chunk_size=1000, chunk_overlap=50)

2)I experimented with Langchain libraries but faced challenges in obtaining metadata, leading to the necessity of hardcoding it.

from langchain.utilities import SQLDatabase
from langchain_experimental.sql import SQLDatabaseChain
from langchain.chat_models import AzureChatOpenAI

sql = SQLDatabase.from_uri("mysql://user:password@host:port/database")
llm = AzureChatOpenAI(deployment_name= 'rpa-gpt35turbo-training',
                        model_name = "gpt-3.5-turbo", 

sql_chain = SQLDatabaseChain.from_llm(llm, sql, verbose=True)

n summary, I’m seeking advice on creating a chatbot trained with data from a SQL database. Any insights or suggestions would be greatly appreciated.

If utilizing the gpt-3.5-turbo model proves to be challenging, I am open to exploring alternative models and libraries. Any recommendations or insights in this regard would be highly welcome.

Thank you.