Skip to main content

count_passage_tokens

Function count_passage_tokens 

Source
pub fn count_passage_tokens(
    tokenizer: &Tokenizer,
    text: &str,
) -> Result<usize, AppError>
Expand description

Counts the tokens produced by encoding text with the passage prefix.

Prepends PASSAGE_PREFIX before tokenizing so the count reflects the actual number of tokens consumed by the embedding model.

ยงErrors

Returns Err when the tokenizer fails to encode the input.