CLI Reference

February 25, 2026 · View on GitHub

Complete reference for all RagTune commands and flags.

Commands Overview

CommandPurpose
ingestLoad documents into vector store
explainDebug retrieval for a single query with score distribution analysis
simulateBatch benchmark with metrics (Recall, MRR, NDCG, Coverage, NeedleCoverage) + failure analysis
compareCompare embedders or configs
reportGenerate markdown reports
import-queriesImport queries from CSV or JSON
auditQuick health check with pass/fail

ingest

Splits documents into chunks, generates embeddings, stores in vector DB.

ragtune ingest ./docs --collection prod --chunk-size 512 --embedder ollama

Flags

FlagDefaultDescription
--collectionrequiredCollection name
--embedderopenaiEmbedding backend
--chunk-size512Characters per chunk
--chunk-overlap64Overlap between chunks
--storeqdrantVector store backend

Example Output

Reading documents from ./docs...
Found 42 documents
Created 187 chunks (avg 489 chars)
Using embedding dimension: 768 (auto-detected from ollama)
✓ Ingested 187 chunks into collection 'prod'

explain

Shows exactly what chunks are retrieved for one query. Use --save to build your test suite incrementally.

ragtune explain "How do I reset my password?" --collection prod --save

Flags

FlagDefaultDescription
--collectionrequiredCollection name
--embedderopenaiEmbedding backend
--top-k5Results to retrieve
--savefalseSave query to golden queries file
--golden-filegolden-queries.jsonPath to golden queries file
--relevant(inferred)Explicit relevant doc path

Diagnostics Output

  • Score statistics (range, mean, std dev)
  • Quartiles (Q1, median, Q3) and distribution shape
  • Top gap analysis (distance between #1 and #2)
  • Automatic insights and warnings

Interpreting Results

SignalMeaningAction
Score > 0.85Strong matchGood retrieval
Score 0.60-0.85Moderate matchMay need tuning
Score < 0.60Weak matchCheck chunk size, embedder
Right doc missingRetrieval failureIncrease chunk size or try different embedder
All scores similarNo clear winnerQuery may be too vague

simulate

Runs many queries, computes aggregate metrics. Use --ci for automated quality gates. Supports optional needle annotations for sub-document content coverage analysis.

ragtune simulate --collection prod --queries golden-queries.json

Flags

FlagDefaultDescription
--collectionrequiredCollection name
--queriesrequiredPath to queries JSON file
--embedderopenaiEmbedding backend
--top-k5Results to retrieve

CI Mode Flags

FlagDefaultDescription
--cifalseEnable CI mode (exit 1 if thresholds fail)
--min-recall0Minimum Recall@K threshold
--min-mrr0Minimum MRR threshold
--min-coverage0Minimum Coverage threshold
--max-latency-p950Maximum p95 latency in ms (0 = no limit)

Bootstrap Flags (Statistical Confidence)

FlagDefaultDescription
--bootstrap0Number of bootstrap samples for confidence intervals (0 = disabled)
--bootstrap-seed42Random seed for reproducibility

When --bootstrap N is set, metrics are computed N times using random sampling with replacement. Output includes mean ± standard deviation for each metric, enabling you to distinguish real changes from random variance.

NeedleCoverage@K

Standard Recall@K checks whether the right document was retrieved, but it can't tell you whether the retrieved chunks actually contain the specific content needed to answer the query. A chunk from the right document may contain surrounding context (preambles, recitals, related sections) rather than the operative text.

NeedleCoverage@K solves this. You annotate queries with "needles" — short text spans that must be present in the retrieved chunks for a complete answer. RagTune checks each needle against the concatenated retrieved text (case-insensitive) and reports the fraction found.

Queries file with needles:

{
  "queries": [{
    "id": "q1",
    "text": "What fines can be imposed under the GDPR?",
    "relevant_docs": ["gdpr.txt"],
    "needles": [
      {"text": "up to 20 000 000 EUR", "source": "Art 83(5)", "difficulty": "easy"},
      {"text": "up to 10 000 000 EUR", "source": "Art 83(4)", "difficulty": "easy"},
      {"text": "imposed on public authorities", "source": "Art 83(7)", "difficulty": "hard"}
    ]
  }]
}

Each needle has a required text field (the span to search for) and optional source and difficulty fields (for your own tracking). If a query has no needles field, it is skipped for this metric — existing queries files work unchanged.

Examples

# Basic run
ragtune simulate --collection prod --queries golden.json

# With needle coverage (just use a queries file that has needles)
ragtune simulate --collection prod --queries needles.json --embedder ollama

# With bootstrap confidence intervals
ragtune simulate --collection prod --queries golden.json --bootstrap 20
# Output: Recall@5: 0.664 ± 0.012 (n=20)

# CI mode with thresholds
ragtune simulate --collection prod --queries golden.json \
  --ci --min-recall 0.85 --min-coverage 0.90

Exit code 1 if thresholds not met.


compare

Compares collections (different chunk sizes) or embedders.

# Compare chunk sizes
ragtune compare --collections prod-256,prod-512,prod-1024 --queries queries.json

# Compare embedders (auto-ingests)
ragtune compare --embedders ollama,openai --docs ./docs --queries queries.json

Flags

FlagDefaultDescription
--collectionsComma-separated collection names
--embeddersComma-separated embedder names
--docsPath to documents (required with --embedders)
--queriesrequiredPath to queries JSON file

audit

Pass/fail health report with recommendations. Great for daily checks or exec summaries.

ragtune audit --collection prod --queries golden-queries.json

Flags

FlagDefaultDescription
--collectionrequiredCollection name
--queriesrequiredPath to queries JSON file
--min-recall0.85Minimum Recall@K threshold
--min-mrr0.70Minimum MRR threshold
--min-coverage0.90Minimum Coverage threshold
--max-latency-p950Maximum p95 latency in ms (0 = no limit)

Returns exit code 0 (pass) or 1 (fail).


report

Creates Markdown or JSON report from a simulation run.

ragtune report --input runs/latest.json --format markdown > report.md

Flags

FlagDefaultDescription
--inputrequiredPath to simulation run JSON
--formatmarkdownOutput format (markdown or json)

import-queries

Import queries from CSV or JSON files.

ragtune import-queries queries.csv --output golden-queries.json

CSV Format

query,relevant_docs
"How do I reset password?",docs/auth/password.md
"What are rate limits?",docs/api/limits.md;docs/api/quotas.md

Header required. Use semicolon for multiple relevant docs.


Common Flags

These flags work across most commands:

FlagDefaultDescription
--collectionrequiredCollection name
--embedderopenaiEmbedding backend (ollama, openai, tei, cohere, voyage)
--top-k5Results to retrieve
--storeqdrantVector store backend

Vector Store Flags

FlagDescription
--store qdrantUse Qdrant (default)
--store pgvector --pgvector-url URLUse PostgreSQL with pgvector
--store weaviate --weaviate-host HOSTUse Weaviate
--store chroma --chroma-url URLUse ChromaDB
--store pinecone --pinecone-host HOST --pinecone-api-key KEYUse Pinecone

Embedder Flags

EmbedderRequired Flags / Environment
ollamaOllama must be running locally
openaiOPENAI_API_KEY environment variable
tei--tei-addr http://localhost:8080
cohereCOHERE_API_KEY environment variable
voyageVOYAGE_API_KEY environment variable, optional --voyage-model