eval.cost_estimator¶
chunktuner.eval.cost_estimator
¶
Dry-run cost and runtime estimates (no API calls).
CostEstimator
¶
Heuristic token counts and USD estimates without calling embedding or LLM APIs.
encoding_name is the tiktoken encoding used to count document tokens (the workspace
tokenizer_encoding; default cl100k_base).
Source code in src/chunktuner/eval/cost_estimator.py
estimate
¶
estimate(
docs,
strategies,
param_grid,
embedding_model,
*,
generate_dataset=True,
avg_chunks_per_doc=3.0,
llm_tokens_per_query=400,
llm_model=None,
questions_per_doc=3,
max_queries=50,
)
Heuristic token counts × strategy configs; USD from litellm when available.
When generate_dataset is True and llm_model is given, the LLM line is computed
by estimate_dataset_generation (same sampling as DatasetBuilder.build_from_docs)
and llm_model / llm_dataset_tokens are filled in; otherwise the legacy
per-query heuristic is used and those fields stay None.
Source code in src/chunktuner/eval/cost_estimator.py
estimate_dataset_generation
¶
estimate_dataset_generation(
docs,
llm_model,
*,
questions_per_doc=3,
max_queries=50,
encoding_name="cl100k_base",
)
Return (llm_tokens, usd) for LLM eval-dataset generation (no API calls).
Uses the same doc budget as DatasetBuilder.build_from_docs
(max_queries // questions_per_doc docs, one completion each). Pricing comes from
litellm's model table when known, else a flat $0.15 / 1M tokens.