-
Notifications
You must be signed in to change notification settings - Fork 693
[Feature]support bad_words #3055
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
Conversation
|
Thanks for your contribution! |
| # Update bad tokens len | ||
| max_bad_tokens_len = ( | ||
| paddle.max(self.share_inputs["bad_tokens_len"]) | ||
| if paddle.max(self.share_inputs["bad_tokens_len"]) > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的写法可以优化一下,可能会执行两次max算子,可以在初始化时把bad_tokens_len初始值填充为1
| continue | ||
|
|
||
| if prompt_token_ids not in self._bad_words_token_ids: | ||
| self._bad_words_token_ids.extend(prompt_token_ids) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里需要去重吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要吧,如果给的bad_words有重复的话
功能描述
支持 bad_words,用于禁止模型生成某些特定词。通过将bad_words中的词语的采样概率设置为1e-10来避免生成该词。
使用方法
online inference
请求中加入bad_words参数
offline inference