This repository contains two scripts that together create a chatbot based on OpenAI's GPT-3 language model and a custom search index.
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:
- Load training documents from a directory named "datos".
- Set parameters such as maximum input size, maximum token count, and chunk size.
- Create a
PromptHelper
object to process queries and fragment the documents. - Create an
LLMPredictor
model with a pre-trained OpenAI model. - Create a service context using the model and the
PromptHelper
. - Train a
GPTVectorStoreIndex
using the documents and the service context. - Save the trained index to a directory named "Modelo".
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:
- Load the trained index from the "Modelo" directory.
- Create a query engine from the loaded index.
- Define a
chatbot
function that queries the index and generates responses. - Create a graphical interface using the
gradio
library. - Users can input questions and receive responses generated by the chatbot.