mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-10-13 00:10:37 +02:00
vocab : implement PLaMo-3 tokenizer pre-segmentation (#30045)
* vocab : implement PLaMo-3 tokenizer pre-segmentation The PLaMo-3 tokenizer inserts hard boundaries before running the Unigram DP, around <|plamo:...|>-looking text, and around runs of at least 4 identical characters or 2 spaces. Without them llama.cpp tokenizes code indentation and repeated punctuation differently from the reference. Reproduce the two re.sub() passes in llm_tokenizer_plamo2 by encoding each segment independently. * add vocab type "plamo3" * Update src/llama-vocab.cpp Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@huggingface.co> * misc change --------- Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@huggingface.co>
This commit is contained in:
co-authored by
Sigbjørn Skjæret
parent
4625240437
commit
abeada335e
+9
-1
@@ -2511,6 +2511,14 @@ class TextModel(ModelBase):
|
||||
with open(tokenizer_config_path, "r", encoding="utf-8") as f:
|
||||
tokenizer_config = json.load(f)
|
||||
|
||||
tokenizer_class = tokenizer_config.get("tokenizer_class")
|
||||
if tokenizer_class == "Plamo2Tokenizer":
|
||||
tokenizer_model = "plamo2"
|
||||
elif tokenizer_class == "Plamo3Tokenizer":
|
||||
tokenizer_model = "plamo3"
|
||||
else:
|
||||
raise ValueError(f"Unsupported PLaMo tokenizer class: {tokenizer_class}")
|
||||
|
||||
# Load tokens from JSONL file (actually a list format)
|
||||
tokens = []
|
||||
scores = []
|
||||
@@ -2550,7 +2558,7 @@ class TextModel(ModelBase):
|
||||
scores.append(-1000.0)
|
||||
toktypes.append(gguf.TokenType.UNUSED)
|
||||
|
||||
self.gguf_writer.add_tokenizer_model("plamo2")
|
||||
self.gguf_writer.add_tokenizer_model(tokenizer_model)
|
||||
self.gguf_writer.add_tokenizer_pre("default")
|
||||
self.gguf_writer.add_token_list(tokens)
|
||||
self.gguf_writer.add_token_scores(scores)
|
||||
|
||||
Reference in New Issue
Block a user