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

[BugFix] Fix llama3 eot_id #8371

Merged
merged 1 commit into from
May 13, 2024
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
7 changes: 5 additions & 2 deletions paddlenlp/transformers/llama/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,12 @@
ENDOFTEXT = "<|end_of_text|>"
IMSTART = "<|start_header_id|>"
IMEND = "<|end_header_id|>"
EOTID = "<|eot_id|>"
# as the default behavior is changed to allow special tokens in
# regular texts, the surface forms of special tokens need to be
# as different as possible to minimize the impact
EXTRAS = tuple((f"<|reserved_special_token_{i}|>" for i in range(250)))
SPECIAL_TOKENS = (BEGINOFTEXT, ENDOFTEXT) + EXTRAS[0:4] + (IMSTART, IMEND) + EXTRAS[4:]
EXTRAS = tuple((f"<|reserved_special_token_{i}|>" for i in range(251)))
SPECIAL_TOKENS = (BEGINOFTEXT, ENDOFTEXT) + EXTRAS[0:4] + (IMSTART, IMEND, EXTRAS[4], EOTID) + EXTRAS[5:]

tiktoken = None

Expand Down Expand Up @@ -354,9 +355,11 @@

self.tokenizer = enc # type: tiktoken.Encoding

self.bod_id = self.special_tokens[BEGINOFTEXT]

Check warning on line 358 in paddlenlp/transformers/llama/tokenizer.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/transformers/llama/tokenizer.py#L358

Added line #L358 was not covered by tests
self.eod_id = self.special_tokens[ENDOFTEXT]
self.start_header_id = self.special_tokens[IMSTART]
self.end_header_id = self.special_tokens[IMEND]
self.eot_id = self.special_tokens[EOTID]

Check warning on line 362 in paddlenlp/transformers/llama/tokenizer.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/transformers/llama/tokenizer.py#L362

Added line #L362 was not covered by tests

if "pad_token_id" in kwargs:
self.pad_token_id = kwargs["pad_token_id"]
Expand Down
Loading