str splitter

This commit is contained in:
Concedo
2025-04-14 23:05:36 +08:00
parent 6bc2ca4803
commit ad2522b319
2 changed files with 19 additions and 0 deletions
+17
View File
@@ -542,4 +542,21 @@ kcpp_embd_batch::kcpp_embd_batch(std::vector<llama_token> & tokens, int32_t npas
}
}
batch.logits[n_tokens - 1] = true;
}
std::vector<std::string> split_string(const std::string& input, const std::string& separator) {
std::vector<std::string> result;
size_t start = 0;
size_t end = input.find(separator);
while (end != std::string::npos) {
result.push_back(input.substr(start, end - start));
start = end + separator.length();
end = input.find(separator, start);
}
// Add the remaining part after the last separator
result.push_back(input.substr(start));
return result;
}
+2
View File
@@ -65,6 +65,8 @@ std::vector<float> resample_wav(const std::vector<float>& input, uint32_t input_
int32_t kcpp_quick_sample(float * logits, const int n_logits, const std::vector<int32_t> & last_n_tokens, float rep_pen, float top_p, int top_k, float temp, std::mt19937 & rng);
std::vector<std::string> split_string(const std::string& input, const std::string& separator);
struct kcpp_embd_batch { //duplcated from llava_embd_batch
std::vector<int32_t> pos;
std::vector<int32_t> n_seq_id;