Skip invalid token mixes

This commit is contained in:
Aleksandras Kostarevas 2024-05-16 12:18:13 -05:00
parent edbb92114f
commit e19de589f1

View File

@ -393,7 +393,8 @@ struct LanguageModelState {
// mix_f[0], mix_f[1], mix_f[2], mix_f[3], mix_f[4], mix_f[5], mix_f[6]); // mix_f[0], mix_f[1], mix_f[2], mix_f[3], mix_f[4], mix_f[5], mix_f[6]);
} else { } else {
for (auto &t: mix.mixes) { for (auto &t: mix.mixes) {
if (t.weight < EPS) break; if (t.weight < EPS) continue;
if (t.token < 0 || t.token >= (int)n_vocab) continue;
float *src = ((LlamaAdapter *) model->adapter)->embeddings.data() + float *src = ((LlamaAdapter *) model->adapter)->embeddings.data() +
(t.token * n_embd); (t.token * n_embd);