This project consists of two main scripts:
train.py
: For training the model on custom dialogue datasets.infer.py
: For generating responses using the trained model.
- Python 3.7 or later
- PyTorch
- Transformers library by Hugging Face
- Git
- Clone the repository.
- Create a virtual environment and activate it.
- Install the required packages, by using
pip install -r requirements.txt
Ensure you have the pre-trained Google's t5 model and tokenizer saved in the models
directory:
models/t5_model
models/t5_tokenizer
If not, use the train command to train and save the models.
To train the model, use the train.py
script. Ensure your training data is properly preprocessed and available.
To generate responses using the trained model, use the infer.py
script.
The train.py
script is used to train the model with custom dialogue datasets. Here's a breakdown of the script:
- Data Preprocessing: Tokenizes the input and target texts. Pads the sequences to the maximum length.
- Training Loop: Uses the
torch
library to train the model. Saves the trained model and tokenizer.
The infer.py
script is used to generate responses based on the input text. Here's how it works:
- Model and Tokenizer Loading: Loads the trained model and tokenizer from the
models
directory. - Generate Response Function: Encodes the input text. Generates the response using the model. Decodes and returns the response.
Contributions are welcome! If you'd like to contribute to this project, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature-branch
). - Open a Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.
I will be improving this project.
Contact: [email protected]
๐ If you like this project, give it a โญ and share it with friends!