Skip to main content

tokenizer

Function tokenizer 

Source
pub fn tokenizer() -> EconomicsTokenizer
Expand description

The tokenizer’s identity, as recorded with every count.

Two counts are comparable only when both the encoding and the implementation agree, so a run carries both: a change to either makes earlier records a different measurement, not a smaller or larger one.

use majordomus_cli::economics::context::{tokenizer, TOKENIZER_ENCODING};
let t = tokenizer();
assert_eq!(t.encoding, TOKENIZER_ENCODING);
assert_eq!(
    serde_json::to_value(&t).unwrap(),
    serde_json::json!({ "encoding": "o200k_base", "implementation": "tiktoken-rs 0.12.0" }),
);