summaryrefslogtreecommitdiff
path: root/llama.cpp
diff options
context:
space:
mode:
authorgoerch <jhr.walter@t-online.de>2023-09-16 13:41:33 +0200
committerGitHub <noreply@github.com>2023-09-16 13:41:33 +0200
commitb08e75baea294e366628b898e85c0bd359b58115 (patch)
tree417a1a8e7589567ceedba88771056aee080c8e70 /llama.cpp
parente6616cf0db2b63189fc34d0076f654af9adecdf8 (diff)
Fixing the last deviations from sentencepiece indicated by test-tokenizer-1 (#3170)
* Fix für #2721 * Reenable tokenizer test for LLaMa * Add `console.cpp` dependency * Fix dependency to `common` * Fixing wrong fix. * Make console usage platform specific Work on compiler warnings. * Adapting makefile * Remove trailing whitespace * Adapting the other parts of the makefile * Fix typo. * Fixing the last deviations from sentencepiece indicated by test-tokenizer-1 * Simplify logic * Add missing change... * Fix ugly compiler warning * llama_tokenize should accept strings containing NUL now * Adding huichen's test case
Diffstat (limited to 'llama.cpp')
-rw-r--r--llama.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llama.cpp b/llama.cpp
index a6502612..0b334b4e 100644
--- a/llama.cpp
+++ b/llama.cpp
@@ -7032,19 +7032,21 @@ llama_token llama_token_nl(const struct llama_context * ctx) {
int llama_tokenize(
struct llama_context * ctx,
const char * text,
+ int text_len,
llama_token * tokens,
int n_max_tokens,
bool add_bos) {
- return llama_tokenize_with_model(&ctx->model, text, tokens, n_max_tokens, add_bos);
+ return llama_tokenize_with_model(&ctx->model, text, text_len, tokens, n_max_tokens, add_bos);
}
int llama_tokenize_with_model(
const struct llama_model * model,
const char * text,
+ int text_len,
llama_token * tokens,
int n_max_tokens,
bool add_bos) {
- auto res = llama_tokenize_internal(model->vocab, text, add_bos);
+ auto res = llama_tokenize_internal(model->vocab, std::string(text, text_len), add_bos);
if (n_max_tokens < (int) res.size()) {
// LLAMA_LOG_ERROR("%s: too many tokens\n", __func__);