Expand description
memra-tokenizer — host-only GPT-2/BPE tokenizer (encode + decode + chat template).
Algorithm TAKEn ~1:1 from llama.cpp’s GPT-2 BPE path (src/llama-vocab.cpp,
src/unicode.cpp), Rust glue hand-rolled. Built from the model’s own GGUF
tokenizer metadata (tokenizer.ggml.*) so it is integer-exact for that model.
Scope: the gpt2 vocab model with the qwen35/qwen2/deepseek-v3 pre-tokenizers, plus
the gemma4 SPM-style path — see SUPPORTED_PRETOKENIZERS. A model declaring anything else
is REFUSED at load (UnknownPretokenizer), because an unported pre-tokenizer produces
fluent output with wrong token ids and nothing downstream can see it.
Re-exports§
pub use chat::apply_chat_template_str;
Modules§
- chat
- Minimal chat-template renderer for the Qwen3.5 / ChatML format.
Structs§
- Tokenizer
- Unknown
Pretokenizer - A model declared a pre-tokenizer memra has no exact split for.
Enums§
- PreSplit
- The pre-tokenizer split a loaded
Tokenizerruns. Constructed only throughPreSplit::resolve, so “we do not know how to split for this model” is not a state a live tokenizer can be in unless the operator asked for it via the env opt-out.
Constants§
- ALLOW_
UNKNOWN_ PRETOKENIZER_ ENV - Escape hatch for deliberate experimentation with a family whose pre-tokenizer is not ported
yet. Set to
1to downgrade the hard load error to a loud per-load WARN. - SUPPORTED_
PRETOKENIZERS - Every
tokenizer.ggml.preid memra implements an EXACT split for. This is the allowlist a load is checked against and the list quoted in the load error, so the two can never drift.