#include "tokenizer.hpp" #include #include #include int main(void) { static constexpr const char* filepath = "./gpt/shakespeare.txt"; std::ifstream file(filepath, std::ios::binary); if (!file.is_open()) return 1; std::string contents((std::istreambuf_iterator(file)), std::istreambuf_iterator()); file.close(); tokenizer<2256> bpe; bpe.train(contents); bpe.dump("./gpt/shakespeare.bpe"); auto tokens = bpe.encode("Hello, World!"); for (auto tok : tokens) { std::printf("0x%08X: ", tok); // NOLINT std::cout << bpe.token_text(tok) << '\n'; } std::cout << bpe.decode(tokens) << '\n'; return 0; }