random choice

This commit is contained in:
JohannesGaessler 2024-02-07 18:55:37 +01:00
parent 617ae42dd4
commit 51b7317a65

View file

@ -3,6 +3,7 @@
#include <cmath> #include <cmath>
#include <cstdio> #include <cstdio>
#include <stdlib.h>
#include <string> #include <string>
#include <vector> #include <vector>
@ -160,35 +161,11 @@ int main(int argc, char ** argv){
// generate n_pred tokens through prompt lookup // generate n_pred tokens through prompt lookup
auto prompt_lookup = [&]() -> void { auto prompt_lookup = [&]() -> void {
int inp_size = inp.size(); for (int i = 0; i < n_draft; ++i) {
for (int ngram_size = ngram_max ; ngram_size > ngram_min; --ngram_size){ draft.push_back(rand() % 32000);
const llama_token * ngram = &inp[inp_size - ngram_size];
for (int i = 0; i <= (int) inp_size - (ngram_size * 2); ++i) {
bool match = true;
for (int j = 0; j < ngram_size; ++j) {
if (inp[i + j] != ngram[j]) {
match = false;
break;
}
}
if (match) {
const int startIdx = i + ngram_size;
const int endIdx = startIdx + n_draft;
if (endIdx < inp_size) {
for (int j = startIdx; j < endIdx; ++j) {
LOG(" - draft candidate %d: %d\n", j, inp[j]);
draft.push_back(inp[j]);
llama_batch_add(batch_tgt, inp[j], n_past + (j - startIdx) + 1, { 0 }, true);
++n_drafted; ++n_drafted;
} }
return; return;
}
}
}
}
return;
}; };
prompt_lookup(); prompt_lookup();