@@ -656,6 +656,22 @@ def llama_tokenize(
656
656
_lib .llama_tokenize .restype = c_int
657
657
658
658
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
+
659
675
# LLAMA_API int llama_n_vocab(const struct llama_context * ctx);
660
676
def llama_n_vocab (ctx : llama_context_p ) -> int :
661
677
return _lib .llama_n_vocab (ctx )
@@ -683,6 +699,33 @@ def llama_n_embd(ctx: llama_context_p) -> int:
683
699
_lib .llama_n_embd .restype = c_int
684
700
685
701
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
+
686
729
# // Get the vocabulary as output parameters.
687
730
# // Returns number of results.
688
731
# LLAMA_API int llama_get_vocab(
@@ -703,6 +746,20 @@ def llama_get_vocab(
703
746
_lib .llama_get_vocab .restype = c_int
704
747
705
748
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
+
706
763
# Token logits obtained from the last call to llama_eval()
707
764
# The logits for the last token are stored in the last row
708
765
# Can be mutated in order to change the probabilities of the next token
@@ -732,15 +789,28 @@ def llama_get_embeddings(
732
789
_lib .llama_get_embeddings .restype = c_float_p
733
790
734
791
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);
737
796
def llama_token_to_str (ctx : llama_context_p , token : llama_token ) -> bytes :
738
797
return _lib .llama_token_to_str (ctx , token )
739
798
740
799
741
800
_lib .llama_token_to_str .argtypes = [llama_context_p , llama_token ]
742
801
_lib .llama_token_to_str .restype = c_char_p
743
802
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
+
744
814
# Special tokens
745
815
746
816
0 commit comments