This repository contains a Transformer-based chat model implemented using TensorFlow and Keras. The model is trained to predict answers based on provided background and question text.
ChatBot_architecture_from_scratch.ipynb
: The Python script containing the model and associated functions.
- Install the required Python packages: pandas, numpy, tensorflow, scikit-learn.
pip install pandas numpy tensorflow scikit-learn
- Place your
dataset.csv
file in the same directory asChatBot_architecture_from_scratch.ipynb
.
-
Navigate to the folder containing
ChatBot_architecture_from_scratch.ipynb
. -
Rename
ChatBot_architecture_from_scratch.ipynb
toChatBot_architecture_from_scratch.py
-
Run the script to train the model and to use the chat function. Optionally, we can proced with that as .ipynb file, however, we recommend to use rename it to
.py
as it make it more straightforward taks and better seuted for this example/tutorial/process.python ChatBot_architecture_from_scratch.py
- The script starts by importing necessary modules and loading the dataset.
- A Tokenizer is trained on the text data.
- Text sequences are tokenized and padded.
- The data is split into training and validation sets.
- A Transformer model is created using Keras layers.
- The model is compiled and trained.
- A chat function (
chat()
) uses the trained model to predict answers.
You can replace the Tokenizer with any other tokenization method or library. Make sure to update the tokenize_and_pad()
function accordingly.
We can replace the Transformer encoder with other model architectures like LSTM, GRU, or custom layers. Make sure to update the model creation and compilation steps.