Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <map>
#include <string>
#include <vector>
#include <unordered_set>

// determine number of model parts based on the dimension
static const std::map<int, int> LLAMA_N_PARTS = {
Expand Down Expand Up @@ -123,6 +124,9 @@ bool llama_model_load(const std::string & fname, llama_model & model, gpt_vocab
}

// load vocab

std::unordered_set<std::string> unprintable_characters = {"", "�", "��"};

{
const int32_t n_vocab = model.hparams.n_vocab;

Expand All @@ -140,6 +144,10 @@ bool llama_model_load(const std::string & fname, llama_model & model, gpt_vocab
word.resize(len);
fin.read((char *) word.data(), len);

if(unprintable_characters.find(word) != unprintable_characters.end()) {
continue;
}

vocab.token_to_id[word] = i;
vocab.id_to_token[i] = word;

Expand Down