Skip to main content
tokens counts the tokens in each row of a text column and returns a column of BIGINT counts. By default, tokens uses the same tokenizer as infer’s default models. To use another model’s tokenizer, pass a Hugging Face repository or a local tokenizer.json as the second argument.

Signature

Example

Return type

BIGINT, or null for a null input. tokens performs tokenization but avoids building the token string list returned by tokenize. Use it for budgets, filters, and aggregates. Special tokens are not added. Tokenizers load once per path into a process-scoped cache. See Count tokens in a dataset to count conversations, total tokens, and average input size across a hosted dataset.