Building an LLM Inference Engine from Scratch: Tokenization Pipeline Notes A developer building an LLM inference engine from scratch detailed the tokenization pipeline, which converts raw text into token IDs through normalization, regex pre-tokenization, byte-to-Unicode mapping, and BPE merging. The implementation, using C++ and nlohmann::json, parses Hugging Face tokenizer files and applies iterative merge rules before vocabulary lookup. The project is available on GitHub. The development of an LLM inference engine starts from understanding and implementing the tokenizer. Before the model can perform any computation, raw text input must be converted into numerical token IDs that correspond to entries in the model vocabulary. The first step was to load the tokenizer files downloaded from Hugging Face. The tokenizer configuration contains several important components: vocab.json : Maps token strings to integer token IDs. merges.txt or equivalent JSON structure : Defines the Byte Pair Encoding BPE merge priority. tokenizer.json : Defines how raw text is initially split into smaller components.Using the nlohmann::json library in C++, the vocabulary and merge dictionaries were parsed into native C++ data structures for efficient lookup. Example structures: std::unordered map