Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T5 prompt learning fixes missing from r.11.0 merge #5075

Merged
merged 6 commits into from
Oct 6, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,15 @@ def predict_step(self, batch: Any, batch_idx: int, dataloader_idx: int = 0) -> A
idx = pred.index(self.tokenizer.eos_id)
pred = pred[:idx]

special_token_ids = (
self.tokenizer.special_token_to_id.values()
if hasattr(self.tokenizer, 'special_token_to_id')
else self.tokenizer.tokenizer.additional_special_tokens_ids
)
pred = [
id
for id in pred
if id not in self.tokenizer.tokenizer.additional_special_tokens_ids
and id not in self.tokenizer.text_to_ids(T5Sentinel.FIRST.value)
if id not in special_token_ids and id not in self.tokenizer.text_to_ids(T5Sentinel.FIRST.value)
] # delete the sentinel token at the beginning of prediction

pred = self.tokenizer.ids_to_text(pred)
Expand All @@ -445,8 +449,7 @@ def predict_step(self, batch: Any, batch_idx: int, dataloader_idx: int = 0) -> A
label = [
id
for id in label
if id not in self.tokenizer.tokenizer.additional_special_tokens_ids
and id not in self.tokenizer.text_to_ids(T5Sentinel.FIRST.value)
if id not in special_token_ids and id not in self.tokenizer.text_to_ids(T5Sentinel.FIRST.value)
] # delete the sentinel token at the beginning of label

label = self.tokenizer.ids_to_text(label)
Expand Down