summaryrefslogtreecommitdiff
path: root/convert-mpt-hf-to-gguf.py
diff options
context:
space:
mode:
authorGalunid <karolek1231456@gmail.com>2023-10-23 21:46:00 +0200
committerGitHub <noreply@github.com>2023-10-23 21:46:00 +0200
commit69a6735087c3634963c642fd69f0851ac479cd78 (patch)
treeb4a0a0037e1d748e1dbf531ab5c83da5fcd7bd2e /convert-mpt-hf-to-gguf.py
parent5be6c803fa5378f62a1590f3ad8c6b64c7c0c2ce (diff)
Update special token handling in conversion scripts for gpt2 derived tokenizers (#3746)
We still have the heads up in `README.md` regarding `bpe` tokenizers and this patch is needed for - a couple of tokenizer tests - some more `special` and `non-special` added tokens handling (as far as I understand it) * Update special token handling * Add mpt
Diffstat (limited to 'convert-mpt-hf-to-gguf.py')
-rwxr-xr-xconvert-mpt-hf-to-gguf.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/convert-mpt-hf-to-gguf.py b/convert-mpt-hf-to-gguf.py
index 2d2fa232..70d154b3 100755
--- a/convert-mpt-hf-to-gguf.py
+++ b/convert-mpt-hf-to-gguf.py
@@ -136,9 +136,11 @@ for i in range(vocab_size):
tokens.append(f"[PAD{i}]")
toktypes.append(gguf.TokenType.USER_DEFINED)
elif reverse_vocab[i] in added_vocab:
- # NOTE: wouldn't we like to distinguish CONTROL tokens here?
tokens.append(reverse_vocab[i])
- toktypes.append(gguf.TokenType.USER_DEFINED)
+ if tokenizer.added_tokens_decoder[i].special:
+ toktypes.append(gguf.TokenType.CONTROL)
+ else:
+ toktypes.append(gguf.TokenType.USER_DEFINED)
else:
tokens.append(reverse_vocab[i])
toktypes.append(gguf.TokenType.NORMAL)