|
|
@@ -4391,6 +4391,9 @@ static void llm_load_vocab(
|
|
|
} else if (
|
|
|
tokenizer_pre == "command-r") {
|
|
|
vocab.type_pre = LLAMA_VOCAB_PRE_TYPE_COMMAND_R;
|
|
|
+ } else if (
|
|
|
+ tokenizer_pre == "qwen2") {
|
|
|
+ vocab.type_pre = LLAMA_VOCAB_PRE_TYPE_QWEN2;
|
|
|
} else if (
|
|
|
tokenizer_pre == "olmo") {
|
|
|
vocab.type_pre = LLAMA_VOCAB_PRE_TYPE_OLMO;
|
|
|
@@ -12263,6 +12266,13 @@ struct llm_tokenizer_bpe {
|
|
|
"'s|'t|'re|'ve|'m|'ll|'d| ?\\p{L}+| ?\\p{N}+| ?[^\\s\\p{L}\\p{N}]+|\\s+(?!\\S)",
|
|
|
});
|
|
|
break;
|
|
|
+ case LLAMA_VOCAB_PRE_TYPE_QWEN2:
|
|
|
+ word_collection = unicode_regex_split(text, {
|
|
|
+ // original regex from tokenizer.json
|
|
|
+ // "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?\\p{L}+|\\p{N}| ?[^\\s\\p{L}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+"
|
|
|
+ "(?:'[sS]|'[tT]|'[rR][eE]|'[vV][eE]|'[mM]|'[lL][lL]|'[dD])|[^\\r\\n\\p{L}\\p{N}]?\\p{L}+|\\p{N}| ?[^\\s\\p{L}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
|
|
|
+ });
|
|
|
+ break;
|
|
|
default:
|
|
|
// default regex for BPE tokenization pre-processing
|
|
|
word_collection = unicode_regex_split(text, {
|