main.py allows you to run model evaluation experiments with different configurations. It supports various command-line arguments to customize the behavior of the script.Data_preparation folder contains the create_dataset.py script for preparing our training and testing datasets.Finetuning folder contains the finetune_nmt_backbone.py script for fine-tuning the NMT backbone model on a dataset.AlignAtt folder contains the definitions of align att and local agreement policies and runs the model using them.Evaluation folder contains the scripts for the evaluation metrics, which can be used independently or by running the main script.Visualization folder contains scripts for parsing results, creating tables, and plotting results.AlignAttOutputs folder contains the output logs from the grid search over local agreement and align att parameters, parsed results, and final results.Each module contains its own requirements.txt. To install dependencies for a module, run:
pip install -r <module>/requirements.txt
Example:
pip install -r Data_preparation/requirements.txt
Alternitavely, to install all dependencies for all modules, run:
pip install -r requirements.txt
| Argument | Type | Default | Description |
|---|---|---|---|
--dataset_path | str | ./Data_preparation/cleaned_eval_dataset.jsonl | Path to the JSONL dataset file. |
--local_agreement_length | int | 0 | Number of next tokens to agree with the previous theory. |
--skip_l | int | 0 | Number of last positions in attention_frame_size to ignore. |
--layers | int list | 3, 4 | Layer indices to use. The attention values are averaged over these layers. |
--top_attentions | int | 0 | Top attentions to use (0 disables AlignAtt). |
--output_file | str | results.jsonl | Output file for results. |
--attention_frame_size | int | 10 | Excluded frame of last positions size. |
--count_in | int | 1 | Required top_attentions within attention_frame_size for position to be bad. |
--wait_for | int | 0 | Static wait time applied globally. |
--wait_for_beginning | int | 3 | Wait time applied at the beginning. |
--heads | int list | 0 1 2 3 4 5 | Attention heads to use. The attention values are averaged over these heads. |
--device | str | cuda | Device (cuda or cpu). |
--words_per_prefix | int | 2 | Words per prefix shown. |
--forced_bos_token_text | str | None | Forced BOS token text. |
--model_id | int | 0 | Model ID from predefined list. |
--num_beams | int | 2 | Number of beams for beam search (multiple of 3 for diverse beam search). |
--num_swaps | int | 0 | Number of word pairs to blindly swap. |
--src_key | str | source | Source key in dataset. |
--tgt_key | str | target | Target key in dataset. |
--verbose | flag | True | Enable verbose output. |
--experiment_type | str | none | Experiment type (simple, alignatt). The simple option does a grid search over num_beams and wait_for_beginning. The alignatt option does a grid search over layers and attention_frame_size. |
python main.py \
--dataset_path ./Data_preparation/cleaned_eval_dataset.jsonl \
--experiment_type alignatt \
--layers 3 \
--heads 0 1 2 3 4 5 \
--model_id 0 \
--device cuda \
--output_file results.jsonl
Simul-Translation/
βββ .gitignore
βββ main.py
βββ README.md
βββ report.pdf
βββ requirements.txt
βββ slides.pdf
βββ AlignAtt/
β βββ README.md
β βββ alignatt.py
β βββ analyze_dataset.py
β βββ get_data.py
β βββ local_agreement.py
β βββ requirements.txt
β βββ translate.py
βββ AlignAttOutputs/
β βββ output_logs_grid_search_local_agreement/
β βββ parsed/
β βββ results/
βββ Data_preparation/
β βββ README.md
β βββ cleaned_eval_dataset.jsonl
β βββ create_dataset.py
β βββ iwslt2024_cs_devset.json
β βββ requirements.txt
βββ Evaluation/
β βββ README.md
β βββ requirements.txt
β βββ simueval.py
βββ Finetuning/
β βββ README.md
β βββ finetune_nmt_backbone.py
β βββ finetuning.log
β βββ requirements.txt
βββ Visualization/
βββ RESULTS.md
βββ RESULTS_OVERALL.md
βββ best.json
βββ create_tables.py
βββ parse_results.py
βββ plot_results.py
main.py allows you to run model evaluation experiments with different configurations. It supports various command-line arguments to customize the behavior of the script.Data_preparation folder contains the create_dataset.py script for preparing our training and testing datasets.Finetuning folder contains the finetune_nmt_backbone.py script for fine-tuning the NMT backbone model on a dataset.AlignAtt folder contains the definitions of align att and local agreement policies and runs the model using them.Evaluation folder contains the scripts for the evaluation metrics, which can be used independently or by running the main script.Visualization folder contains scripts for parsing results, creating tables, and plotting results.AlignAttOutputs folder contains the output logs from the grid search over local agreement and align att parameters, parsed results, and final results.Each module contains its own requirements.txt. To install dependencies for a module, run:
pip install -r <module>/requirements.txt
Example:
pip install -r Data_preparation/requirements.txt
Alternitavely, to install all dependencies for all modules, run:
pip install -r requirements.txt
| Argument | Type | Default | Description |
|---|---|---|---|
--dataset_path | str | ./Data_preparation/cleaned_eval_dataset.jsonl | Path to the JSONL dataset file. |
--local_agreement_length | int | 0 | Number of next tokens to agree with the previous theory. |
--skip_l | int | 0 | Number of last positions in attention_frame_size to ignore. |
--layers | int list | 3, 4 | Layer indices to use. The attention values are averaged over these layers. |
--top_attentions | int | 0 | Top attentions to use (0 disables AlignAtt). |
--output_file | str | results.jsonl | Output file for results. |
--attention_frame_size | int | 10 | Excluded frame of last positions size. |
--count_in | int | 1 | Required top_attentions within attention_frame_size for position to be bad. |
--wait_for | int | 0 | Static wait time applied globally. |
--wait_for_beginning | int | 3 | Wait time applied at the beginning. |
--heads | int list | 0 1 2 3 4 5 | Attention heads to use. The attention values are averaged over these heads. |
--device | str | cuda | Device (cuda or cpu). |
--words_per_prefix | int | 2 | Words per prefix shown. |
--forced_bos_token_text | str | None | Forced BOS token text. |
--model_id | int | 0 | Model ID from predefined list. |
--num_beams | int | 2 | Number of beams for beam search (multiple of 3 for diverse beam search). |
--num_swaps | int | 0 | Number of word pairs to blindly swap. |
--src_key | str | source | Source key in dataset. |
--tgt_key | str | target | Target key in dataset. |
--verbose | flag | True | Enable verbose output. |
--experiment_type | str | none | Experiment type (simple, alignatt). The simple option does a grid search over num_beams and wait_for_beginning. The alignatt option does a grid search over layers and attention_frame_size. |
python main.py \
--dataset_path ./Data_preparation/cleaned_eval_dataset.jsonl \
--experiment_type alignatt \
--layers 3 \
--heads 0 1 2 3 4 5 \
--model_id 0 \
--device cuda \
--output_file results.jsonl
Simul-Translation/
βββ .gitignore
βββ main.py
βββ README.md
βββ report.pdf
βββ requirements.txt
βββ slides.pdf
βββ AlignAtt/
β βββ README.md
β βββ alignatt.py
β βββ analyze_dataset.py
β βββ get_data.py
β βββ local_agreement.py
β βββ requirements.txt
β βββ translate.py
βββ AlignAttOutputs/
β βββ output_logs_grid_search_local_agreement/
β βββ parsed/
β βββ results/
βββ Data_preparation/
β βββ README.md
β βββ cleaned_eval_dataset.jsonl
β βββ create_dataset.py
β βββ iwslt2024_cs_devset.json
β βββ requirements.txt
βββ Evaluation/
β βββ README.md
β βββ requirements.txt
β βββ simueval.py
βββ Finetuning/
β βββ README.md
β βββ finetune_nmt_backbone.py
β βββ finetuning.log
β βββ requirements.txt
βββ Visualization/
βββ RESULTS.md
βββ RESULTS_OVERALL.md
βββ best.json
βββ create_tables.py
βββ parse_results.py
βββ plot_results.py