-
Notifications
You must be signed in to change notification settings - Fork 234
fix bos token missing #346
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
base: main
Are you sure you want to change the base?
Conversation
| local_working_dir: DataFolderLike | None = None, | ||
| save_filename: str = None, # if defined, the final output filename will be this | ||
| tokenizer_name_or_path: str = "gpt2", # tokenizer to use, from HF or a local | ||
| bos_token: str = "<|startoftext|>", # whether to add the BOS token nefore each document |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| bos_token: str = "<|startoftext|>", # whether to add the BOS token nefore each document | |
| bos_token: str | None = None, # whether to add the BOS token nefore each document |
should disable it by default
| elif self.bos_token is not None or self.eos_token is not None: | ||
| special_tokens = [] | ||
| if self.bos_token: | ||
| special_tokens.append(("<BOS>", self.tokenizer.token_to_id(self.bos_token))) | ||
| if self.eos_token: | ||
| special_tokens.append(("<EOS>", self.tokenizer.token_to_id(self.eos_token))) | ||
| if self.bos_token and not self.eos_token: | ||
| single = "<BOS> $A" | ||
| elif self.eos_token and not self.bos_token: | ||
| single = "$A <EOS>" | ||
| else: | ||
| single = "<BOS> $A <EOS>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| elif self.bos_token is not None or self.eos_token is not None: | |
| special_tokens = [] | |
| if self.bos_token: | |
| special_tokens.append(("<BOS>", self.tokenizer.token_to_id(self.bos_token))) | |
| if self.eos_token: | |
| special_tokens.append(("<EOS>", self.tokenizer.token_to_id(self.eos_token))) | |
| if self.bos_token and not self.eos_token: | |
| single = "<BOS> $A" | |
| elif self.eos_token and not self.bos_token: | |
| single = "$A <EOS>" | |
| else: | |
| single = "<BOS> $A <EOS>" | |
| elif self.bos_token is not None or self.eos_token is not None: | |
| special_tokens = [] | |
| single_elems = [] | |
| if self.bos_token: | |
| special_tokens.append(("<BOS>", self.tokenizer.token_to_id(self.bos_token))) | |
| single_elems.append("<BOS>") | |
| single_elems.append("$A") | |
| if self.eos_token: | |
| special_tokens.append(("<EOS>", self.tokenizer.token_to_id(self.eos_token))) | |
| single_elems.append("<EOS>") |
| self._tokenizer.post_processor = TemplateProcessing( | ||
| single="$A <EOS>", | ||
| special_tokens=[("<EOS>", self.tokenizer.token_to_id(self.eos_token))], | ||
| single=single, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| single=single, | |
| single=" ".join(single_elems), |
|
hi, can you please make this pr editable by maintainers? |
This fixes #345 by checking for all three combinations of bos/eos existence and using an appropriate template for each case