@@ -1180,97 +1180,97 @@ def llama_get_embeddings(
11801180# //
11811181
11821182
1183- # LLAMA_API const char * llama_token_get_text(const struct llama_context * ctx , llama_token token);
1184- def llama_token_get_text (ctx : llama_context_p , token : llama_token ) -> bytes :
1185- return _lib .llama_token_get_text (ctx , token )
1183+ # LLAMA_API const char * llama_token_get_text(const struct llama_model * model , llama_token token);
1184+ def llama_token_get_text (model : llama_model_p , token : llama_token ) -> bytes :
1185+ return _lib .llama_token_get_text (model , token )
11861186
11871187
1188- _lib .llama_token_get_text .argtypes = [llama_context_p , llama_token ]
1188+ _lib .llama_token_get_text .argtypes = [llama_model_p , llama_token ]
11891189_lib .llama_token_get_text .restype = c_char_p
11901190
11911191
1192- # LLAMA_API float llama_token_get_score(const struct llama_context * ctx , llama_token token);
1193- def llama_token_get_score (ctx : llama_context_p , token : llama_token ) -> float :
1194- return _lib .llama_token_get_score (ctx , token )
1192+ # LLAMA_API float llama_token_get_score(const struct llama_model * model , llama_token token);
1193+ def llama_token_get_score (model : llama_model_p , token : llama_token ) -> float :
1194+ return _lib .llama_token_get_score (model , token )
11951195
11961196
1197- _lib .llama_token_get_score .argtypes = [llama_context_p , llama_token ]
1197+ _lib .llama_token_get_score .argtypes = [llama_model_p , llama_token ]
11981198_lib .llama_token_get_score .restype = c_float
11991199
12001200
1201- # LLAMA_API enum llama_token_type llama_token_get_type(const struct llama_context * ctx , llama_token token);
1202- def llama_token_get_type (ctx : llama_context_p , token : llama_token ) -> int :
1203- return _lib .llama_token_get_type (ctx , token )
1201+ # LLAMA_API enum llama_token_type llama_token_get_type(const struct llama_model * model , llama_token token);
1202+ def llama_token_get_type (model : llama_model_p , token : llama_token ) -> int :
1203+ return _lib .llama_token_get_type (model , token )
12041204
12051205
1206- _lib .llama_token_get_type .argtypes = [llama_context_p , llama_token ]
1206+ _lib .llama_token_get_type .argtypes = [llama_model_p , llama_token ]
12071207_lib .llama_token_get_type .restype = ctypes .c_int
12081208
12091209
12101210# // Special tokens
12111211
12121212
1213- # LLAMA_API llama_token llama_token_bos(const struct llama_context * ctx); // beginning-of-sentence
1214- def llama_token_bos (ctx : llama_context_p ) -> int :
1215- return _lib .llama_token_bos (ctx )
1213+ # LLAMA_API llama_token llama_token_bos(const struct llama_model * model); // beginning-of-sentence
1214+ def llama_token_bos (model : llama_model_p ) -> int :
1215+ return _lib .llama_token_bos (model )
12161216
12171217
1218- _lib .llama_token_bos .argtypes = [llama_context_p ]
1218+ _lib .llama_token_bos .argtypes = [llama_model_p ]
12191219_lib .llama_token_bos .restype = llama_token
12201220
12211221
1222- # LLAMA_API llama_token llama_token_eos(const struct llama_context * ctx); // end-of-sentence
1223- def llama_token_eos (ctx : llama_context_p ) -> int :
1224- return _lib .llama_token_eos (ctx )
1222+ # LLAMA_API llama_token llama_token_eos(const struct llama_model * model); // end-of-sentence
1223+ def llama_token_eos (model : llama_model_p ) -> int :
1224+ return _lib .llama_token_eos (model )
12251225
12261226
1227- _lib .llama_token_eos .argtypes = [llama_context_p ]
1227+ _lib .llama_token_eos .argtypes = [llama_model_p ]
12281228_lib .llama_token_eos .restype = llama_token
12291229
12301230
1231- # LLAMA_API llama_token llama_token_nl (const struct llama_context * ctx); // next-line
1232- def llama_token_nl (ctx : llama_context_p ) -> int :
1233- return _lib .llama_token_nl (ctx )
1231+ # LLAMA_API llama_token llama_token_nl (const struct llama_model * model); // next-line
1232+ def llama_token_nl (model : llama_model_p ) -> int :
1233+ return _lib .llama_token_nl (model )
12341234
12351235
1236- _lib .llama_token_nl .argtypes = [llama_context_p ]
1236+ _lib .llama_token_nl .argtypes = [llama_model_p ]
12371237_lib .llama_token_nl .restype = llama_token
12381238
12391239
12401240# // codellama infill tokens
1241- # LLAMA_API llama_token llama_token_prefix(const struct llama_context * ctx ); // Beginning of infill prefix
1242- def llama_token_prefix (ctx : llama_context_p ) -> int :
1243- return _lib .llama_token_prefix (ctx )
1241+ # LLAMA_API llama_token llama_token_prefix(const struct llama_model * model ); // Beginning of infill prefix
1242+ def llama_token_prefix (model : llama_model_p ) -> int :
1243+ return _lib .llama_token_prefix (model )
12441244
12451245
1246- _lib .llama_token_prefix .argtypes = [llama_context_p ]
1246+ _lib .llama_token_prefix .argtypes = [llama_model_p ]
12471247_lib .llama_token_prefix .restype = llama_token
12481248
12491249
1250- # LLAMA_API llama_token llama_token_middle(const struct llama_context * ctx ); // Beginning of infill middle
1251- def llama_token_middle (ctx : llama_context_p ) -> int :
1252- return _lib .llama_token_middle (ctx )
1250+ # LLAMA_API llama_token llama_token_middle(const struct llama_model * model ); // Beginning of infill middle
1251+ def llama_token_middle (model : llama_model_p ) -> int :
1252+ return _lib .llama_token_middle (model )
12531253
12541254
1255- _lib .llama_token_middle .argtypes = [llama_context_p ]
1255+ _lib .llama_token_middle .argtypes = [llama_model_p ]
12561256_lib .llama_token_middle .restype = llama_token
12571257
12581258
1259- # LLAMA_API llama_token llama_token_suffix(const struct llama_context * ctx ); // Beginning of infill suffix
1260- def llama_token_suffix (ctx : llama_context_p ) -> int :
1261- return _lib .llama_token_suffix (ctx )
1259+ # LLAMA_API llama_token llama_token_suffix(const struct llama_model * model ); // Beginning of infill suffix
1260+ def llama_token_suffix (model : llama_model_p ) -> int :
1261+ return _lib .llama_token_suffix (model )
12621262
12631263
1264- _lib .llama_token_suffix .argtypes = [llama_context_p ]
1264+ _lib .llama_token_suffix .argtypes = [llama_model_p ]
12651265_lib .llama_token_suffix .restype = llama_token
12661266
12671267
1268- # LLAMA_API llama_token llama_token_eot (const struct llama_context * ctx ); // End of infill middle
1269- def llama_token_eot (ctx : llama_context_p ) -> int :
1270- return _lib .llama_token_eot (ctx )
1268+ # LLAMA_API llama_token llama_token_eot (const struct llama_model * model ); // End of infill middle
1269+ def llama_token_eot (model : llama_model_p ) -> int :
1270+ return _lib .llama_token_eot (model )
12711271
12721272
1273- _lib .llama_token_eot .argtypes = [llama_context_p ]
1273+ _lib .llama_token_eot .argtypes = [llama_model_p ]
12741274_lib .llama_token_eot .restype = llama_token
12751275
12761276
@@ -1431,70 +1431,46 @@ def llama_set_rng_seed(ctx: llama_context_p, seed: Union[c_uint32, int]):
14311431_lib .llama_set_rng_seed .restype = None
14321432
14331433
1434- # @details Repetition penalty described in CTRL academic paper https://arxiv.org/abs/1909.05858, with negative logit fix.
1435- # LLAMA_API void llama_sample_repetition_penalty(
1434+ # /// @details Repetition penalty described in CTRL academic paper https://arxiv.org/abs/1909.05858, with negative logit fix.
1435+ # /// @details Frequency and presence penalties described in OpenAI API https://platform.openai.com/docs/api-reference/parameter-details.
1436+ # LLAMA_API void llama_sample_repetition_penalties(
14361437# struct llama_context * ctx,
14371438# llama_token_data_array * candidates,
14381439# const llama_token * last_tokens,
1439- # size_t last_tokens_size,
1440- # float penalty);
1441- def llama_sample_repetition_penalty (
1440+ # size_t penalty_last_n,
1441+ # float penalty_repeat,
1442+ # float penalty_freq,
1443+ # float penalty_present);
1444+ def llama_sample_repetition_penalties (
14421445 ctx : llama_context_p ,
14431446 candidates , # type: _Pointer[llama_token_data_array]
14441447 last_tokens_data , # type: Array[llama_token]
1445- last_tokens_size : Union [c_int , int ],
1446- penalty : Union [c_float , float ],
1448+ penalty_last_n : Union [c_size_t , int ],
1449+ penalty_repeat : Union [c_float , float ],
1450+ penalty_freq : Union [c_float , float ],
1451+ penalty_present : Union [c_float , float ],
14471452):
1448- return _lib .llama_sample_repetition_penalty (
1449- ctx , candidates , last_tokens_data , last_tokens_size , penalty
1450- )
1451-
1452-
1453- _lib .llama_sample_repetition_penalty .argtypes = [
1454- llama_context_p ,
1455- llama_token_data_array_p ,
1456- llama_token_p ,
1457- c_int ,
1458- c_float ,
1459- ]
1460- _lib .llama_sample_repetition_penalty .restype = None
1461-
1462-
1463- # @details Frequency and presence penalties described in OpenAI API https://platform.openai.com/docs/api-reference/parameter-details.
1464- # LLAMA_API void llama_sample_frequency_and_presence_penalties(
1465- # struct llama_context * ctx,
1466- # llama_token_data_array * candidates,
1467- # const llama_token * last_tokens,
1468- # size_t last_tokens_size,
1469- # float alpha_frequency,
1470- # float alpha_presence);
1471- def llama_sample_frequency_and_presence_penalties (
1472- ctx : llama_context_p ,
1473- candidates , # type: _Pointer[llama_token_data_array]
1474- last_tokens_data , # type: Array[llama_token]
1475- last_tokens_size : Union [c_int , int ],
1476- alpha_frequency : Union [c_float , float ],
1477- alpha_presence : Union [c_float , float ],
1478- ):
1479- return _lib .llama_sample_frequency_and_presence_penalties (
1453+ return _lib .llama_sample_repetition_penalties (
14801454 ctx ,
14811455 candidates ,
14821456 last_tokens_data ,
1483- last_tokens_size ,
1484- alpha_frequency ,
1485- alpha_presence ,
1457+ penalty_last_n ,
1458+ penalty_repeat ,
1459+ penalty_freq ,
1460+ penalty_present ,
14861461 )
14871462
14881463
1489- _lib .llama_sample_frequency_and_presence_penalties .argtypes = [
1464+ _lib .llama_sample_repetition_penalties .argtypes = [
14901465 llama_context_p ,
14911466 llama_token_data_array_p ,
14921467 llama_token_p ,
1493- c_int ,
1468+ c_size_t ,
1469+ c_float ,
14941470 c_float ,
14951471 c_float ,
14961472]
1497- _lib .llama_sample_frequency_and_presence_penalties .restype = None
1473+ _lib .llama_sample_repetition_penalties .restype = None
14981474
14991475
15001476# /// @details Apply classifier-free guidance to the logits as described in academic paper "Stay on topic with Classifier-Free Guidance" https://arxiv.org/abs/2306.17806
0 commit comments