> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chowder.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Count tokens in a dataset

> Count rows, total tokens, and average tokens per row directly from a Hugging Face dataset.

A row count tells you how many conversations you have. Token counts tell you how much text your inference workload needs to process. Query a Hugging Face dataset with SQL to measure both before running inference.

## Count conversations and tokens

This query reads the synthetic customer-service conversations in [`chowderai/cust-convo`](https://huggingface.co/datasets/chowderai/cust-convo) and profiles the `convo_transcript` column:

```chowder-sql theme={"theme":"css-variables","languages":{"custom":["/languages/chowder-sql.json"]}}
WITH conversations AS (
    SELECT tokens(convo_transcript) AS token_count -- Count tokens without building token arrays
    FROM read_parquet('hf://datasets/chowderai/cust-convo/data/*.parquet')
)
SELECT
    count(*) AS conversation_count,
    sum(token_count) AS total_tokens,
    round(avg(token_count), 2) AS avg_tokens_per_conversation
FROM conversations;
```

| conversation\_count | total\_tokens | avg\_tokens\_per\_conversation |
| - | - | - |
| 71314 | 245429518 | 3441.53 |

Across 71,314 conversations, that is about **245 million transcript tokens**—an average of **3,442 tokens per conversation**. A dataset with the same row count but longer conversations would have a larger input workload.

The query scans every conversation; there is no sampling or inference call. `tokens` runs the tokenizer locally without loading an inference model or requiring a GPU. The first use may download the tokenizer.

## Interpret the counts

* `conversation_count` counts every row, including rows with a null transcript.
* `total_tokens` sums the token counts for non-null transcripts.
* `avg_tokens_per_conversation` averages the non-null counts, rounded to two decimal places. Empty transcripts contribute zero; null transcripts do not contribute to the sum or average.

These counts use Chowder's default **`Qwen/Qwen3.5-0.8B` tokenizer**. Counts depend on the tokenizer: use the tokenizer for your intended model when comparing context limits or estimating input size. Pass a Hugging Face tokenizer repository or local `tokenizer.json` path as the second argument:

```chowder-sql theme={"theme":"css-variables","languages":{"custom":["/languages/chowder-sql.json"]}}
SELECT
    convo_id,
    tokens(convo_transcript, 'Qwen/Qwen3.5-0.8B') AS token_count
FROM read_parquet('hf://datasets/chowderai/cust-convo/data/*.parquet')
LIMIT 5;
```

The counts cover transcript text only. They exclude instructions, chat templates, special tokens, and generated output. Use them to size the input workload; actual inference time and cost also depend on the model, output length, batching, and hardware.

## Inspect how text splits

Use [`tokenize`](https://docs.chowder.ai/reference/column-functions/tokenize) to inspect token strings for a small sample. Use [`tokens`](https://docs.chowder.ai/reference/column-functions/tokens) for aggregate counts so you do not materialize token arrays for the whole dataset.

```chowder-sql theme={"theme":"css-variables","languages":{"custom":["/languages/chowder-sql.json"]}}
SELECT
    convo_id,
    tokenize(convo_transcript) AS token_strings
FROM read_parquet('hf://datasets/chowderai/cust-convo/data/*.parquet')
LIMIT 1;
```

Token strings may contain whitespace markers rather than readable words. A token is not necessarily a word.

For access and authentication, see [Hugging Face datasets](https://docs.chowder.ai/reference/sources/hugging-face-datasets.md). The dataset is licensed under CC BY-NC 4.0; its dataset card contains the usage terms.

## Try inference on a bounded batch

Use these counts to choose an initial batch, then classify or extract fields with [Chowder Cloud](https://docs.chowder.ai/cloud/quickstart.md). Inspect AI response quality and observed usage before expanding to the whole dataset. Token counts size the input; they are not a complete Cloud price estimate.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.