Skip to content

Commit edc7649

Browse files
committed
Add Smaug tokenizer support
1 parent 5ca49cb commit edc7649

File tree

6 files changed

+9
-6
lines changed

6 files changed

+9
-6
lines changed

convert-hf-to-gguf-update.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class TOKENIZER_TYPE(IntEnum):
8181
{"name": "jina-v2-en", "tokt": TOKENIZER_TYPE.WPM, "repo": "https://huggingface.co/jinaai/jina-embeddings-v2-base-en", }, # WPM!
8282
{"name": "jina-v2-es", "tokt": TOKENIZER_TYPE.BPE, "repo": "https://huggingface.co/jinaai/jina-embeddings-v2-base-es", },
8383
{"name": "jina-v2-de", "tokt": TOKENIZER_TYPE.BPE, "repo": "https://huggingface.co/jinaai/jina-embeddings-v2-base-de", },
84+
{"name": "smaug-bpe", "tokt": TOKENIZER_TYPE.BPE, "repo": "https://huggingface.co/abacusai/Smaug-Llama-3-70B-Instruct", },
8485
]
8586

8687

convert-hf-to-gguf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,6 @@ def get_vocab_base_pre(self, tokenizer) -> str:
461461
if chkhsh == "b6dc8df998e1cfbdc4eac8243701a65afe638679230920b50d6f17d81c098166":
462462
# ref: https://huggingface.co/allenai/OLMo-1.7-7B-hf
463463
res = "olmo"
464-
if chkhsh == "a8594e3edff7c29c003940395316294b2c623e09894deebbc65f33f1515df79e":
465-
# ref: https://huggingface.co/databricks/dbrx-base
466-
res = "dbrx"
467464
if chkhsh == "0876d13b50744004aa9aeae05e7b0647eac9d801b5ba4668afc01e709c15e19f":
468465
# ref: https://huggingface.co/jinaai/jina-embeddings-v2-base-en
469466
res = "jina-v2-en"
@@ -473,6 +470,9 @@ def get_vocab_base_pre(self, tokenizer) -> str:
473470
if chkhsh == "27949a2493fc4a9f53f5b9b029c82689cfbe5d3a1929bb25e043089e28466de6":
474471
# ref: https://huggingface.co/jinaai/jina-embeddings-v2-base-de
475472
res = "jina-v2-de"
473+
if chkhsh == "c136ed14d01c2745d4f60a9596ae66800e2b61fa45643e72436041855ad4089d":
474+
# ref: https://huggingface.co/abacusai/Smaug-Llama-3-70B-Instruct
475+
res = "smaug-bpe"
476476

477477
if res is None:
478478
logger.warning("\n")

llama.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4472,6 +4472,9 @@ static void llm_load_vocab(
44724472
} else if (
44734473
tokenizer_pre == "dbrx") {
44744474
vocab.type_pre = LLAMA_VOCAB_PRE_TYPE_DBRX;
4475+
} else if (
4476+
tokenizer_pre == "smaug-bpe") {
4477+
vocab.type_pre = LLAMA_VOCAB_PRE_TYPE_SMAUG;
44754478
} else {
44764479
throw std::runtime_error(format("unknown pre-tokenizer type: '%s'", tokenizer_pre.c_str()));
44774480
}
@@ -12310,6 +12313,7 @@ struct llm_tokenizer_bpe {
1231012313
});
1231112314
break;
1231212315
case LLAMA_VOCAB_PRE_TYPE_DBRX:
12316+
case LLAMA_VOCAB_PRE_TYPE_SMAUG:
1231312317
word_collection = unicode_regex_split(text, {
1231412318
// same as llama3
1231512319
"(?:'[sS]|'[tT]|'[rR][eE]|'[vV][eE]|'[mM]|'[lL][lL]|'[dD])|[^\\r\\n\\p{L}\\p{N}]?\\p{L}+|\\p{N}{1,3}| ?[^\\s\\p{L}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",

llama.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ extern "C" {
8585
LLAMA_VOCAB_PRE_TYPE_QWEN2 = 11,
8686
LLAMA_VOCAB_PRE_TYPE_OLMO = 12,
8787
LLAMA_VOCAB_PRE_TYPE_DBRX = 13,
88+
LLAMA_VOCAB_PRE_TYPE_SMAUG = 14,
8889
};
8990

9091
// note: these values should be synchronized with ggml_rope

models/ggml-vocab-llama-bpe.gguf.inp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,3 @@ __ggml_vocab_test__
104104

105105
🚀 (normal) 😶‍🌫️ (multiple emojis concatenated) ✅ 🦙🦙 3 33 333 3333 33333 333333 3333333 33333333 3.3 3..3 3...3 កាន់តែពិសេសអាច😁 ?我想在apple工作1314151天~ ------======= нещо на Български ''''''```````""""......!!!!!!?????? I've been 'told he's there, 'RE you sure? 'M not sure I'll make it, 'D you like some tea? We'Ve a'lL
106106
__ggml_vocab_test__
107-
Việt
108-
__ggml_vocab_test__

models/ggml-vocab-llama-bpe.gguf.out

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,3 @@
4141
8765 8765 1644
4242
8765 8765 8765
4343
198 4815 15073 66597 8004 1602 2355 79772 11187 9468 248 222 320 8416 8 27623 114 102470 9468 234 104 31643 320 36773 100166 98634 8 26602 227 11410 99 247 9468 99 247 220 18 220 1644 220 8765 220 8765 18 220 8765 1644 220 8765 8765 220 8765 8765 18 220 8765 8765 1644 220 18 13 18 220 18 497 18 220 18 1131 18 220 21549 222 98629 241 45358 233 21549 237 45358 224 21549 244 21549 115 21549 253 45358 223 21549 253 21549 95 98629 227 76460 223 949 37046 101067 19000 23182 102301 9263 18136 16 36827 21909 56560 54337 19175 102118 13373 64571 34694 3114 112203 80112 3436 106451 14196 14196 74694 3089 3089 29249 17523 3001 27708 7801 358 3077 1027 364 83 820 568 596 1070 11 364 793 499 2771 30 364 44 539 2771 358 3358 1304 433 11 364 35 499 1093 1063 15600 30 1226 6 43712 264 64966 43
44-
101798

0 commit comments

Comments
 (0)