Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Fix an index bug in BART prediction. #175

Merged
merged 2 commits into from
Dec 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Fixed

- Fix an index bug in BART prediction.

### Added

- Added link to source code to API docs.
Expand Down
2 changes: 1 addition & 1 deletion allennlp_models/generation/models/bart.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def make_output_human_readable(self, output_dict: Dict[str, torch.Tensor]) -> Di
predicted_tokens = [None] * predictions.shape[0]
for i in range(predictions.shape[0]):
predicted_tokens[i] = self._indexer.indices_to_tokens(
{"token_ids": predictions[0].tolist()}, self.vocab
{"token_ids": predictions[i].tolist()}, self.vocab
Copy link
Member

Choose a reason for hiding this comment

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

Wow, what a bug

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed, I'm surprised I didn't catch it earlier. Perhaps I was only using batch size 1 when making predictions and missed it.

)
output_dict["predicted_tokens"] = predicted_tokens

Expand Down