CLI reference¶
All commands are provided by the chunk-tune Typer app. Global patterns:
path: file or directory to ingest (must exist).--config: optional path to.autochunk.yaml(see Configuration).--output-format:table(default),json, oryamlwhere supported.
chunk-tune init¶
Create .autochunk.yaml in the current working directory. embedding_model is null by default — dummy embeddings are used (no API calls) until you set a model.
| Flag | Type | Default | Description |
|---|---|---|---|
-m, --model |
string | none | Embedding model id (LiteLLM). Any provider: text-embedding-3-small (OpenAI), gemini/gemini-embedding-001 (Google), openai/<id> for local servers. Omit to keep dummy embeddings. |
Fails with exit code 1 if .autochunk.yaml already exists.
chunk-tune analyze¶
Structural scan using tiktoken and heuristics — no embeddings, no external APIs.
| Argument / flag | Type | Default | Description |
|---|---|---|---|
path |
path | (required) | File or directory |
--content-type |
string | auto | Override detected type |
--output-format |
choice | table |
table, json, or yaml |
--config |
path | none | Workspace YAML |
path: README.md
sample_path: README.md
content_type: markdown
token_count: 412
...
heuristic_starting_strategy: recursive_character (~1600 chars)
heuristic_starting_strategy is chosen from the sampled text: many Markdown headers → markdown_semantic (when available); several fenced code blocks → code_ast (when available); otherwise recursive_character (~1600 chars).
For directories, the first .md / .txt file under the tree is sampled.
chunk-tune estimate¶
Dry-run token, cost, and wall-time estimates using CostEstimator — no API calls. Documents whose content type a selected strategy does not support (e.g. code with the default text strategies) are skipped with a warning naming the strategies that support them; if none remain, the command exits 1. Token counts use the workspace tokenizer_encoding.
| Flag | Type | Default | Description |
|---|---|---|---|
path |
path | (required) | File or directory |
--strategies |
string | fixed_tokens,recursive_character |
Comma-separated strategy names |
--use-case |
string | rag_qa |
Scoring profile label (for consistency with other commands) |
--max-docs |
int | 100 (or max_docs in YAML) |
Cap documents after ingest and unsupported-type filtering |
--config |
path | none | .autochunk.yaml |
--output-format |
choice | table |
table, json, or yaml |
--generate-dataset |
bool | false | Also estimate LLM eval-dataset generation (adds llm_model and llm_dataset_tokens; llm_cost_usd uses that model's pricing) |
--llm-model |
string | none | LLM to estimate for --generate-dataset; default is workspace llm_model |
--retrieval-mode |
choice | dense (or retrieval_mode in YAML) |
With bm25, embedding tokens, cost and wall time are reported as 0 and a note says no embedding calls are made |
--reranker |
string | none (or reranker in YAML) |
With a LiteLLM rerank model, adds a note estimating rerank requests (about 1 per eval query per config); they are not priced |
Total embedding tokens (est.): ...
Embedding cost (USD est.): ...
LLM dataset cost (USD est.): ...
Wall time (min est.): ...
Strategy-config combinations: ...
chunk-tune evaluate¶
Runs the evaluator for each strategy × default param grid. Uses dummy embeddings only when both --embedding-model is omitted and embedding_model in the workspace YAML (from --config or cwd .autochunk.yaml) is empty or unset; otherwise LiteLLMEmbeddingFunction is used and you are prompted unless --yes. Documents whose content type a selected strategy does not support (e.g. code with the default text strategies) are skipped with a warning naming the strategies that support them; if none remain, the command exits 1.
| Flag | Type | Default | Description |
|---|---|---|---|
path |
path | (required) | File or directory |
--strategies |
string | fixed_tokens,recursive_character |
Comma-separated names |
--use-case |
string | rag_qa (or use_case in YAML) |
rag_qa, search, summarization, code_assist |
--max-docs |
int | 20 (or max_docs in YAML) |
Max documents |
--top-k |
int | 5 |
No effect on metrics: retrieval depth is the effective k = 2000-token context budget / avg chunk tokens |
--config |
path | none | Workspace YAML |
--output-format |
choice | table |
table, json, or yaml |
--embedding-model |
string | none | If set, overrides workspace embedding_model; a non-empty resolved model uses LiteLLM (prompts unless --yes) |
--api-base |
string | none | OpenAI-compatible API base (overrides workspace / CHUNKTUNER_API_BASE) |
--api-key |
string | none | API key for embeddings/LLM (overrides workspace / CHUNKTUNER_API_KEY) |
--llm-model |
string | none | LiteLLM id for generation paths; default is workspace llm_model |
--yes |
bool | false | Skip confirmation for real embeddings and --generate-dataset |
--dataset |
path | none | JSON/YAML eval dataset (queries: question, document_id, answer_spans, optional reference_answer). document_id may be the file path relative to path, an absolute path, or the file name. Mutually exclusive with --generate-dataset |
--generate-dataset |
bool | false | Generate questions with the resolved --llm-model; prompts unless --yes; cached under cache_dir/datasets/ and reused for the same documents, model and settings. Run estimate --generate-dataset first |
--retrieval-scope |
choice | document |
document or corpus: which ranking feeds the score's rank metrics (mrr, recall@1) |
--retrieval-mode |
choice | dense (or retrieval_mode in YAML) |
First-stage retrieval: dense (embeddings), bm25 (lexical BM25, no embedding calls) or hybrid (dense and BM25 fused with reciprocal rank fusion, k = 60). bm25 and hybrid need the bm25 extra |
--reranker |
string | none (or reranker in YAML) |
Optional second stage that reorders the top 20 first-stage chunks of each ranking per query (one rerank call per query; effective k unchanged; token metrics use the reranked order): dummy (free, lexical, for tests), local (cross-encoder/ms-marco-MiniLM-L6-v2) or local:<hf-model-id> (local cross-encoder; needs the late extra, downloads the model), or any other string as a LiteLLM rerank model, e.g. cohere/rerank-english-v3.0 (paid; prompts unless --yes; credentials come from the provider's env vars, not --api-base / --api-key). Warns on stderr when chunks exceed the reranker's input window |
--no-cache |
bool | false | Disable the SQLite embedding cache (cache_dir/chunktuner_cache.sqlite); dummy embeddings are never cached |
Without --dataset or --generate-dataset, a placeholder dataset is used (one query per document, whose answer is the first 200 characters) and a warning is printed on stderr.
chunk-tune evaluate ./samples --output-format json
chunk-tune evaluate ./samples --dataset questions.yaml --retrieval-scope corpus
chunk-tune evaluate ./samples --dataset questions.yaml --retrieval-mode hybrid --reranker local
chunk-tune recommend¶
Full AutoTuner grid over strategies and default (or filtered) param grids; prints best config. Embedding resolution matches evaluate: --embedding-model else workspace embedding_model; dummy only when the resolved value is empty. Documents whose content type a selected strategy does not support (e.g. code with the default text strategies) are skipped with a warning naming the strategies that support them; if none remain, the command exits 1.
| Flag | Type | Default | Description |
|---|---|---|---|
path |
path | (required) | File or directory |
--strategies |
string | fixed_tokens,recursive_character |
Comma-separated names |
--use-case |
string | rag_qa (or use_case in YAML) |
Use case for scoring |
--max-docs |
int | 20 (or max_docs in YAML) |
Max documents |
--top-k |
int | 5 |
No effect on metrics (see evaluate) |
--config |
path | none | Workspace YAML |
--output-format |
choice | table |
table, json, or yaml |
--embedding-model |
string | none | Overrides workspace embedding_model (see evaluate) |
--api-base |
string | none | Same as evaluate |
--api-key |
string | none | Same as evaluate |
--llm-model |
string | none | Same as evaluate |
--yes |
bool | false | Skip paid-call confirmation |
--no-baseline |
bool | false | Skip the baseline run (fixed_tokens 512/0, or code_window 512/0 for code) |
--dataset, --generate-dataset, --retrieval-scope, --retrieval-mode, --reranker, --no-cache |
Same as evaluate |
chunk-tune compare¶
Side-by-side comparison using the first default param set per strategy. Rich table to stdout; optional Markdown report. Embedding resolution matches evaluate. Documents whose content type a selected strategy does not support (e.g. code with the default text strategies) are skipped with a warning naming the strategies that support them; if none remain, the command exits 1.
| Flag | Type | Default | Description |
|---|---|---|---|
path |
path | (required) | File or directory |
--strategies |
string | required | Comma-separated names |
--use-case |
string | rag_qa (or use_case in YAML) |
Use case |
--max-docs |
int | 15 (or max_docs in YAML) |
Max documents |
--top-k |
int | 5 |
No effect on metrics (see evaluate) |
--config |
path | none | Workspace YAML |
--report |
path | none | Write Markdown comparison table |
--embedding-model |
string | none | Overrides workspace embedding_model (see evaluate) |
--api-base |
string | none | Same as evaluate |
--api-key |
string | none | Same as evaluate |
--llm-model |
string | none | Same as evaluate |
--yes |
bool | false | Skip confirmation |
--dataset, --generate-dataset, --retrieval-scope, --retrieval-mode, --reranker, --no-cache |
Same as evaluate |
chunk-tune preview¶
Chunk a single document from a file path or inline string — no embeddings.
| Argument / flag | Type | Default | Description |
|---|---|---|---|
target |
string | (required) | File path or raw text |
-s, --strategy |
string | required | Registered strategy name |
--params |
JSON string | {} |
Strategy params, e.g. '{"max_tokens":256}' |
--output-format |
choice | table |
table, json, or yaml |
--config |
path | none | Workspace YAML |
chunk-tune cache¶
SQLite-backed embedding and chunk caches. Subcommands:
chunk-tune cache stats¶
| Flag | Type | Default | Description |
|---|---|---|---|
--config |
path | none | Workspace YAML (for cache_dir) |
--model |
string | (unset) | Only embedding rows cached for this model; without it, all rows. Rows written before 0.3 (no recorded model) are counted only without --model |
chunk-tune cache clear¶
Same flags as stats. Without --model, clears all embedding and chunk rows for the resolved database; with --model, clears only that model's embedding rows (chunk rows and rows written before 0.3 are kept).