mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2025-09-09 16:44:35 +00:00
traded my ink for a pen
This commit is contained in:
commit
0db4ae6237
25 changed files with 13853 additions and 12134 deletions
|
@ -216,7 +216,7 @@ static void TokenizeString(const std::string & str_to_tokenize, std::vector<int>
|
|||
output_tokens = ::common_tokenize(llama_ctx_v4, str_to_tokenize, add_bos, true);
|
||||
if(add_bos)
|
||||
{
|
||||
const llama_vocab * tmpvocab = llama_model_get_vocab(&(llama_ctx_v4->model));
|
||||
const llama_vocab * tmpvocab = llama_model_get_vocab(llama_get_model(llama_ctx_v4));
|
||||
llama_token bostoadd = llama_vocab_bos(tmpvocab);
|
||||
if(bostoadd != LLAMA_TOKEN_NULL) //if bos does not exist, do not add it
|
||||
{
|
||||
|
@ -249,7 +249,7 @@ static int GetEosID(FileFormat file_format, int32_t n_vocab)
|
|||
{
|
||||
if(file_format == FileFormat::GGUF_GENERIC)
|
||||
{
|
||||
const llama_vocab * tmpvocab = llama_model_get_vocab(&(llama_ctx_v4->model));
|
||||
const llama_vocab * tmpvocab = llama_model_get_vocab(llama_get_model(llama_ctx_v4));
|
||||
eosID = llama_vocab_eos(tmpvocab);
|
||||
}
|
||||
else if(file_format == FileFormat::GGJT_3)
|
||||
|
@ -301,7 +301,7 @@ static int GetEotID(FileFormat file_format)
|
|||
{
|
||||
if(file_format == FileFormat::GGUF_GENERIC)
|
||||
{
|
||||
const llama_vocab * tmpvocab = llama_model_get_vocab(&(llama_ctx_v4->model));
|
||||
const llama_vocab * tmpvocab = llama_model_get_vocab(llama_get_model(llama_ctx_v4));
|
||||
return llama_vocab_eot(tmpvocab);
|
||||
}
|
||||
return -1;
|
||||
|
@ -500,10 +500,10 @@ void ContextRewind(std::vector<int> &embd, std::vector<int> ¤t_context_tok
|
|||
|
||||
if (file_format == FileFormat::GGUF_GENERIC)
|
||||
{
|
||||
llama_kv_cache_seq_rm(llama_ctx_v4, 0, n_past, -1);
|
||||
llama_kv_self_seq_rm(llama_ctx_v4, 0, n_past, -1);
|
||||
if(draft_ctx)
|
||||
{
|
||||
llama_kv_cache_seq_rm(draft_ctx, 0, n_past, -1);
|
||||
llama_kv_self_seq_rm(draft_ctx, 0, n_past, -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1801,12 +1801,12 @@ void PurgeMissingTokens(llama_context * ctx, llama_context * draft_ctx, std::vec
|
|||
|
||||
//extract the unwanted tokens out from context and KV
|
||||
int diff = found - trimstart;
|
||||
llama_kv_cache_seq_rm(ctx, 0, trimstart, trimstart + diff);
|
||||
llama_kv_cache_seq_add(ctx, 0, trimstart + diff, -1, -diff);
|
||||
llama_kv_self_seq_rm(ctx, 0, trimstart, trimstart + diff);
|
||||
llama_kv_self_seq_add(ctx, 0, trimstart + diff, -1, -diff);
|
||||
if(draft_ctx)
|
||||
{
|
||||
llama_kv_cache_seq_rm(draft_ctx, 0, trimstart, trimstart + diff);
|
||||
llama_kv_cache_seq_add(draft_ctx, 0, trimstart + diff, -1, -diff);
|
||||
llama_kv_self_seq_rm(draft_ctx, 0, trimstart, trimstart + diff);
|
||||
llama_kv_self_seq_add(draft_ctx, 0, trimstart + diff, -1, -diff);
|
||||
}
|
||||
|
||||
for (size_t i = trimstart + diff; i < current_context_tokens.size() - 1; i++)
|
||||
|
@ -2298,7 +2298,7 @@ ModelLoadResult gpttype_load_model(const load_model_inputs inputs, FileFormat in
|
|||
|
||||
//determine mem per token
|
||||
std::vector<int> tmp = {1, 2, 3, 4};
|
||||
llama_kv_cache_clear(llama_ctx_v4);
|
||||
llama_kv_self_clear(llama_ctx_v4);
|
||||
auto er = llama_decode(llama_ctx_v4, llama_batch_get_one(tmp.data(), tmp.size()));
|
||||
if(er!=0)
|
||||
{
|
||||
|
@ -2696,13 +2696,13 @@ std::string gpttype_get_chat_template()
|
|||
// copied from examples/server/utils.hpp::llama_get_chat_template
|
||||
std::string template_key = "tokenizer.chat_template";
|
||||
// call with NULL buffer to get the total size of the string
|
||||
int32_t res = llama_model_meta_val_str(&llama_ctx_v4->model, template_key.c_str(), NULL, 0);
|
||||
int32_t res = llama_model_meta_val_str(llama_get_model(llama_ctx_v4), template_key.c_str(), NULL, 0);
|
||||
if (res < 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::vector<char> model_template(res + 1, 0);
|
||||
llama_model_meta_val_str(&llama_ctx_v4->model, template_key.c_str(), model_template.data(), model_template.size());
|
||||
llama_model_meta_val_str(llama_get_model(llama_ctx_v4), template_key.c_str(), model_template.data(), model_template.size());
|
||||
return std::string(model_template.data(), model_template.size() - 1);
|
||||
}
|
||||
|
||||
|
@ -2885,7 +2885,7 @@ generation_outputs gpttype_generate(const generation_inputs inputs)
|
|||
bool add_bos_token = true; //if set to false, mmproj handling breaks
|
||||
// if(file_format == FileFormat::GGUF_GENERIC && mmproj_filename == "")
|
||||
// {
|
||||
// const llama_vocab * tmpvocab = llama_model_get_vocab(&(llama_ctx_v4->model));
|
||||
// const llama_vocab * tmpvocab = llama_model_get_vocab(llama_get_model(llama_ctx_v4));
|
||||
// add_bos_token = llama_vocab_get_add_bos(tmpvocab);
|
||||
// if(!add_bos_token && debugmode==1)
|
||||
// {
|
||||
|
@ -3296,10 +3296,10 @@ generation_outputs gpttype_generate(const generation_inputs inputs)
|
|||
{
|
||||
if(n_past==0)
|
||||
{
|
||||
llama_kv_cache_clear(llama_ctx_v4);
|
||||
llama_kv_self_clear(llama_ctx_v4);
|
||||
if(draft_ctx)
|
||||
{
|
||||
llama_kv_cache_clear(draft_ctx);
|
||||
llama_kv_self_clear(draft_ctx);
|
||||
}
|
||||
}
|
||||
else if(embd_inp.size()==0)
|
||||
|
@ -3326,10 +3326,10 @@ generation_outputs gpttype_generate(const generation_inputs inputs)
|
|||
}
|
||||
if(file_format == FileFormat::GGUF_GENERIC)
|
||||
{
|
||||
llama_kv_cache_seq_rm(llama_ctx_v4, 0, n_past, -1);
|
||||
llama_kv_self_seq_rm(llama_ctx_v4, 0, n_past, -1);
|
||||
if(draft_ctx)
|
||||
{
|
||||
llama_kv_cache_seq_rm(draft_ctx, 0, n_past, -1);
|
||||
llama_kv_self_seq_rm(draft_ctx, 0, n_past, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3861,9 +3861,9 @@ generation_outputs gpttype_generate(const generation_inputs inputs)
|
|||
//if we have somehow skipped ahead (e.g drafting), ensure that all tokens after npast are purged
|
||||
if (file_format == FileFormat::GGUF_GENERIC && draft_used)
|
||||
{
|
||||
llama_kv_cache_seq_rm(llama_ctx_v4, 0, n_past, -1);
|
||||
llama_kv_self_seq_rm(llama_ctx_v4, 0, n_past, -1);
|
||||
if (draft_ctx) {
|
||||
llama_kv_cache_seq_rm(draft_ctx, 0, n_past, -1);
|
||||
llama_kv_self_seq_rm(draft_ctx, 0, n_past, -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue