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

Correctly identify special tokens during generation #438

Merged
merged 3 commits into from
Jan 24, 2024
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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ $(PACKAGE_DIST) $(PACKAGE_WHEEL): $(PACKAGE_FILES)

neuronx-tgi: $(PACKAGE_DIST)
docker build --rm -f text-generation-inference/Dockerfile --build-arg VERSION=$(VERSION) -t neuronx-tgi:$(VERSION) .
docker tag neuronx-tgi:$(VERSION) neuronx-tgi:latest

neuronx-tgi-sagemaker: $(PACKAGE_DIST)
docker build --rm -f text-generation-inference/Dockerfile --target sagemaker --build-arg VERSION=$(VERSION) -t neuronx-tgi:$(VERSION) .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def __init__(
tokenizer.pad_token_id = tokenizer.eos_token_id
tokenizer.padding_side = "left"
self.tokenizer = tokenizer
self.special_tokens = [self.tokenizer.eos_token_id, self.tokenizer.pad_token_id]
self.special_tokens = self.tokenizer.all_special_ids
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to use a set() here to use optimized lookup?

self.slots = [Slot(i, tokenizer) for i in range(self.model.batch_size)]

@property
Expand Down Expand Up @@ -459,7 +459,7 @@ def _generate_token(
token_id=next_token,
token_logprob=None,
token_text=next_token_text,
token_is_special=(next_token in [self.special_tokens]),
token_is_special=(next_token in self.special_tokens),
generated_text=generated_text,
)
)
Expand Down