/GPT3-Index-Chatbot

Making a GPT-3 Index Chatbot using the openai api and text-ada-001 as model.

Primary LanguagePythonMIT LicenseMIT

GPT-3 Index Chatbot

This repository contains two scripts that together create a chatbot based on OpenAI's GPT-3 language model and a custom search index.

Index Training (train.py)

The Train.py script is responsible for training a search index using OpenAI's GPT-3 language model. Here is a summary of the key steps in the process:

  1. Load training documents from a directory named "datos".
  2. Set parameters such as maximum input size, maximum token count, and chunk size.
  3. Create a PromptHelper object to process queries and fragment the documents.
  4. Create an LLMPredictor model with a pre-trained OpenAI model.
  5. Create a service context using the model and the PromptHelper.
  6. Train a GPTVectorStoreIndex using the documents and the service context.
  7. Save the trained index to a directory named "Modelo".

Interactive Chatbot (predict.py)

The Predict.py script allows interacting with the chatbot to receive generated responses based on the previously trained index. Here is a summary of the key steps in the process:

  1. Load the trained index from the "Modelo" directory.
  2. Create a query engine from the loaded index.
  3. Define a chatbot function that queries the index and generates responses.
  4. Create a graphical interface using the gradio library.
  5. Users can input questions and receive responses generated by the chatbot.