Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
wsxiaoys committed Nov 29, 2023
1 parent c906db6 commit 4b8b603
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crates/llama-cpp-bindings/src/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ struct Request {
int find_ngram(const std::vector<llama_token> & ngram, size_t n_pred_tokens) {
const int max = static_cast<int>(tokens.size()) - ngram.size() - n_pred_tokens;
for (int i = 0; i < max; ++i) {
bool matched = std::mismatch(tokens.begin() + i, tokens.begin() + i + ngram.size(), ngram.begin()).second == ngram.end();
if (matched) {
const auto mismatch = std::mismatch(tokens.begin() + i, tokens.begin() + i + ngram.size(), ngram.begin());
if (mismatch.second == ngram.end()) {
// Matched
return i;
}
}
Expand Down

0 comments on commit 4b8b603

Please sign in to comment.