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

feat: use '\n' as default eos_token in demo #39

Merged
merged 2 commits into from
Nov 7, 2023
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
3 changes: 3 additions & 0 deletions demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ python text_generation.py \
--model 01-ai/Yi-6B \
--tokenizer 01-ai/Yi-6B \
--max-tokens 512 \
--eos-token $'\n' \
--streaming
```

Expand All @@ -21,5 +22,7 @@ torchrun --nproc_per_node 2 \
text_generation_tp.py \
--model 01-ai/Yi-6B \
--max-tokens 512 \
--eos-token $'\n' \
--streaming

```
7 changes: 7 additions & 0 deletions demo/text_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ def parse_inputs():
default="Let me tell you an interesting story about cat Tom and mouse Jerry,",
help="The prompt to start with",
)
parser.add_argument(
"--eos-token",
type=str,
default="<|endoftext|>",
help="End of sentence token",
)
args = parser.parse_args()
return args

Expand All @@ -55,6 +61,7 @@ def main(args):
inputs.input_ids.cuda(),
max_new_tokens=args.max_tokens,
streamer=streamer,
eos_token_id=tokenizer.convert_tokens_to_ids(args.eos_token),
do_sample=True,
)
if streamer is None:
Expand Down
7 changes: 7 additions & 0 deletions demo/text_generation_tp.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ def parse_inputs():
default="Let me tell you an interesting story about cat Tom and mouse Jerry,",
help="The prompt to start with",
)
parser.add_argument(
"--eos-token",
type=str,
default="<|endoftext|>",
help="End of sentence token",
)
args = parser.parse_args()
return args

Expand Down Expand Up @@ -93,6 +99,7 @@ def on_finalized_text(self, text: str, stream_end: bool = False):
inputs.input_ids.cuda(),
max_new_tokens=args.max_tokens,
streamer=streamer,
eos_token_id=tokenizer.convert_tokens_to_ids(args.eos_token),
do_sample=True,
)
if distributed.get_rank() == 0 and streamer is None:
Expand Down