This repository contains experiments for English<->Swedish machine translation using:
tencent/HY-MT1.5-7B modelThe code supports training, qualitative translation checks, and metric-based evaluation (BLEU, chrF++, COMET).
mt/train.py - train a custom seq2seq Transformer with Hydra config.mt/translate.py - load a trained custom checkpoint and run greedy translation.mt/finetune_model.py - LoRA finetuning pipeline for tencent/HY-MT1.5-7B.mt/eval.py - metric evaluation across multiple models.mt/create_samples.py - manual sample translations for quick quality checks.mt/test_finetune.py - sanity tests for finetuned adapters and baselines.run.sh, train_finetune.sh, eval.sh, translate.sh, test_model.sh - SLURM helper scripts.data/tokenizer/ - SentencePiece tokenizer assets for the custom model.outputs/ - Hydra run outputs and logs from previous runs.Main Python packages used by the code:
torchtransformersdatasetshydra-coreomegaconfsentencepiecepefttrlevaluatetqdmCreate and activate a virtual environment, then install dependencies:
python -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install torch transformers datasets hydra-core omegaconf sentencepiece peft trl evaluate tqdm numpy
If you need private model access:
huggingface-cli login
mt/train.py, mt/translate.py, and mt/eval.py expect a Hydra config at:
conf/config.yamlThe repository currently contains run-time snapshots under outputs/*/.hydra/config.yaml, which can be used as a template. A typical config includes fields like:
hf_name, hf_config, src_lang, tgt_langsp_model_path, token IDs, vocab_size, max_lenbatch_size, epochs, lr, scheduler and regularization fieldsd_model, nhead, encoder/decoder layers, ffn_dimsave_dir, log_dirLocal:
python -u mt/train.py
SLURM:
sbatch run.sh
Checkpoints are saved to the configured save_dir (for example checkpoints/en-sv/).
Local:
python -u mt/translate.py
SLURM:
sbatch translate.sh
Local:
python -u mt/finetune_model.py
SLURM:
sbatch train_finetune.sh
By default, adapter outputs are written to ./tencent_opus_finetune_16r.
Local:
python -u mt/eval.py
SLURM:
sbatch eval.sh
Evaluation artifacts are serialized under eval/.
python -u mt/create_samples.py
or (SLURM):
sbatch test_model.sh
conda activate theenv or ~/.envs/en-sv-mt). Adjust these before running.outputs/ contains historical run logs and Hydra snapshots; you can keep or clean it as needed.conf/config.yaml (or copy from outputs/*/.hydra/config.yaml).sp_model_path) and output directories.python -u mt/train.py or sbatch run.sh.python -u mt/eval.py after training/finetuning.This repository contains experiments for English<->Swedish machine translation using:
tencent/HY-MT1.5-7B modelThe code supports training, qualitative translation checks, and metric-based evaluation (BLEU, chrF++, COMET).
mt/train.py - train a custom seq2seq Transformer with Hydra config.mt/translate.py - load a trained custom checkpoint and run greedy translation.mt/finetune_model.py - LoRA finetuning pipeline for tencent/HY-MT1.5-7B.mt/eval.py - metric evaluation across multiple models.mt/create_samples.py - manual sample translations for quick quality checks.mt/test_finetune.py - sanity tests for finetuned adapters and baselines.run.sh, train_finetune.sh, eval.sh, translate.sh, test_model.sh - SLURM helper scripts.data/tokenizer/ - SentencePiece tokenizer assets for the custom model.outputs/ - Hydra run outputs and logs from previous runs.Main Python packages used by the code:
torchtransformersdatasetshydra-coreomegaconfsentencepiecepefttrlevaluatetqdmCreate and activate a virtual environment, then install dependencies:
python -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install torch transformers datasets hydra-core omegaconf sentencepiece peft trl evaluate tqdm numpy
If you need private model access:
huggingface-cli login
mt/train.py, mt/translate.py, and mt/eval.py expect a Hydra config at:
conf/config.yamlThe repository currently contains run-time snapshots under outputs/*/.hydra/config.yaml, which can be used as a template. A typical config includes fields like:
hf_name, hf_config, src_lang, tgt_langsp_model_path, token IDs, vocab_size, max_lenbatch_size, epochs, lr, scheduler and regularization fieldsd_model, nhead, encoder/decoder layers, ffn_dimsave_dir, log_dirLocal:
python -u mt/train.py
SLURM:
sbatch run.sh
Checkpoints are saved to the configured save_dir (for example checkpoints/en-sv/).
Local:
python -u mt/translate.py
SLURM:
sbatch translate.sh
Local:
python -u mt/finetune_model.py
SLURM:
sbatch train_finetune.sh
By default, adapter outputs are written to ./tencent_opus_finetune_16r.
Local:
python -u mt/eval.py
SLURM:
sbatch eval.sh
Evaluation artifacts are serialized under eval/.
python -u mt/create_samples.py
or (SLURM):
sbatch test_model.sh
conda activate theenv or ~/.envs/en-sv-mt). Adjust these before running.outputs/ contains historical run logs and Hydra snapshots; you can keep or clean it as needed.conf/config.yaml (or copy from outputs/*/.hydra/config.yaml).sp_model_path) and output directories.python -u mt/train.py or sbatch run.sh.python -u mt/eval.py after training/finetuning.