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

about labels and decoder_attention_mask #59

Open
gitfor20 opened this issue Jan 4, 2024 · 0 comments
Open

about labels and decoder_attention_mask #59

gitfor20 opened this issue Jan 4, 2024 · 0 comments

Comments

@gitfor20
Copy link

gitfor20 commented Jan 4, 2024

target_text_encoding = self.tokenizer(
data_row["target_text"],
max_length=self.target_max_token_len,
padding="max_length",
truncation=True,
return_attention_mask=True,
add_special_tokens=True,
return_tensors="pt",
)

    labels = target_text_encoding["input_ids"]
    labels[
        labels == 0
    ] = -100  # to make sure we have correct labels for T5 text generation

    return dict(
        source_text_input_ids=source_text_encoding["input_ids"].flatten(),
        source_text_attention_mask=source_text_encoding["attention_mask"].flatten(),
        labels=labels.flatten(),
        labels_attention_mask=target_text_encoding["attention_mask"].flatten(),
    )

as i know, the decoder_input_ids is default to be got by shifting labels, but at these codes, the decoder_attention_mask is matched to labels. so i think the decoder_input_ids prepared by models will not be matched to decoder_attention_mask.
is it a bug or my understanding is wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant