Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e7795f6
last_gentxt_size -> last_gentxt_len
dungquixote42 Jun 2, 2026
8c2b697
reorg and delete unused member
dungquixote42 Jun 6, 2026
cddda17
handle rewind, simplify logic
dungquixote42 Jun 7, 2026
e3b4a52
update rewind_context() to loop over all rewinded tokens
dungquixote42 Jun 7, 2026
281f69c
add special rewind case: idx=0
dungquixote42 Jun 8, 2026
2421f37
restore rewind_context() logic
dungquixote42 Jun 8, 2026
89a1b09
Merge branch 'main' into fix-expiring_bias-0
dungquixote42 Jun 8, 2026
8fb0efd
Merge branch 'main' into fix-expiring_bias-0
dungquixote42 Jun 10, 2026
757db7d
simplify logic
dungquixote42 Jun 12, 2026
646cebf
add flag for marking end of prompt processing
dungquixote42 Jun 12, 2026
9504a4a
Merge branch 'main' into fix-expiring_bias-0
dungquixote42 Jun 13, 2026
c89b09a
revert some cosmetic changes
dungquixote42 Jun 14, 2026
0c22838
sampling: add ELB rewind support and optimize sampler text handling
dungquixote42 Jun 16, 2026
86a965b
cleanup
dungquixote42 Jun 16, 2026
86aca2c
Merge branch 'main' into fix-expiring_bias-0
dungquixote42 Jun 16, 2026
47f14d6
fix: correct expiring logit bias search logic and server prompt inges…
dungquixote42 Jun 17, 2026
507927e
cleanup
dungquixote42 Jun 17, 2026
7a7617d
compatibility patch speculative decoding and string ban
dungquixote42 Jun 18, 2026
7d8ddb8
minor
dungquixote42 Jun 19, 2026
63039c6
Merge branch 'main' into fix-expiring_bias-0
dungquixote42 Jun 19, 2026
0b71102
fix keyword search
dungquixote42 Jun 20, 2026
a36f23f
move search position to include next token
dungquixote42 Jun 21, 2026
e59ffb1
Merge branch 'main' into fix-expiring_bias-0
dungquixote42 Jun 24, 2026
4e82d83
fix underflow
dungquixote42 Jun 25, 2026
aebc870
Merge branch 'main' into fix-expiring_bias-0
dungquixote42 Jun 25, 2026
785da68
Merge branch 'main' into fix-expiring_bias-0
dungquixote42 Jun 27, 2026
6922a70
Merge branch 'main' into fix-expiring_bias-0
dungquixote42 Jun 29, 2026
478aa7e
Merge branch 'main' into fix-expiring_bias-0
dungquixote42 Jul 6, 2026
b514513
Merge branch 'main' into fix-expiring_bias-0
dungquixote42 Jul 14, 2026
613f93f
Merge branch 'main' into fix-expiring_bias-0
dungquixote42 Jul 15, 2026
75593db
Merge branch 'main' into fix-expiring_bias-0
dungquixote42 Jul 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions common/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3770,6 +3770,15 @@ bool string_is_found(const std::string& window, const std::string& str, size_t&
return pos != std::string::npos;
}

void string_assign_append(std::string& dst, const std::string_view& sv, const std::string& str, const int32_t pos) {
const int32_t margin = SSIZE(sv) - pos;
if (margin > 0) {
dst.assign(sv, pos).append(str);
} else {
dst.assign(str, -margin);
}
}

//
// Filesystem utils
//
Expand Down Expand Up @@ -5473,7 +5482,7 @@ void argparse_expiring_logit_bias(const std::string& content, common_params_samp
static const std::vector<std::string> names = { X_COMMON_PARAMS_SAMPLING };

std::vector<float> addsubs(names.size(), 0.0f);
bool is_sb = false;
bool is_epb = false;

// (... : SPARAM ...)
const auto window = line.substr(last_qq_pos + 1);
Expand All @@ -5489,26 +5498,27 @@ void argparse_expiring_logit_bias(const std::string& content, common_params_samp
auto sub = string_strip(window.substr(pos, next_pos - pos));
if (sub[0] == '~') {
addsubs[j] += std::stof(sub.substr(1));
is_sb = true;
is_epb = true;
LLAMA_LOG_DEBUG("%s: line %zu: bias = %f\n", __func__, i, addsubs[j]);
}
}
}

auto& phrases = extracts;
if (phrases.empty()) {
if (is_sb) {
if (is_epb) {
phrases.push_back("");
} else {
continue; // next line
}
}

int32_t max_keyword_len = 0;
const auto n_phrase = phrases.size();
std::vector<float> biases;
bool is_range = false;

if (!is_sb) {
if (!is_epb) {
// (... : BIAS ...)
const auto cln_rpos = line.rfind(':');
auto sub = line.substr(cln_rpos + 1, n_char - cln_rpos - 2);
Expand All @@ -5532,20 +5542,19 @@ void argparse_expiring_logit_bias(const std::string& content, common_params_samp
if (biases.empty()) {
continue; // next line
}
} else {
for (const auto& keyword: phrases) {
LLAMA_LOG_DEBUG("%s: line %zu: keyword = \"%s\"\n", __func__, i, keyword.c_str());
max_keyword_len = std::max(SSIZE(keyword), max_keyword_len);
}
LLAMA_LOG_DEBUG("%s: line %zu: max_keyword_len = %d\n", __func__, i, max_keyword_len);
}

size_t max_phrase_len = 0;
for (const auto& phrase: phrases) {
LLAMA_LOG_DEBUG("%s: line %zu: phrase = \"%s\"\n", __func__, i, phrase.c_str());
max_phrase_len = std::max(phrase.length(), max_phrase_len);
}
LLAMA_LOG_DEBUG("%s: line %zu: max_phrase_len = %zu\n", __func__, i, max_phrase_len);

common_params_sampling::elb_param::elb_entry entry = {
std::vector<size_t>(n_phrase, 0),
max_keyword_len,
std::vector<int32_t>(n_phrase, 0),
std::move(addsubs),
std::vector<bool>(n_phrase, false),
max_phrase_len,
std::move(phrases),
std::move(biases),
duration,
Expand Down
2 changes: 2 additions & 0 deletions common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@ std::vector<std::string> string_extract(const std::string& str, const char c, st

bool string_is_found(const std::string& window, const std::string& str, size_t& pos);

void string_assign_append(std::string& dst, const std::string_view& sv, const std::string& str, const int32_t pos);

//
// Filesystem utils
//
Expand Down
Loading