Simple single-card training of transformer for machine translation
This code is training with 4090 Nvidia GPU. If the version of your GPU is lower, please decrease the batch size.
pip install transformers
pip install sentencepiece
pip install sacrebleu
The dataset of Helsinki-NLP and translation2019zh is shared in the alipan. The link is shown below.
https://www.alipan.com/s/F5dRWAwod7w
Finetune huggingface model
python train_huggingface.py
Test huggingface model
python test_huggingface.py
Train from scratch
python train.py
We provide a trained model for you to test the performance of our scratched model. Download the model_weights.pt from the provided link below,
https://pan.baidu.com/s/1lGRzWyrK0_IxgDPTqVPgcQ 提取码: tran
Then create a folder in root folder called record.
Finally, put the model_weights.pt into the record folder.
To train the model, set train_flag = 1. To test the model, set set train_flag = 0