ParlAI icon indicating copy to clipboard operation
ParlAI copied to clipboard

BlenderBot3 3B Search Error

Open a-ichikura opened this issue 3 years ago • 2 comments

Bug description I tried to execute BlenderBot3 with search engine according to README.md but it failed due to the AttributeError.

parlai interactive --model projects.bb3.agents.r2c2_bb3_agent:BB3SubSearchAgent --model-file zoo:bb3/bb3_3B/model --rag-retriever-type search_engine --search-server RELEVANT_SEARCH_SERVER
Enter Your Message: Do you know Snoopy?
Traceback (most recent call last):
  File "/home/jsk/ichikura/anaconda3/envs/parlai/bin/parlai", line 8, in <module>
    sys.exit(main())
  File "/home/jsk/ichikura/anaconda3/envs/parlai/lib/python3.8/site-packages/parlai/__main__.py", line 14, in main
    superscript_main()
  File "/home/jsk/ichikura/anaconda3/envs/parlai/lib/python3.8/site-packages/parlai/core/script.py", line 325, in superscript_main
    return SCRIPT_REGISTRY[cmd].klass._run_from_parser_and_opt(opt, parser)
  File "/home/jsk/ichikura/anaconda3/envs/parlai/lib/python3.8/site-packages/parlai/core/script.py", line 108, in _run_from_parser_and_opt
    return script.run()
  File "/home/jsk/ichikura/anaconda3/envs/parlai/lib/python3.8/site-packages/parlai/scripts/interactive.py", line 118, in run
    return interactive(self.opt)
  File "/home/jsk/ichikura/anaconda3/envs/parlai/lib/python3.8/site-packages/parlai/scripts/interactive.py", line 93, in interactive
    world.parley()
  File "/home/jsk/ichikura/anaconda3/envs/parlai/lib/python3.8/site-packages/parlai/tasks/interactive/worlds.py", line 89, in parley
    acts[1] = agents[1].act()
  File "/home/jsk/ichikura/anaconda3/envs/parlai/lib/python3.8/site-packages/parlai/core/torch_agent.py", line 2148, in act
    response = self.batch_act([self.observation])[0]
  File "/home/jsk/ichikura/anaconda3/envs/parlai/lib/python3.8/site-packages/parlai/core/torch_agent.py", line 2244, in batch_act
    output = self.eval_step(batch)
  File "/home/jsk/ichikura/anaconda3/envs/parlai/lib/python3.8/site-packages/projects/seeker/agents/seeker.py", line 160, in eval_step
    output = TorchGeneratorAgent.eval_step(self, batch)
  File "/home/jsk/ichikura/anaconda3/envs/parlai/lib/python3.8/site-packages/parlai/core/torch_generator_agent.py", line 901, in eval_step
    beam_preds_scores, beams = self._generate(
  File "/home/jsk/ichikura/anaconda3/envs/parlai/lib/python3.8/site-packages/parlai/agents/rag/rag.py", line 684, in _generate
    gen_outs = self._rag_generate(batch, beam_size, max_ts, prefix_tokens)
  File "/home/jsk/ichikura/anaconda3/envs/parlai/lib/python3.8/site-packages/parlai/agents/rag/rag.py", line 727, in _rag_generate
    return self._generation_agent._generate(
  File "/home/jsk/ichikura/anaconda3/envs/parlai/lib/python3.8/site-packages/parlai/core/torch_generator_agent.py", line 1163, in _generate
    encoder_states = model.encoder(*self._encoder_input(batch))
  File "/home/jsk/ichikura/anaconda3/envs/parlai/lib/python3.8/site-packages/projects/seeker/agents/seeker_modules.py", line 244, in encoder
    output = super().encoder(
  File "/home/jsk/ichikura/anaconda3/envs/parlai/lib/python3.8/site-packages/parlai/agents/fid/fid.py", line 149, in encoder
    enc_out, mask, input_turns_cnt, top_docs, top_doc_scores = super().encoder(
  File "/home/jsk/ichikura/anaconda3/envs/parlai/lib/python3.8/site-packages/parlai/agents/rag/modules.py", line 192, in encoder
    expanded_input, top_docs, top_doc_scores = self.retrieve_and_concat(
  File "/home/jsk/ichikura/anaconda3/envs/parlai/lib/python3.8/site-packages/parlai/agents/rag/modules.py", line 327, in retrieve_and_concat
    top_docs, top_doc_scores = self.retriever.retrieve(query_vec)
  File "/home/jsk/ichikura/anaconda3/envs/parlai/lib/python3.8/site-packages/parlai/agents/rag/retrievers.py", line 419, in retrieve
    docs, scores = self.retrieve_and_score(query)
  File "/home/jsk/ichikura/anaconda3/envs/parlai/lib/python3.8/site-packages/projects/bb3/agents/r2c2_bb3_agent.py", line 166, in retrieve_and_score
    return super().retrieve_and_score(query)
  File "/home/jsk/ichikura/anaconda3/envs/parlai/lib/python3.8/site-packages/parlai/agents/rag/retrievers.py", line 1212, in retrieve_and_score
    search_queries = self.generate_search_query(query)
  File "/home/jsk/ichikura/anaconda3/envs/parlai/lib/python3.8/site-packages/projects/seeker/agents/seeker_modules.py", line 130, in generate_search_query
    if self.search_queries:
  File "/home/jsk/ichikura/anaconda3/envs/parlai/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1185, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'BB3Retriever' object has no attribute 'search_queries'

It seems no problem when I do not use search engine.

parlai interactive --model projects.bb3.agents.r2c2_bb3_agent:BB3SubSearchAgent --model-file zoo:bb3/bb3_3B/model --force-skip-retrieval True --search-server none

And also, BlenderBot2 succeeds with search engine.

python -m parlai.scripts.safe_interactive --model-file zoo:blenderbot2/blenderbot2_400M/model --search_server 0.0.0.0:8080

I execute all projects on Anaconda3. Here is my environment.

$ conda env export --no-build
name: parlai
channels:
  - pytorch
  - defaults
dependencies:
  - _libgcc_mutex=0.1
  - _openmp_mutex=5.1
  - blas=1.0
  - brotlipy=0.7.0
  - bzip2=1.0.8
  - ca-certificates=2022.07.19
  - certifi=2022.6.15
  - cffi=1.15.0
  - cryptography=37.0.1
  - cudatoolkit=11.3.1
  - ffmpeg=4.3
  - freetype=2.11.0
  - giflib=5.2.1
  - gmp=6.2.1
  - gnutls=3.6.15
  - intel-openmp=2021.4.0
  - jpeg=9e
  - lame=3.100
  - lcms2=2.12
  - lerc=3.0
  - libdeflate=1.8
  - libedit=3.1.20210910
  - libffi=3.2.1
  - libgcc-ng=11.2.0
  - libgomp=11.2.0
  - libiconv=1.16
  - libidn2=2.3.2
  - libpng=1.6.37
  - libstdcxx-ng=11.2.0
  - libtasn1=4.16.0
  - libtiff=4.4.0
  - libunistring=0.9.10
  - libuv=1.40.0
  - libwebp=1.2.2
  - libwebp-base=1.2.2
  - lz4-c=1.9.3
  - mkl=2021.4.0
  - mkl-service=2.4.0
  - mkl_fft=1.3.1
  - mkl_random=1.2.2
  - ncurses=6.3
  - nettle=3.7.3
  - numpy-base=1.23.1
  - openh264=2.1.1
  - openssl=1.1.1q
  - pip=22.1.2
  - pycparser=2.21
  - pyopenssl=22.0.0
  - pysocks=1.7.1
  - python=3.8.0
  - pytorch=1.11.0
  - pytorch-mutex=1.0
  - readline=7.0
  - setuptools=63.4.1
  - six=1.16.0
  - sqlite=3.33.0
  - tk=8.6.12
  - torchaudio=0.11.0
  - torchvision=0.12.0
  - typing_extensions=4.3.0
  - wheel=0.37.1
  - xz=5.2.5
  - zlib=1.2.12
  - zstd=1.5.2
  - pip:
    - aiohttp==3.8.1
    - aiosignal==1.2.0
    - alabaster==0.7.12
    - antlr4-python3-runtime==4.8
    - anyascii==0.3.1
    - asttokens==2.0.8
    - async-timeout==4.0.2
    - attrs==20.2.0
    - babel==2.10.3
    - backcall==0.2.0
    - beautifulsoup4==4.9.3
    - bitarray==2.6.0
    - blis==0.7.8
    - cachetools==5.2.0
    - catalogue==2.0.8
    - chardet==4.0.0
    - charset-normalizer==2.1.1
    - click==8.1.3
    - colorama==0.4.5
    - coloredlogs==15.0.1
    - commonmark==0.9.1
    - contractions==0.1.72
    - cymem==2.0.6
    - cython==0.29.32
    - datasets==2.2.1
    - decorator==5.1.1
    - dill==0.3.5.1
    - docformatter==1.5.0
    - docutils==0.15.2
    - emoji==2.0.0
    - executing==1.0.0
    - fairscale==0.4.8
    - fairseq==0.12.2
    - filelock==3.8.0
    - fire==0.4.0
    - flake8==5.0.4
    - flake8-bugbear==22.8.23
    - frozenlist==1.3.1
    - fsspec==2022.8.2
    - fuzzywuzzy==0.18.0
    - gitdb==4.0.9
    - gitdb2==4.0.2
    - gitpython==3.1.27
    - google-api-core==2.10.0
    - google-auth==2.11.0
    - google-cloud-core==2.3.2
    - google-cloud-storage==2.5.0
    - google-crc32c==1.5.0
    - google-resumable-media==2.3.3
    - googleapis-common-protos==1.56.4
    - googlesearch-python==1.1.0
    - html2text==2020.1.16
    - huggingface-hub==0.9.1
    - humanfriendly==10.0
    - hydra-core==1.0.7
    - idna==2.10
    - imagesize==1.4.1
    - importlib-metadata==4.2.0
    - importlib-resources==5.9.0
    - iniconfig==1.1.1
    - iopath==0.1.10
    - ipython==8.4.0
    - jedi==0.18.1
    - jinja2==3.1.2
    - joblib==1.1.0
    - jsonlines==3.1.0
    - langcodes==3.3.0
    - lxml==4.9.1
    - markdown==3.3.2
    - markdown-it-py==0.5.8
    - markupsafe==2.1.1
    - matplotlib-inline==0.1.6
    - mccabe==0.7.0
    - mock==4.0.3
    - multidict==6.0.2
    - multiprocess==0.70.13
    - murmurhash==1.0.8
    - myst-parser==0.12.10
    - ninja==1.10.2.3
    - nltk==3.7
    - numpy==1.23.2
    - omegaconf==2.0.6
    - packaging==21.3
    - pandas==1.4.4
    - parlai==1.7.0
    - parso==0.8.3
    - pathy==0.6.2
    - pexpect==4.8.0
    - pickleshare==0.7.5
    - pillow==9.2.0
    - pluggy==1.0.0
    - portalocker==2.5.1
    - preshed==3.0.7
    - prompt-toolkit==3.0.31
    - protobuf==3.20.1
    - ptyprocess==0.7.0
    - pure-eval==0.2.2
    - py==1.11.0
    - py-gfm==1.0.2
    - py-rouge==1.1
    - pyahocorasick==1.4.4
    - pyarrow==9.0.0
    - pyasn1==0.4.8
    - pyasn1-modules==0.2.8
    - pycodestyle==2.9.1
    - pydantic==1.9.2
    - pyflakes==2.5.0
    - pygments==2.13.0
    - pyparsing==3.0.9
    - pytest==7.1.3
    - pytest-datadir==1.3.1
    - pytest-regressions==2.3.1
    - python-dateutil==2.8.2
    - pytz==2022.2.1
    - pyyaml==6.0
    - pyzmq==23.2.1
    - regex==2022.8.17
    - requests==2.25.1
    - requests-mock==1.10.0
    - responses==0.18.0
    - rich==12.5.1
    - rsa==4.9
    - sacrebleu==2.2.0
    - scikit-learn==1.1.2
    - scipy==1.9.1
    - sh==1.14.3
    - smart-open==5.2.1
    - smmap==5.0.0
    - snowballstemmer==2.2.0
    - soupsieve==2.3.2.post1
    - spacy==3.4.1
    - spacy-legacy==3.0.10
    - spacy-loggers==1.0.3
    - sphinx==2.2.2
    - sphinx-autodoc-typehints==1.10.3
    - sphinx-rtd-theme==1.0.0
    - sphinxcontrib-applehelp==1.0.2
    - sphinxcontrib-devhelp==1.0.2
    - sphinxcontrib-htmlhelp==2.0.0
    - sphinxcontrib-jsmath==1.0.1
    - sphinxcontrib-qthelp==1.0.3
    - sphinxcontrib-serializinghtml==1.1.5
    - srsly==2.4.4
    - stack-data==0.5.0
    - subword-nmt==0.3.8
    - tabulate==0.8.10
    - tensorboardx==2.5.1
    - termcolor==1.1.0
    - textsearch==0.0.24
    - thinc==8.1.0
    - threadpoolctl==3.1.0
    - tokenizers==0.12.1
    - tomli==2.0.1
    - torch==1.12.1
    - torchtext==0.13.1
    - tornado==6.2
    - tqdm==4.62.3
    - traitlets==5.3.0
    - transformers==4.21.2
    - typer==0.4.2
    - unidecode==1.3.4
    - untokenize==0.1.1
    - urllib3==1.26.12
    - wasabi==0.10.1
    - wcwidth==0.2.5
    - websocket-client==1.4.0
    - xxhash==3.0.0
    - yarl==1.8.1
    - zipp==3.8.1
prefix: /home/jsk/ichikura/anaconda3/envs/parlai

How can I interact with BlenderBot3 with search engine?

a-ichikura avatar Sep 04 '22 08:09 a-ichikura

After that, with the following code, it seems to succeed.

$ parlai i -mf zoo:bb3/bb3_3B/model -o ~/ParlAI/parlai/opt_presets/gen/r2c2_bb3 --search-server 0.0.0.0:8080

However, what is the difference between the official code?

parlai interactive --model projects.bb3.agents.r2c2_bb3_agent:BB3SubSearchAgent --model-file zoo:bb3/bb3_3B/model --rag-retriever-type search_engine --search-server RELEVANT_SEARCH_SERVER

a-ichikura avatar Sep 04 '22 09:09 a-ichikura

The command in the original comment (with BB3SubSearchAgent) should only be used if you wish to interact directly with a certain module of BB3.

The only module of BB3 that requires access to search is the search knowledge module; you can see in the instructions that you must directly set the search queries for the module so that it can get the relevant documents

klshuster avatar Sep 12 '22 17:09 klshuster

This issue has not had activity in 30 days. Please feel free to reopen if you have more issues. You may apply the "never-stale" tag to prevent this from happening.

github-actions[bot] avatar Oct 13 '22 00:10 github-actions[bot]