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

Allow input_ids in the input of the /generate endpoint #363

Merged

Conversation

lolipopshock
Copy link
Contributor

As of now, GenerateReqInput only allows text in the input; this PR enables specifying either text or input_ids as the request input. Supplementing input_ids allows more precise token operations in the input; and hopefully this simple patch won't affect other functionality.

if cur_output_tokens[-1] == self.tokenizer.eos_token_id:
recv_obj.meta_info[i]['output_tokens'] = cur_output_tokens[:-1]
else:
recv_obj.meta_info[i]['output_tokens'] = cur_output_tokens
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain why this is needed?

Copy link
Contributor Author

@lolipopshock lolipopshock Jun 3, 2024

Choose a reason for hiding this comment

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

Oh sry I just saw your comment. I think this piece of code just tries to make sure the token output is aligned with text output. If I remember correctly, when I tested last time, if the last token is EOS, the text output does not include the <|endoftext|> token while the <|endoftext|> token id will be included in output_tokens without this code. But perhaps I am hallucinating on this since I did the test a while ago...

@merrymercy merrymercy force-pushed the shannons/allow-input-ids-in-generate branch 2 times, most recently from bc6703a to 48a78a5 Compare May 12, 2024 22:12
@merrymercy merrymercy merged commit 04c0b21 into sgl-project:main May 12, 2024
@merrymercy
Copy link
Contributor

@lolipopshock Thanks for the contribution. It is merged. I do not understand this comment (#363 (comment)) so I reverted it. Feel free to reopen

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

Successfully merging this pull request may close these issues.

None yet

2 participants