facebookresearch / fairseq

Facebook AI Research Sequence-to-Sequence Toolkit written in Python.
MIT License
30.43k stars 6.4k forks source link

Broken links for (transformer-based) translation models with torch.hub.load #3955

Open fkoehlin opened 3 years ago

fkoehlin commented 3 years ago

🐛 Bug

Trying to load various transformer-based models for translations as documented in several READMEs (see below) with torch.hub.load fails.

For PyTorch version 1.8.1 (from pip): The step Downloading: "https://github.com/pytorch/fairseq/archive/master.zip" fails with an HTTP Error 404: urllib.error.HTTPError: HTTP Error 404: Not Found

Using PyTorch version 1.9.1 (from pip) instead yields the following error message: ValueError: Cannot find master in https://github.com/pytorch/fairseq. If it's a commit from a forked repo, please call hub.load() with forked repo directly.

To Reproduce

The following snippets are all copy&pasted from READMEs.

import torch
en2fr = torch.hub.load('pytorch/fairseq', 'transformer.wmt14.en-fr', tokenizer='moses', bpe='subword_nmt')

or

import torch
en2de = torch.hub.load('pytorch/fairseq', 'transformer.wmt19.en-de.single_model')

or

import torch
print(torch.hub.list('pytorch/fairseq'))

Code sample

import torch
en2de = torch.hub.load('pytorch/fairseq', 'transformer.wmt19.en-de.single_model')

Expected behavior

Models should be downloaded to local cache so that translation can be started.

Environment

Additional context

N/A

AnticPan commented 3 years ago

This issue may have been solved in lastest main branch.

https://github.com/pytorch/pytorch/blob/b6df043f1fa31f37c4b205eb4083918b919751ff/torch/hub.py#L114

For old version(e.g., 1.9.1), change line MASTER_BRANCH = 'master' to MASTER_BRANCH = 'main' in file <PYTHON-ENV>/site-packages/torch/hub.py can solve this problem, if the target repo's main branch has renamed from master to main.

https://github.com/pytorch/pytorch/blob/880c811aeb6937a44d5cc700ab3d802f95538aa9/torch/hub.py#L58