8000 Update llama.cpp · trannhan/llama-cpp-python@e6c67c8 · GitHub
[go: up one dir, main page]

Skip to content

Commit e6c67c8

Browse files
committed
Update llama.cpp
1 parent 82b11c8 commit e6c67c8

File tree

2 files changed

+73
-3
lines changed

2 files changed

+73
-3
lines changed

llama_cpp/llama_cpp.py

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,22 @@ def llama_tokenize(
656656
_lib.llama_tokenize.restype = c_int
657657

658658

659+
# LLAMA_API int llama_tokenize_with_model(
660+
# const struct llama_model * model,
661+
# const char * text,
662+
# llama_token * tokens,
663+
# int n_max_tokens,
664+
# bool add_bos);
665+
def llama_tokenize_with_model(
666+
model: llama_model_p,
667+
text: bytes,
668+
tokens, # type: Array[llama_token]
669+
n_max_tokens: c_int,
670+
add_bos: c_bool,
671+
) -> int:
672+
return _lib.llama_tokenize_with_model(model, text, tokens, n_max_tokens, add_bos)
673+
674+
659675
# LLAMA_API int llama_n_vocab(const struct llama_context * ctx);
660676
def llama_n_vocab(ctx: llama_context_p) -> int:
661677
return _lib.llama_n_vocab(ctx)
@@ -683,6 +699,33 @@ def llama_n_embd(ctx: llama_context_p) -> int:
683699
_lib.llama_n_embd.restype = c_int
684700

685701

702+
# LLAMA_API int llama_n_vocab_from_model(const struct llama_model * model);
703+
def llama_n_vocab_from_model(model: llama_model_p) -> int:
704+
return _lib.llama_n_vocab_from_model(model)
705+
706+
707+
_lib.llama_n_vocab_from_model.argtypes = [llama_model_p]
708+
_lib.llama_n_vocab_from_model.restype = c_int
709+
710+
711+
# LLAMA_API int llama_n_ctx_from_model (const struct llama_model * model);
712+
def llama_n_ctx_from_model(model: llama_model_p) -> int:
713+
return _lib.llama_n_ctx_from_model(model)
714+
715+
716+
_lib.llama_n_ctx_from_model.argtypes = [llama_model_p]
717+
_lib.llama_n_ctx_from_model.restype = c_int
718+
719+
720+
# LLAMA_API int llama_n_embd_from_model (const struct llama_model * model);
721+
def llama_n_embd_from_model(model: llama_model_p) -> int:
722+
return _lib.llama_n_embd_from_model(model)
723+
724+
725+
_lib.llama_n_embd_from_model.argtypes = [llama_model_p]
726+
_lib.llama_n_embd_from_model.restype = c_int
727+
728+
686729
# // Get the vocabulary as output parameters.
687730
# // Returns number of results.
688731
# LLAMA_API int llama_get_vocab(
@@ -703,6 +746,20 @@ def llama_get_vocab(
703746
_lib.llama_get_vocab.restype = c_int
704747

705748

749+
# LLAMA_API int llama_get_vocab_from_model(
750+
# const struct llama_model * model,
751+
# const char * * strings,
752+
# float * scores,
753+
# int capacity);
754+
def llama_get_vocab_from_model(
755+
model: llama_model_p,
756+
strings, # type: Array[c_char_p] # type: ignore
757+
scores, # type: Array[c_float] # type: ignore
758+
capacity: c_int,
759+
) -> int:
760+
return _lib.llama_get_vocab_from_model(model, strings, scores, capacity)
761+
762+
706763
# Token logits obtained from the last call to llama_eval()
707764
# The logits for the last token are stored in the last row
708765
# Can be mutated in order to change the probabilities of the next token
@@ -732,15 +789,28 @@ def llama_get_embeddings(
732789
_lib.llama_get_embeddings.restype = c_float_p
733790

734791

735-
# Token Id -> String. Uses the vocabulary in the provided context
736-
# LLAMA_API const char * llama_token_to_str(const struct llama_context * ctx, llama_token token);
792+
# // Token Id -> String. Uses the vocabulary in the provided context
793+
# LLAMA_API const char * llama_token_to_str(
794+
# const struct llama_context * ctx,
795+
# llama_token token);
737796
def llama_token_to_str(ctx: llama_context_p, token: llama_token) -> bytes:
738797
return _lib.llama_token_to_str(ctx, token)
739798

740799

741800
_lib.llama_token_to_str.argtypes = [llama_context_p, llama_token]
742801
_lib.llama_token_to_str.restype = c_char_p
743802

803+
804+
# LLAMA_API const char * llama_token_to_str_with_model(
805+
# const struct llama_model * model,
806+
# llama_token token);
807+
def llama_token_to_str_with_model(model: llama_model_p, token: llama_token) -> bytes:
808+
return _lib.llama_token_to_str_with_model(model, token)
809+
810+
811+
_lib.llama_token_to_str_with_model.argtypes = [llama_model_p, llama_token]
812+
_lib.llama_token_to_str_with_model.restype = c_char_p
813+
744814
# Special tokens
745815

746816

vendor/llama.cpp

0 commit comments

Comments
 (0)
0