Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

[RAG/FiD] Support Left Padded Inputs #4361

Merged
merged 3 commits into from
Feb 16, 2022
Merged

Conversation

klshuster
Copy link
Contributor

Patch description
This patch provides support for RAG and FiD with left-padded input, if desired.

Two methods are required to change:

  1. RagModel.concat_docs_and_input - when left padding, we need to make sure that the concatenated docs and input are padded appropriately
  2. concat_enc_outs - When concatenating encoder outputs for FiD, we need to make sure that we are concatenating the correct parts of the input.

Testing steps
Added CI test.

$ pytest -k TestLeftPadding
=====test session starts =====
platform linux -- Python 3.7.9, pytest-5.3.2, py-1.10.0, pluggy-0.13.1
rootdir: /private/home/kshuster/ParlAI, inifile: pytest.ini, testpaths: tests, parlai/tasks
plugins: hydra-core-1.1.0, requests-mock-1.7.0, regressions-2.1.1, datadir-1.3.1
collected 1312 items / 1310 deselected / 2 selected

tests/nightly/gpu/test_rag.py ..                                                                                                                                              [100%]

====slowest 10 test durations ====
10.29s call     tests/nightly/gpu/test_rag.py::TestLeftPadding::test_concat_docs_and_input

(0.00 durations hidden.  Use -vv to show these durations.)
====2 passed, 1310 deselected, 4 warnings in 21.34s ====

Copy link
Contributor

@stephenroller stephenroller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx for tests

parlai/agents/fid/fid.py Outdated Show resolved Hide resolved
Co-authored-by: Stephen Roller <roller@fb.com>
@klshuster klshuster merged commit 7a28f15 into main Feb 16, 2022
@klshuster klshuster deleted the support_left_padding_rag branch February 16, 2022 22:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants