diff options
author | Galunid <karolek1231456@gmail.com> | 2023-10-24 09:17:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-24 09:17:17 +0200 |
commit | daab3d7f45832e10773c99f3484b0d5b14d86c0c (patch) | |
tree | 432092c5aec7c775ab6e33b968564bd0a1e4a187 /tests/test-tokenizer-1-bpe.cpp | |
parent | 469c9addef75893e6be12edda852d12e840bf064 (diff) |
Add more tokenizer tests (#3742)
* Add more tokenizer tests
* Add starcoder
* Update test vocab files
* Restrict bpe tokenizer tests to unicode planes
* Update comment
* Comment cosmetics
* Remove bloom vocab/test
Diffstat (limited to 'tests/test-tokenizer-1-bpe.cpp')
-rw-r--r-- | tests/test-tokenizer-1-bpe.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/tests/test-tokenizer-1-bpe.cpp b/tests/test-tokenizer-1-bpe.cpp index 85a59a14..386530f2 100644 --- a/tests/test-tokenizer-1-bpe.cpp +++ b/tests/test-tokenizer-1-bpe.cpp @@ -91,9 +91,19 @@ int main(int argc, char **argv) { } } } - // TODO: why doesn't this work for the full range of Unicodes? + // Restrict to assigned unicode planes // for (uint32_t cp = 0x10000; cp < 0x0010ffff; ++cp) { - for (uint32_t cp = 0x10000; cp < 0x00080000; ++cp) { + for (uint32_t cp = 0x10000; cp < 0x00040000; ++cp) { + std::string str = codepoint_to_utf8(cp); + std::vector<llama_token> tokens = llama_tokenize(ctx, str, false); + std::string check = llama_detokenize_bpe(ctx, tokens); + if (str != check) { + fprintf(stderr, "%s : error: codepoint %x detokenizes to '%s'(%zu) instead of '%s'(%zu)\n", + __func__, cp, check.c_str(), check.length(), str.c_str(), str.length()); + return 4; + } + } + for (uint32_t cp = 0x000e0000; cp < 0x0010ffff; ++cp) { std::string str = codepoint_to_utf8(cp); std::vector<llama_token> tokens = llama_tokenize(ctx, str, false); std::string check = llama_detokenize_bpe(ctx, tokens); @@ -103,7 +113,6 @@ int main(int argc, char **argv) { return 4; } } - llama_free_model(model); llama_free(ctx); |