mirror of
https://github.com/ollama/ollama.git
synced 2025-05-11 02:16:36 +02:00
llama: update vendored code to commit 40c6d79f (#7875)
This commit is contained in:
parent
a37f4a86a7
commit
527cc97899
289 changed files with 58552 additions and 41806 deletions
44
llama/sampling_ext.cpp
vendored
44
llama/sampling_ext.cpp
vendored
|
@ -3,16 +3,12 @@
|
|||
#include "sampling_ext.h"
|
||||
#include "json-schema-to-grammar.h"
|
||||
|
||||
struct gpt_sampler *gpt_sampler_cinit(
|
||||
const struct llama_model *model, struct gpt_sampler_cparams *params)
|
||||
{
|
||||
try
|
||||
{
|
||||
gpt_sampler_params sparams;
|
||||
struct common_sampler *common_sampler_cinit(const struct llama_model *model, struct common_sampler_cparams *params) {
|
||||
try {
|
||||
common_params_sampling sparams;
|
||||
sparams.top_k = params->top_k;
|
||||
sparams.top_p = params->top_p;
|
||||
sparams.min_p = params->min_p;
|
||||
sparams.tfs_z = params->tfs_z;
|
||||
sparams.typ_p = params->typical_p;
|
||||
sparams.temp = params->temp;
|
||||
sparams.penalty_last_n = params->penalty_last_n;
|
||||
|
@ -25,38 +21,28 @@ struct gpt_sampler *gpt_sampler_cinit(
|
|||
sparams.penalize_nl = params->penalize_nl;
|
||||
sparams.seed = params->seed;
|
||||
sparams.grammar = params->grammar;
|
||||
return gpt_sampler_init(model, sparams);
|
||||
}
|
||||
catch (const std::exception &err)
|
||||
{
|
||||
sparams.xtc_probability = 0.0;
|
||||
sparams.xtc_threshold = 0.5;
|
||||
return common_sampler_init(model, sparams);
|
||||
} catch (const std::exception &err) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void gpt_sampler_cfree(struct gpt_sampler *sampler)
|
||||
{
|
||||
gpt_sampler_free(sampler);
|
||||
void common_sampler_cfree(struct common_sampler *sampler) {
|
||||
common_sampler_free(sampler);
|
||||
}
|
||||
|
||||
void gpt_sampler_creset(struct gpt_sampler *sampler)
|
||||
{
|
||||
gpt_sampler_reset(sampler);
|
||||
void common_sampler_creset(struct common_sampler *sampler) {
|
||||
common_sampler_reset(sampler);
|
||||
}
|
||||
|
||||
llama_token gpt_sampler_csample(
|
||||
struct gpt_sampler *sampler,
|
||||
struct llama_context *ctx_main,
|
||||
int idx)
|
||||
{
|
||||
return gpt_sampler_sample(sampler, ctx_main, idx);
|
||||
void common_sampler_caccept(struct common_sampler *sampler, llama_token id, bool apply_grammar) {
|
||||
common_sampler_accept(sampler, id, apply_grammar);
|
||||
}
|
||||
|
||||
void gpt_sampler_caccept(
|
||||
struct gpt_sampler *sampler,
|
||||
llama_token id,
|
||||
bool apply_grammar)
|
||||
{
|
||||
gpt_sampler_accept(sampler, id, apply_grammar);
|
||||
llama_token common_sampler_csample(struct common_sampler *sampler, struct llama_context *ctx, int idx) {
|
||||
return common_sampler_sample(sampler, ctx, idx);
|
||||
}
|
||||
|
||||
int schema_to_grammar(const char *json_schema, char *grammar, size_t max_len)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue