GithubHelp home page GithubHelp logo

sirofjelly / atmt_2023 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arnisafazla/atmt_2023

0.0 0.0 0.0 113.88 MB

Materials for the first assignment of "Advanced Techniques of Machine Translation" @UZH (Autumn 2023).

License: MIT License

Shell 0.31% Python 2.95% Perl 1.66% Forth 1.61% Frege 4.64% SystemVerilog 88.84%

atmt_2023's Introduction

atmt code base

Materials for "Advanced Techniques of Machine Translation". Please refer to the assignment sheet for instructions on how to use the toolkit.

The toolkit is based on this implementation.

Environment Setup

In case you prefer to run the code locally, we suggest creating a Python environment to prevent library clashes with future projects, using either Conda or virtualenv (Conda is suggested). For other options, see supplementary material

conda

# ensure that you have conda (or miniconda) installed (https://conda.io/projects/conda/en/latest/user-guide/install/index.html) and that it is activated

# create clean environment
conda create --name atmt311 python=3.11

# activate the environment
conda activate atmt311

# intall required packages
conda install pytorch=2.0.1 numpy tqdm sacrebleu

virtualenv

# ensure that you have python > 3.6 downloaded and installed (https://www.python.org/downloads/)

# install virtualenv
pip install virtualenv  # for both powershell and WSL

# create a virtual environment named "atmt311"
virtualenv --python=python3.11 atmt311  # on WSL terminal
python -m venv atmt311    # on powershell

# launch the newly created environment
source atmt311/bin/activate
.\atmt311\Scripts\Activate.ps1   # on powershell


# intall required packages
pip install torch==2.0.1 numpy tqdm sacrebleu   # for both powershell and WSL

Training a model

python train.py \
    --data path/to/prepared/data \
    --source-lang en \
    --target-lang sv \
    --save-dir path/to/model/checkpoints \
    --train-on-tiny # for testing purposes only

Notes:

  • path/to/prepared/data and path/to/model/checkpoints are placholders, not true paths. Replace these arguments with the correct paths for your system.
  • only use --train-on-tiny for testing. This will train a dummy model on the tiny_train split.
  • add the --cuda flag if you want to train on a GPU, e.g. using Google Colab

Evaluating a trained model

Run inference on test set

python translate.py \
    --data path/to/prepared/data \
    --dicts path/to/prepared/data \
    --checkpoint-path path/to/model/checkpoint/file/for/loading \
    --output path/to/output/file/model/translations

Postprocess model translations

bash scripts/postprocess.sh path/to/output/file/model/translations path/to/postprocessed/model/translations/file en

Score with SacreBLEU

cat path/to/postprocessed/model/translations/file | sacrebleu path/to/raw/target/test/file

Assignments

Assignments must be submitted on OLAT by 14:00 on their respective due dates.

atmt_2023's People

Contributors

arnisafazla avatar hallerp avatar sirofjelly avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.