Skip to content

Commit 38e34c9

Browse files
committed
Update llama.cpp
1 parent 8d75016 commit 38e34c9

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

llama_cpp/llama.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ def tokenize(self, text: bytes, add_bos: bool = True) -> List[int]:
430430
n_tokens = llama_cpp.llama_tokenize_with_model(
431431
self.model,
432432
text,
433+
len(text),
433434
tokens,
434435
n_ctx,
435436
add_bos,
@@ -440,6 +441,7 @@ def tokenize(self, text: bytes, add_bos: bool = True) -> List[int]:
440441
n_tokens = llama_cpp.llama_tokenize_with_model(
441442
self.model,
442443
text,
444+
len(text),
443445
tokens,
444446
n_tokens,
445447
add_bos,

llama_cpp/llama_cpp.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -950,42 +950,47 @@ def llama_token_nl(ctx: llama_context_p) -> llama_token:
950950
# LLAMA_API int llama_tokenize(
951951
# struct llama_context * ctx,
952952
# const char * text,
953+
# int text_len,
953954
# llama_token * tokens,
954955
# int n_max_tokens,
955956
# bool add_bos);
956957
def llama_tokenize(
957958
ctx: llama_context_p,
958959
text: bytes,
960+
text_len: Union[c_int, int],
959961
tokens, # type: Array[llama_token]
960962
n_max_tokens: Union[c_int, int],
961963
add_bos: Union[c_bool, int],
962964
) -> int:
963-
return _lib.llama_tokenize(ctx, text, tokens, n_max_tokens, add_bos)
965+
return _lib.llama_tokenize(ctx, text, text_len, tokens, n_max_tokens, add_bos)
964966

965967

966-
_lib.llama_tokenize.argtypes = [llama_context_p, c_char_p, llama_token_p, c_int, c_bool]
968+
_lib.llama_tokenize.argtypes = [llama_context_p, c_char_p, c_int, llama_token_p, c_int, c_bool]
967969
_lib.llama_tokenize.restype = c_int
968970

969971

970972
# LLAMA_API int llama_tokenize_with_model(
971973
# const struct llama_model * model,
972974
# const char * text,
975+
# int text_len,
973976
# llama_token * tokens,
974977
# int n_max_tokens,
975978
# bool add_bos);
976979
def llama_tokenize_with_model(
977980
model: llama_model_p,
978981
text: bytes,
982+
text_len: Union[c_int, int],
979983
tokens, # type: Array[llama_token]
980984
n_max_tokens: Union[c_int, int],
981985
add_bos: Union[c_bool, bool],
982986
) -> int:
983-
return _lib.llama_tokenize_with_model(model, text, tokens, n_max_tokens, add_bos)
987+
return _lib.llama_tokenize_with_model(model, text, text_len, tokens, n_max_tokens, add_bos)
984988

985989

986990
_lib.llama_tokenize_with_model.argtypes = [
987991
llama_model_p,
988992
c_char_p,
993+
c_int,
989994
llama_token_p,
990995
c_int,
991996
c_bool,

vendor/llama.cpp

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy