{"id":13474301,"url":"https://github.com/pcyin/pytorch_basic_nmt","last_synced_at":"2026-03-13T11:31:25.483Z","repository":{"id":70671776,"uuid":"148842467","full_name":"pcyin/pytorch_basic_nmt","owner":"pcyin","description":"A simple yet strong implementation of neural machine translation in pytorch","archived":false,"fork":false,"pushed_at":"2021-02-22T22:37:20.000Z","size":17341,"stargazers_count":92,"open_issues_count":0,"forks_count":23,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-07-25T17:04:49.507Z","etag":null,"topics":["deep-learning","natural-language-processing","neural-machine-translation","pytorch","pytorch-implmention"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pcyin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-09-14T21:14:15.000Z","updated_at":"2025-06-04T13:19:20.000Z","dependencies_parsed_at":"2023-06-15T15:15:30.318Z","dependency_job_id":null,"html_url":"https://github.com/pcyin/pytorch_basic_nmt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pcyin/pytorch_basic_nmt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pcyin%2Fpytorch_basic_nmt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pcyin%2Fpytorch_basic_nmt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pcyin%2Fpytorch_basic_nmt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pcyin%2Fpytorch_basic_nmt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pcyin","download_url":"https://codeload.github.com/pcyin/pytorch_basic_nmt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pcyin%2Fpytorch_basic_nmt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30466314,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-13T11:00:43.441Z","status":"ssl_error","status_checked_at":"2026-03-13T11:00:23.173Z","response_time":60,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","natural-language-processing","neural-machine-translation","pytorch","pytorch-implmention"],"created_at":"2024-07-31T16:01:11.234Z","updated_at":"2026-03-13T11:31:25.458Z","avatar_url":"https://github.com/pcyin.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"## A Basic PyTorch Implementation of Attentional Neural Machine Translation\n\nThis is a basic implementation of attentional neural machine translation (Bahdanau et al., 2015, Luong et al., 2015) in Pytorch.\nIt implements the model described in [Luong et al., 2015](https://arxiv.org/abs/1508.04025), and supports label smoothing, beam-search decoding and random sampling.\nWith 256-dimensional LSTM hidden size, it achieves 28.13 BLEU score on the IWSLT 2014 Germen-English dataset (Ranzato et al., 2015).\n\nThis codebase is used for instructional purposes in Stanford [CS224N Nautral Language Processing with Deep Learning]( http://web.stanford.edu/class/cs224n/) and CMU [11-731 Machine Translation and Sequence-to-Sequence Models](http://www.phontron.com/class/mtandseq2seq2018/).\n\n### File Structure\n\n* `nmt.py`: contains the neural machine translation model and training/testing code.\n* `vocab.py`: a script that extracts vocabulary from training data\n* `util.py`: contains utility/helper functions\n\n### Example Dataset\n\nWe provide a preprocessed version of the IWSLT 2014 German-English translation task used in (Ranzato et al., 2015) [[script]](https://github.com/harvardnlp/BSO/blob/master/data_prep/MT/prepareData.sh). To download the dataset:\n\n```bash\nwget http://www.cs.cmu.edu/~pengchey/iwslt2014_ende.zip\nunzip iwslt2014_ende.zip\n```\n\nRunning the script will extract a`data/` folder which contains the IWSLT 2014 dataset.\nThe dataset has 150K German-English training sentences. The `data/` folder contains a copy of the public release of the dataset. Files with suffix `*.wmixerprep` are pre-processed versions of the dataset from Ranzato et al., 2015, with long sentences chopped and rared words replaced by a special `\u003cunk\u003e` token. You could use the pre-processed training files for training/developing (or come up with your own pre-processing strategy), but for testing you have to use the **original** version of testing files, ie., `test.de-en.(de|en)`.\n\n### Environment\n\nThe code is written in Python 3.6 using some supporting third-party libraries. We provided a conda environment to install Python 3.6 with required libraries. Simply run\n\n```bash\nconda env create -f environment.yml\n```\n\n### Usage\n\nEach runnable script (`nmt.py`, `vocab.py`) is annotated using `dotopt`.\nPlease refer to the source file for complete usage.\n\nFirst, we extract a vocabulary file from the training data using the command:\n\n```bash\npython vocab.py \\\n    --train-src=data/train.de-en.de.wmixerprep \\\n    --train-tgt=data/train.de-en.en.wmixerprep \\\n    data/vocab.json\n```\n\nThis generates a vocabulary file `data/vocab.json`. \nThe script also has options to control the cutoff frequency and the size of generated vocabulary, which you may play with.\n\nTo start training and evaluation, simply run `scripts/train.sh`. \nAfter training and decoding, we call the official evaluation script `multi-bleu.perl` to compute the corpus-level BLEU score of the decoding results against the gold-standard.\n\n### License\n\nThis work is licensed under a Creative Commons Attribution 4.0 International License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpcyin%2Fpytorch_basic_nmt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpcyin%2Fpytorch_basic_nmt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpcyin%2Fpytorch_basic_nmt/lists"}