- Python >= 3.11
- PyTorch >= 2.4.0
- Clone repo
git clone https://github.com/qin1122/Transformer-Machine-Translation.git
cd Transformer-Machine-Translation- Install dependent packages (use conda)
conda create --name transformer
conda activate transformer
conda install python
pip install -r requirements.txtI use a dataset consisting of 21,621 pairs of English and Chinese short sentences. Original dataset can be downloaded here.
I applied a better tokenizing method for Chinese sentences, which led to a higher BLEU score. The new dataset and the preprocessed original dataset can be downloaded here
Create a new yaml config file or use my config files (e.g. './configs/train_1.yaml'), put the yaml file in './configs'.
Then run:
python main.py --config 'configs/config.yaml'You can monitor the training process in real time on Weights & Biases (wandb).
To use wandb, you have to login in terminal first, use the command below to login:
wandb loginCreate a new yaml config file or use my config files (e.g. './configs/test_origin.yaml'), put the yaml file in './configs'.
Then run:
python test.py --config 'configs/config.yaml'We conducted a total of 19 experiments, and the best model parameters can be downloaded here.