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

Support min_tokens, min_p parameters for api_server #2681

Merged
merged 4 commits into from
Nov 1, 2024

Conversation

AllentDan
Copy link
Collaborator

No description provided.

@AllentDan
Copy link
Collaborator Author

The weird thing is, min_new_tokens did not work. @irexyc

@irexyc
Copy link
Collaborator

irexyc commented Oct 29, 2024

from lmdeploy import pipeline
pipe = pipeline('/nvme/shared/vicuna-7b-v1.5/')
pipe('hello', gen_config=GenerationConfig())
# Response(text='ಠ\\_ಠ', generate_token_len=7, input_token_len=41, session_id=8, finish_reason='stop', token_ids=[227, 181, 163, 20122, 227, 181, 163], logprobs=None, index=0)

pipe('hello', gen_config=GenerationConfig(min_new_tokens=8))
# Response(text='ಠ\\_ಠ How can I assist you today?', generate_token_len=14, input_token_len=41, session_id=7, finish_reason='stop', token_ids=[227, 181, 163, 20122, 227, 181, 163, 1128, 508, 306, 6985, 366, 9826, 29973], logprobs=None, index=0)

@AllentDan
Copy link
Collaborator Author

But if I set min_new_tokens=100 for internlm2-chat-1_8b, the result is less than 100 tokens.

@irexyc
Copy link
Collaborator

irexyc commented Oct 30, 2024

It only ignore eos token when length of the generated token is less than min_new_tokens. Its behavior should be consistent with transformers, except that transformers support multiple eos tokens

But If encountered stop words token, it will still stop.

@lvhan028 lvhan028 changed the title Support min_tokens for api_server Support min_tokens, min_p parameters for api_server Oct 30, 2024
@lvhan028 lvhan028 requested review from irexyc and lvhan028 October 31, 2024 06:37
@lvhan028
Copy link
Collaborator

lvhan028 commented Nov 1, 2024

Should we update completions_v1 as well?

@AllentDan
Copy link
Collaborator Author

It is a lagecy api from OpenAI. I tend to not update it.

@lvhan028 lvhan028 merged commit 654c457 into InternLM:main Nov 1, 2024
5 checks passed
lvhan028 pushed a commit that referenced this pull request Nov 5, 2024
* Support min_tokens for api_server

* fix

* use min_new_tokens

* add min_p
AllentDan added a commit to AllentDan/lmdeploy that referenced this pull request Nov 13, 2024
* Support min_tokens for api_server

* fix

* use min_new_tokens

* add min_p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants