Skip to content
Snippets Groups Projects
Commit 8bf8399d authored by Myle Ott's avatar Myle Ott Committed by Facebook Github Bot
Browse files

Add small comments for MonolingualDataset and TokenBlockDataset

Summary: Pull Request resolved: https://github.com/pytorch/fairseq/pull/669

Differential Revision: D15114160

Pulled By: myleott

fbshipit-source-id: 64f4a8154c8931ddbbe459d4d4a54c46680ad6b6
parent f701aa8c
No related branches found
No related tags found
No related merge requests found
......@@ -78,6 +78,14 @@ class MonolingualDataset(FairseqDataset):
def __getitem__(self, index):
if self.targets is not None:
# *future_target* is the original sentence
# *source* is shifted right by 1 (maybe left-padded with eos)
# *past_target* is shifted right by 2 (left-padded as needed)
#
# Left-to-right language models should condition on *source* and
# predict *future_target*.
# Right-to-left language models should condition on *source* and
# predict *past_target*.
source, future_target, past_target = self.dataset[index]
source, target = self._make_source_target(source, future_target, past_target)
else:
......
......@@ -112,8 +112,8 @@ class TokenBlockDataset(FairseqDataset):
if self.include_targets:
# *target* is the original sentence (=item)
# *source* is rotated left by 1 (maybe left-padded with eos)
# *past_target* is rotated left by 2 (left-padded as needed)
# *source* is shifted right by 1 (maybe left-padded with eos)
# *past_target* is shifted right by 2 (left-padded as needed)
if s == 0:
source = torch.cat([item.new([self.eos]), buffer[0:e - 1]])
past_target = torch.cat([item.new([self.pad, self.eos]), buffer[0:e - 2]])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment