File tree 3 files changed +11
-6
lines changed
3 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -37,11 +37,18 @@ struct llama_ngram {
37
37
}
38
38
};
39
39
40
+ struct llama_token_hash_function {
41
+ size_t operator ()(const llama_token token) const {
42
+ // see https://probablydance.com/2018/06/16/fibonacci-hashing-the-optimization-that-the-world-forgot-or-a-better-alternative-to-integer-modulo/
43
+ return token * 11400714819323198485llu;
44
+ }
45
+ };
46
+
40
47
struct llama_ngram_hash_function {
41
48
size_t operator ()(const llama_ngram & ngram) const {
42
- size_t hash = 0 ;
43
- for (int i = 0 ; i < LLAMA_NGRAM_MAX; ++i) {
44
- hash ^= std::hash<llama_token> {}(ngram.tokens [i]);
49
+ size_t hash = llama_token_hash_function{}(ngram. tokens [ 0 ]) ;
50
+ for (int i = 1 ; i < LLAMA_NGRAM_MAX; ++i) {
51
+ hash ^= llama_token_hash_function {}(ngram.tokens [i]);
45
52
}
46
53
return hash;
47
54
}
Original file line number Diff line number Diff line change @@ -31,7 +31,6 @@ int main(int argc, char ** argv){
31
31
32
32
// load the model
33
33
std::tie (model, ctx) = llama_init_from_gpt_params (params);
34
- GGML_ASSERT (llama_n_vocab (model) < (1 << 16 ));
35
34
36
35
// tokenize the prompt
37
36
std::vector<llama_token> inp;
@@ -65,7 +64,7 @@ int main(int argc, char ** argv){
65
64
}
66
65
67
66
const int n_input = inp.size ();
68
- const int n_ctx = params. n_ctx ;
67
+ const int n_ctx = llama_n_ctx (ctx) ;
69
68
70
69
int n_drafted = 0 ;
71
70
int n_accept = 0 ;
Original file line number Diff line number Diff line change @@ -39,7 +39,6 @@ int main(int argc, char ** argv){
39
39
40
40
// load the model
41
41
std::tie (model, ctx) = llama_init_from_gpt_params (params);
42
- GGML_ASSERT (llama_n_vocab (model) < (1 << 16 ));
43
42
44
43
// tokenize the prompt
45
44
std::vector<llama_token> inp;
You can’t perform that action at this time.
0 commit comments