PyTorch Implementation of Transformer Deep Learning Model
- Edit the wiki_dump_read.py file to use your own dump of Wikipedia.
- Adjust the hyperparameters of preprocessing.
- Run the preprocessor:
$ python wiki_dump_read.py
Use notebook TokenizerTrainBPE.ipynb to train your own byte-pair encoding (BPE) tokenizer.
Use notebook PlaygroundForTokenizers.ipynb to test your trained BPE tokenizer.
- Dataset caching is useful for improving context and training speed.
- Run the caching (this can take some time):
$ python cache_dataset.py
Use notebook LM_GPT_Wiki.ipynb to train your own transformer based language model.
- Edit the generate_text.py file for your configuration.
- Use setup and temps to adjust text generation behaviour.
- Use q to quit, clear to clear console.
$ python generate_text.py
@misc{alsan_transformers_from_scratch,
title = {fualsan/TransformerFromScratch},
url = {https://github.com/fualsan/TransformerFromScratch},
author = {Alsan, H. Fuat},
year={2024},
}