| 87 | |
| 88 | |
| 89 | void LoadBPEFile(const std::string& filename, std::vector<VocabItem>& vocab) { |
| 90 | std::ifstream file(filename); |
| 91 | std::string line; |
| 92 | |
| 93 | while (std::getline(file, line)) { |
| 94 | if (line.empty()) continue; |
| 95 | |
| 96 | std::istringstream iss(line); |
| 97 | std::string base64_token; |
| 98 | int rank; |
| 99 | |
| 100 | if (iss >> base64_token >> rank) { |
| 101 | // Decode base64 to bytes |
| 102 | std::vector<unsigned char> token_bytes = base64_decode(base64_token); |
| 103 | |
| 104 | VocabItem item; |
| 105 | item.rank = rank; |
| 106 | item.token_bytes = token_bytes; |
| 107 | vocab.push_back(item); |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | void LoadTokenizer(const std::string& tokenizer_path, const std::string& bpe_path, Llama4Tokenizer& tokenizer) { |
| 113 | // hard code it for now. |
no test coverage detected