Conversation
justinwangx
left a comment
There was a problem hiding this comment.
there are a few things i'm worried about with this approach, which are:
- it's not a guarantee that each string in
init_strwill tokenize to the same length - even if all the strings in
init_strtokenize to the same length, i don't think it's necessarily the case that this length will be the intended sequence length
in the prior approach, indexing into the ids after tokenization gives us this guarantee. i think it would be rare for a space-separated sequence of n characters to tokenize to m != n tokens, but i'm not sure that this won't ever occur with some tokenizers.
does using the prior approach but leaving !', '?', and '.' removed still fix our problem?
r.e. identifying strings that are tokenized as the proper suffix, if filter_ids=True, then this should be guaranteed, but, yeah, if not then the string could be tokenized differently
|
i do think it could be good courtesy if |
|
Hello, I understand your concern. I have kept the original method and tried to add spaces before and after the letters in INIT_CHAR. This works for some tokenizers (essentially changing from "!" to " !", making it a new token), but for others, the space becomes an additional token. So perhaps we can add a note [here]( Line 161 in 6e839fe filter_ids=False.
|
|
sorry, i mean -- it seems like the characters that get condensed are '!', '?', and '.' (with emphasis on '!'). if we simply remove these from being used in the initialization (without adding any spaces or thinking about spaces), do the strings generally work fine without getting condensed? |
|
This is indeed an issue... if this occurs frequently, then I think the best fix would be a refactor to using the slices approach that the original repo uses. We adapted this approach from HarmBench, which means that the HarmBench implementation would also suffer from the same problem. |


Referring to issue #15, problem 2, I simulate the user's behavior by interspersing spaces between the letters and systematically removing the characters '!', '?', and '.' from the INIT_CHAR.
It should work well on Llama3 tokenizer and InternLM2 tokenizer, which previously encountered issues (I have not yet tested other models). I suspect that under these circumstances, the
filter_idsparameter might be redundant. Even if we successfully optimize a suffix, it seems infeasible to identify a string that can be tokenized as the suffix's token(unless directly pass input_embeds). It might be beneficial to enhance the warning messages to guide users on reporting model incompatibilities or suggest modifications to the INIT_CHAR to resolve tokenization problems.Let discuss it here and figure it out:)