-
Notifications
You must be signed in to change notification settings - Fork 30
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
[Feature Request] Token Banning/Bias #9
Comments
Read some stuff and basic bias/banning on a token basis seems simple enough to implement. llama.cpp, koboldcpp and the openAI compatible oogabooga endpoints just take a Problem is, this only works for individual tokens, not phrases, and I've found no concrete answers on how this is implemented in the few places I know that have phrase bias like novelAI and AI21.
What's your opinion on this? I feel like it'd be really inefficient to implement this way. Is there any way to mess with the parameters without stopping and restarting the generation? I mostly use bias for punctuation and newlines which are all single tokens more often than not, so I might try to implement the single-token bias when I find some time, but phrase bias would be incredibly useful to have to stop some weird habits models tend to have. |
I think there's no need to include the token in the stop tokens given that we're streaming the tokens, which allows us to determine on the fly the point at which the banned sequence must be omitted from the prompt. But, I don't think there's any way around stopping the generation process to remove the sequence from the context and add the token bias. |
Ah right, we can just manually send a stop command. |
@lmg-anon I'm bad at finding API documentation, does KoboldCPP actually not have a detokenize endpoint? |
@neCo2 No, I don't think so. |
Maintainer said he'll consider adding one in future. |
This would be a very nice feature. This is what I found for the OpenAI API which I think ooba also implements now: https://platform.openai.com/docs/api-reference/chat/create#chat-create-logit_bias But I have kinda little knowledge about the inner workings of these backends. For example, since the user would be typing words, like in NovelAI, I suppose it would need to be translated into the token ids by querying the API first? I think SillyTavern is doing it, I will take a look and see how it does it. But this would be great to be able to make certain sequences less likely |
@culturedniichan That's right. Also, in case you didn't notice, OP did a PR for this issue (but it's still not complete), you can take a look at it here: #25 |
Closing this since regular token bias has been implemented now. Opened up a separate issue for phrase bias here: #58 |
Not too familiar with what options the various backends make available, but if at all possible, a field to ban or bias certain tokens and phrases would be great to have.
The text was updated successfully, but these errors were encountered: