Register or inspect the active tokenizer
See also
hr_tokenizer(), hr_count_tokens(), hr_budget()
Other cost and token functions:
hr_budget(),
hr_context_fit(),
hr_context_policy(),
hr_count_tokens(),
hr_estimate_cost(),
hr_load_models(),
hr_model_info(),
hr_model_limits(),
hr_models(),
hr_register_model(),
hr_tokenizer(),
hr_truncate(),
hr_truncate_tokens()
Examples
old <- hr_tokenizer()
hr_set_tokenizer("heuristic")
hr_count_tokens("the quick brown fox")
#> [1] 8
# Register your own; budgets recompute against it immediately.
hr_set_tokenizer("naive_words",
function(x) lengths(strsplit(trimws(x), "\\s+")))
hr_count_tokens("the quick brown fox")
#> [1] 4
hr_set_tokenizer(old)