mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-05-19 16:31:59 +00:00
try don't trigger the magic if input is following the jinja template.exactly for thinking models (+1 squashed commits)
Squashed commits: [5542e81dc] try don't trigger the magic if input is following the jinja template.
This commit is contained in:
parent
0f1e1b7ae0
commit
a1fc912452
3 changed files with 18 additions and 1 deletions
|
|
@ -3858,14 +3858,18 @@ generation_outputs gpttype_generate(const generation_inputs inputs)
|
|||
const std::string channel_open = "<|channel>";
|
||||
const std::string channel_close = "<channel|>";
|
||||
const std::string channel_prefix = channel_open + channel_close;
|
||||
const std::string systhink = "<|think|>";
|
||||
|
||||
const std::string fullbody = addedmemory + kcpp_data->prompt;
|
||||
|
||||
const bool has_open = fullbody.find(channel_open) != std::string::npos;
|
||||
const bool has_close = fullbody.find(channel_close) != std::string::npos;
|
||||
const bool has_systhink = fullbody.find(systhink) != std::string::npos;
|
||||
const bool ends_with_turn = kcpp_string_ends_with(kcpp_rstrip(fullbody),"<|turn>model");
|
||||
const bool acceptable_jinja_exception = (ends_with_turn && has_systhink);
|
||||
|
||||
// If neither opening nor closing tag is present anywhere, prepend both
|
||||
if (!has_open && !has_close) {
|
||||
if (!has_open && !has_close && !acceptable_jinja_exception) {
|
||||
addedmemory = channel_prefix + addedmemory;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1076,4 +1076,14 @@ std::vector<ggml_backend_dev_t> kcpp_parse_device_list(const std::string & value
|
|||
devices.push_back(nullptr);
|
||||
}
|
||||
return devices;
|
||||
}
|
||||
|
||||
bool kcpp_string_ends_with(const std::string& str, const std::string& suffix) {
|
||||
return str.size() >= suffix.size() &&
|
||||
str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
|
||||
}
|
||||
|
||||
std::string kcpp_rstrip(const std::string& s) {
|
||||
size_t end = s.find_last_not_of(" \t\n\r\f\v");
|
||||
return (end == std::string::npos) ? "" : s.substr(0, end + 1);
|
||||
}
|
||||
|
|
@ -75,6 +75,9 @@ bool kcpp_decode_audio_to_f32_stereo_48k(const uint8_t * data, size_t data_size,
|
|||
|
||||
std::vector<ggml_backend_dev_t> kcpp_parse_device_list(const std::string & value);
|
||||
|
||||
bool kcpp_string_ends_with(const std::string& str, const std::string& suffix);
|
||||
std::string kcpp_rstrip(const std::string& s);
|
||||
|
||||
//duplcated and modified from llava_embd_batch
|
||||
struct kcpp_embd_batch {
|
||||
std::vector<llama_pos> pos;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue