facebookresearch / ParlAI

A framework for training and evaluating AI models on a variety of openly available dialogue datasets.
https://parl.ai
MIT License
10.48k stars 2.09k forks source link

error following quickstart: ZeroDivisionError: Fraction(0, 0) #2013

Closed KiaraGrouwstra closed 5 years ago

KiaraGrouwstra commented 5 years ago

after cloning/installing, the quickstart begins by printing some examples from a dataset:

# display examples from bAbI 10k task 1
python examples/display_data.py -t babi:task10k:1

For me this results in an error:

$ python examples/display_data.py -t babi:task10k:1

[ optional arguments: ] 
[  display_ignore_fields: agent_reply ]
[  max_display_len: 1000 ]
[  num_examples: 10 ]
[ Main ParlAI Arguments: ] 
[  batchsize: 1 ]
[  datapath: /run/media/tycho/meltan/school/ir2/repos/ParlAI/data ]
[  datatype: train:stream ]
[  download_path: /run/media/tycho/meltan/school/ir2/repos/ParlAI/downloads ]
[  hide_labels: False ]
[  image_mode: raw ]
[  init_opt: None ]
[  multitask_weights: [1] ]
[  numthreads: 1 ]
[  show_advanced_args: False ]
[  task: babi:task10k:1 ]
[ ParlAI Model Arguments: ] 
[  dict_class: None ]
[  init_model: None ]
[  model: None ]
[  model_file: None ]
[ PytorchData Arguments: ] 
[  batch_length_range: 5 ]
[  batch_sort_cache_type: pop ]
[  batch_sort_field: text ]
[  numworkers: 4 ]
[  pytorch_context_length: -1 ]
[  pytorch_datapath: None ]
[  pytorch_include_labels: True ]
[  pytorch_preprocess: False ]
[  pytorch_teacher_batch_sort: False ]
[  pytorch_teacher_dataset: None ]
[  pytorch_teacher_task: None ]
[  shuffle: False ]
[ ParlAI Image Preprocessing Arguments: ] 
[  image_cropsize: 224 ]
[  image_size: 256 ]
[ Current ParlAI commit: a9f5928d7e19e5af1992defa4aca7b8ebe8f7e58 ]
[creating task(s): babi:task10k:1]
[loading fbdialog data:/run/media/tycho/meltan/school/ir2/repos/ParlAI/data/bAbI/tasks_1-20_v1-2/en-valid-10k-nosf/qa1_train.txt]
Traceback (most recent call last):
  File "examples/display_data.py", line 22, in <module>
    display_data(opt)
  File "/run/media/tycho/meltan/school/ir2/repos/ParlAI/parlai/scripts/display_data.py", line 46, in display_data
    world.parley()
  File "/run/media/tycho/meltan/school/ir2/repos/ParlAI/parlai/core/worlds.py", line 278, in parley
    agents[0].observe(validate(acts[1]))
  File "/run/media/tycho/meltan/school/ir2/repos/ParlAI/parlai/core/teachers.py", line 355, in observe
    self.metrics.update(observation, self.lastY)
  File "/run/media/tycho/meltan/school/ir2/repos/ParlAI/parlai/core/metrics.py", line 338, in update
    bleu = _bleu(prediction, labels)
  File "/run/media/tycho/meltan/school/ir2/repos/ParlAI/parlai/core/metrics.py", line 162, in _bleu
    smoothing_function=nltkbleu.SmoothingFunction(epsilon=1e-12).method1,
  File "/home/tycho/.local/lib/python3.7/site-packages/nltk/translate/bleu_score.py", line 79, in sentence_bleu
    return corpus_bleu([references], [hypothesis], weights, smoothing_function)
  File "/home/tycho/.local/lib/python3.7/site-packages/nltk/translate/bleu_score.py", line 146, in corpus_bleu
    p_i = modified_precision(references, hypothesis, i)
  File "/home/tycho/.local/lib/python3.7/site-packages/nltk/translate/bleu_score.py", line 287, in modified_precision
    return Fraction(numerator, denominator, _normalize=False)  
  File "/usr/lib/python3.7/fractions.py", line 178, in __new__
    raise ZeroDivisionError('Fraction(%s, 0)' % numerator)
ZeroDivisionError: Fraction(0, 0)

My package versions appear to be as follows:

$ pip freeze
absl-py==0.8.0
aiohttp==3.6.0
alabaster==0.7.12
allennlp==0.8.4
anytree==2.6.0
appdirs==1.4.3
apsw==3.28.0.post1
arandr==0.1.10
aspy.yaml==1.3.0
astor==0.8.0
astroid==2.2.5
async-timeout==3.0.1
atomicwrites==1.3.0
attrs==19.1.0
awscli==1.16.196
Babel==2.7.0
backcall==0.1.0
Beaker==1.10.1
beautifulsoup4==4.6.0
black==19.3b0
bleach==3.1.0
blis==0.2.4
blockify==3.6.3
boto3==1.9.186
botocore==1.12.186
Brlapi==0.7.0
btrfsutil==1.1.1
CacheControl==0.12.5
cfgv==2.0.1
chardet==3.0.4
chrome-gnome-shell==0.0.0
Click==7.0
colorama==0.3.9
colorlog==4.0.2
ConfigArgParse==0.14.0
conllu==0.11
css-parser==1.0.4
cssselect==1.1.0
cycler==0.10.0
cymem==2.0.2
decorator==4.4.0
defusedxml==0.6.0
distlib==0.2.9
distro==1.4.0
dnspython==1.16.0
docopt==0.6.2
docutils==0.14
dukpy==0.3
editdistance==0.5.3
entrypoints==0.3
evdev==1.2.0
feedparser==5.2.1
flake8==3.7.8
flake8-bugbear==19.8.0
flake8-docstrings==1.4.0
flake8-rst-docstrings==0.0.11
flaky==3.6.0
Flask==1.1.1
Flask-Cors==3.0.8
ftfy==5.5.1
future==0.17.1
gast==0.3.1
gevent==1.4.0
gitdb2==2.0.5
GitPython==3.0.2
graphviz==0.11.1
greenlet==0.4.15
grpcio==1.23.0
gunicorn==19.9.0
h5py==2.9.0
html2text==2019.8.11
html5-parser==0.4.8
html5lib==1.0.1
identify==1.4.7
idna==2.8
ifaddr==0.1.6
imagesize==1.1.0
importlib-metadata==0.18
ipykernel==5.1.1
ipython==7.6.1
ipython-genutils==0.1.0
ipywidgets==7.1.1
isc==2.0
isort==4.3.21
itsdangerous==1.1.0
jedi==0.15.1
Jinja2==2.10.1
jmespath==0.9.4
joblib==0.13.2
json5==0.8.5
jsonnet==0.13.0
jsonpickle==1.2
jsonschema==3.0.1
jupyter==1.0.0
jupyter-client==5.2.2
jupyter-console==5.2.0
jupyter-contrib-core==0.3.3
jupyter-contrib-nbextensions==0.5.1
jupyter-core==4.5.0
jupyter-highlight-selected-word==0.2.0
jupyter-latex-envs==1.4.6
jupyter-nbextensions-configurator==0.4.1
jupyterlab==1.1.3
jupyterlab-server==1.0.6
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.0
kiwisolver==1.1.0
lazy-object-proxy==1.4.2
lensfun==0.3.2
lockfile==0.12.2
louis==3.10.0
lutris==0.5.3
lxml==4.4.1
Mako==1.0.14
Markdown==2.6.11
MarkupSafe==1.1.1
matplotlib==3.1.1
mccabe==0.6.1
mechanize==0.4.3
meson==0.51.2
mistune==0.8.4
more-itertools==7.1.0
msgpack==0.6.1
multidict==4.5.2
murmurhash==1.0.2
nb-black==1.0.6
nbconvert==5.6.0
nbformat==4.4.0
netifaces==0.10.9
networkx==2.3
nltk==3.2.1
nodeenv==1.3.3
notebook==6.0.1
numpy==1.16.3
numpydoc==0.9.1
overrides==1.9
packaging==19.0
pandas==0.24.2
pandocfilters==1.4.2
-e git+git@github.com:facebookresearch/ParlAI.git@a9f5928d7e19e5af1992defa4aca7b8ebe8f7e58#egg=parlai
parsimonious==0.8.1
parso==0.5.1
pep517==0.6.0
permutation-test==0.18
pexpect==4.7.0
pickleshare==0.7.5
Pillow==6.0.0
plac==0.9.6
pluggy==0.12.0
pre-commit==1.18.3
preshed==2.0.1
progress==1.5
prometheus-client==0.7.1
prompt-toolkit==1.0.16
protobuf==3.7.1
psutil==5.6.3
ptyprocess==0.6.0
pwquality==1.4.0
py==1.8.0
py-gfm==0.1.4
py-rouge==1.1
pyalpm==0.8.5
pyasn1==0.4.5
pybind11==2.3.0
pycairo==1.18.1
pycodestyle==2.5.0
pycuda==2019.1.2
pydocstyle==4.0.1
pyfavicon==0.1.1
pyflakes==2.1.1
Pygments==2.4.2
PyGObject==3.34.0
pylint==2.3.1
pyotp==2.3.0
pyparsing==2.4.0
PyQt5==5.13.1
PyQt5-sip==4.19.19
PyQtWebEngine==5.13.1
pyrsistent==0.15.3
pyte==0.8.0
pytest==5.0.1
python-dateutil==2.8.0
pytoml==0.1.21
pytools==2019.1.1
pytorch-pretrained-bert==0.6.2
pytz==2019.1
pyusb==1.0.2
pyxdg==0.26
PyYAML==5.1
pyzmq==18.0.2
qtconsole==4.5.1
regex==2019.6.8
requests==2.22.0
requests-mock==1.7.0
responses==0.10.6
restructuredtext-lint==1.3.0
retrying==1.3.3
rsa==3.4.2
ruamel.yaml==0.15.98
s3transfer==0.2.1
scikit-learn==0.21.2
scipy==1.3.0
scons==3.1.1
Send2Trash==1.5.0
sh==1.12.14
simplegeneric==0.8.1
simplejson==3.16.1
six==1.12.0
smmap2==2.0.5
snowballstemmer==1.9.0
soupsieve==1.9.3
spacy==2.1.4
Sphinx==2.1.2
sphinx-rtd-theme==0.4.3
sphinxcontrib-applehelp==1.0.1
sphinxcontrib-devhelp==1.0.1
sphinxcontrib-htmlhelp==1.0.2
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.2
sphinxcontrib-serializinghtml==1.1.3
sqlparse==0.3.0
srsly==0.0.7
team==1.0
tensorboard==1.14.0
tensorboardX==1.6
tensorflow==1.14.0
tensorflow-estimator==1.14.0
tensorflow-serving-api==1.14.0rc0
tensorflow-serving-api-gpu==1.14.0rc0
termcolor==1.1.0
terminado==0.8.1
testpath==0.4.2
text-unidecode==1.2
thefuck==3.29
thinc==7.0.5
tldr==0.5
toml==0.10.0
torch==1.0.1.post2
torchtext==0.4.0
torchvision==0.2.2.post3
tornado==6.0.3
tqdm==4.32.2
traitlets==4.3.2
typed-ast==1.4.0
ujson==1.35
Unidecode==1.1.1
unrardll==0.1.4
urllib3==1.25.3
virtualenv==16.7.5
wasabi==0.2.2
wcwidth==0.1.7
webencodings==0.5.1
websocket-client==0.56.0
websocket-server==0.4
Werkzeug==0.15.4
widgetsnbextension==3.1.4
word2number==1.1
wrapt==1.11.2
yarl==1.3.0
zeroconf==0.23.0
zipp==0.5.2
stephenroller commented 5 years ago

Looks like I'm on nltk 3.4.5. Maybe you can upgrade?

Any other details of your platform? Which python/os?

KiaraGrouwstra commented 5 years ago

I'm using Arch Linux with Python 3.7.4. With nltk 3.4.5 it works for me as well. To improve reproduceability, I wonder if it could make sense to have library versions like this reflected in the requirements.txt?

stephenroller commented 5 years ago

Indeed, it would be better. I considered and there was something that bothered me about that, but I can't remember it now...