This document is the command reference for rag-cli.
Top-level help:
uv run python -m src.cli --helpCurrent commands:
convertchunk preparerag baselineparserdataset peekindexingqueryeval create-dataseteval run
Implemented parser subcommands:
parserparser reviewparser preprocess
Convert one file from a source format to a target format.
Help:
uv run python -m src.cli convert --helpCurrent supported pair:
docx -> pdf
Example:
uv run python -m src.cli convert \
--source docx \
--target pdf \
--input "data/ir-sample-a.docx" \
--output data/raw/avatar-comments.pdfNotes:
- conversion uses LibreOffice in headless mode
- requires
sofficeorlibreofficeonPATH
Run the raw parser pipeline from a YAML config.
Help:
uv run python -m src.cli parser --helpExample:
uv run python -m src.cli parser --config configs/baseline.yml --prettyOverride the run output directory:
uv run python -m src.cli parser \
--config configs/baseline.yml \
--output-dir data/artifacts/ir_document \
--prettyBehavior:
- writes raw parser artifacts, manifest, and telemetry
- if
--output-diris omitted, outputs are written underpipeline.artifact_dir/<run_id> - if
--output-diris set, outputs are written directly under that directory
Primary raw artifact:
parsed/unstructured_elements.json
Render saved parser output into a reviewable file.
Help:
uv run python -m src.cli parser review --helpExample:
uv run python -m src.cli parser review \
--input data/artifacts/ir_document/parsed/unstructured_elements.json \
--output-format htmlOptional explicit output file:
uv run python -m src.cli parser review \
--input data/artifacts/ir_document/parsed/unstructured_elements.json \
--output-format html \
--output data/artifacts/ir_document/parsed/unstructured_elements.htmlBehavior:
- reads saved raw parser JSON
- reconstructs Unstructured elements
- writes a review file such as HTML
- falls back to non-paged HTML when
page_numbermetadata is missing
Typical use:
- manual QA of raw parser output
Normalize saved parser output into lighter-weight artifacts.
Help:
uv run python -m src.cli parser preprocess --helpExample:
uv run python -m src.cli parser preprocess \
--input data/artifacts/ir_document/parsed/unstructured_elements.jsonUse a YAML config to control preprocess steps:
uv run python -m src.cli parser preprocess \
--input data/artifacts/ir_document/parsed/unstructured_elements.json \
--config configs/preprocess.ymlExplicit output directory:
uv run python -m src.cli parser preprocess \
--input data/artifacts/ir_document/parsed/unstructured_elements.json \
--output-dir data/artifacts/ir_document/normalizedOutputs:
normalized/elements.jsonnormalized/review.html
Behavior:
- keeps raw parser output unchanged
- normalizes text and metadata for downstream consumption
- accepts optional YAML step toggles through
--config - strips heavy image base64 payloads
- removes decorative elements and repeated boilerplate
- reclassifies heading-like bold
UncategorizedText - cleans table HTML for review and table text for retrieval
- emits structured warnings for extraction gaps such as missing page metadata
merge_table_columnsis disabled by default so sparse extracted table columns are preserved unless explicitly collapsed
Config example:
preprocess:
steps:
merge_table_columns: trueTypical use:
- prepare parser output for human review
- prepare cleaner artifacts for later indexing work
Build structured retrieval chunks from normalized parser elements.
Detailed chunker behavior and output schema are documented in
docs/chunker.md.
Help:
uv run python -m src.cli chunk prepare --helpExample:
uv run python -m src.cli chunk prepare \
--input data/artifacts/ir_document/normalized/elements.jsonUse the default section-table chunker from YAML:
uv run python -m src.cli chunk prepare \
--input data/artifacts/ir_document/normalized/elements.json \
--config configs/chunker.ymlUse the section-token (RAGFlow-inspired) chunker:
uv run python -m src.cli chunk prepare \
--input data/artifacts/ir_document/normalized/elements.json \
--config configs/chunkers/section-token.ymlUse the title-hierarchy chunker (multi-level heading tree):
uv run python -m src.cli chunk prepare \
--input data/artifacts/ir_document/normalized/elements.json \
--config configs/chunkers/title-hierarchy.ymlExplicit output directory:
uv run python -m src.cli chunk prepare \
--input data/artifacts/ir_document/normalized/elements.json \
--output-dir data/artifacts/ir_document/chunkedOutputs:
chunked/chunks.json
Behavior:
- reads normalized parser elements
- supports pluggable chunker strategies through
core/chunker - default
section_tablestrategy writes section parent chunks plus child text and table chunks section_tokenstrategy builds token-sized child chunks with RAGFlow-style table context windows and optional parent-child splitting (accepts legacyragflowprovider alias)title_hierarchystrategy builds a multi-level section tree from heading-text regexes and emits one chunk per leaf-path with ancestor titles inlined- preserves table structure in
table_html,table_text, andtable_text_markdown - attaches nearby narrative context to table chunks through
pre_textandpost_text - emits
chunk_strategyplus provenance fields such asdoc_id,heading_path,source_element_ids, andpage_number
Chunker config examples:
chunker:
provider: section_table
options: {}chunker:
provider: section_token
options:
chunk_token_size: 128
children_delimiters:
- "\n\n"
use_parent_child: true
table_context_size: 64chunker:
provider: title_hierarchy
options:
levels:
- - "^\\d+\\.\\s+[A-Z].*"
- "^\\([a-z]\\)\\s"
hierarchy: null
include_heading_content: false
root_chunk_as_heading: falseInspect local benchmark datasets and print a compact JSON summary.
Help:
uv run python -m src.cli dataset peek --helpExample:
uv run python -m src.cli dataset peek \
--dataset all \
--root data/datasets \
--prettySupported dataset selectors:
financebencht2-ragbenchfinderall
Embed and index chunks into a vector store.
Help:
uv run python -m src.cli indexing --helpExample:
uv run python -m src.cli indexing \
--input data/artifacts/ir_document/chunked/chunks.json \
--config configs/rag-baseline.yml \
--prettyBehavior:
- reads
chunks.json, optionally runs an ordered enrichment pipeline, embeds chunk retrieval text, and stores chunks in the vector DB - requires
embeddingandvector_storesections in the YAML config - optional
enrichmentsection runs before embedding - current providers: OpenAI embeddings + ChromaDB
Supported enrichment steps today:
table_context: RAGFlow-style table context augmentation; writescontent_with_weightfor table chunks using nearby textauto_keywords: RAGFlow-style keyword extraction; writesimportant_kwdandimportant_tksauto_questions: RAGFlow-style question generation; writesquestion_kwdandquestion_tks
Example:
enrichment:
pipeline:
- table_context
- auto_keywords
- auto_questions
options:
table_context:
table_context_size: 64
auto_keywords:
model: gpt-4.1-mini
topn: 3
auto_questions:
model: gpt-4.1-mini
topn: 3Prebuilt enrichment configs:
configs/enrichment/table-context.ymlconfigs/enrichment/auto-keywords.ymlconfigs/enrichment/auto-questions.ymlconfigs/enrichment/all.yml
To inspect enrichment output without embedding:
uv run python scripts/enrichment/preview.py \
--input data/artifacts/ir_document/chunked/chunks.json \
--config configs/enrichment/table-context.yml
uv run python scripts/enrichment/show_chunks.py \
--input data/artifacts/ir_document/enriched/table-context.json \
--feature table_context \
--chunk-type table \
--limit 5Convenience shell wrapper:
scripts/enrichment/run.sh \
configs/enrichment/table-context.yml \
data/artifacts/ir_document/chunked/chunks.json \
table_context \
table \
5The wrapper enables verbose enrichment progress automatically.
Run a RAG query: retrieve context and generate an answer.
Help:
uv run python -m src.cli query --helpSingle question:
uv run python -m src.cli query \
--question "What was AMD total revenue in FY2022?" \
--config configs/rag-baseline.yml \
--prettyBatch mode (JSONL input):
uv run python -m src.cli query \
--input questions.jsonl \
--config configs/rag-baseline.yml \
--output results.jsonlBehavior:
- single mode: retrieves top-k chunks, generates answer, prints JSON result
- batch mode: processes each row in JSONL, writes results to output JSONL
- requires
embedding,vector_store,retrieval, andgenerationconfig sections
Run one-shot baseline RAG over a local chunks.json file.
Detailed behavior is documented in
docs/rag-baseline.md.
Help:
uv run python -m src.cli rag baseline --helpExample:
uv run python -m src.cli rag baseline \
--input data/artifacts/ir_document/chunked/chunks.json \
--question "What was Cash as of December 31, 2024?" \
--config configs/rag-simple-baseline.yml \
--prettyBehavior:
- reads local chunk artifacts
- converts chunks to LangChain
Documentobjects - builds an in-memory vector store for the command run
- retrieves top-k context
- calls the configured chat model
- does not persist an index
Run end-to-end RAG evaluation against a benchmark dataset.
Help:
uv run python -m src.cli eval run --helpExample:
uv run python -m src.cli eval run \
--dataset financebench \
--filter-doc AMD_2022_10K \
--config configs/rag-baseline.yml \
--prettyBehavior:
- loads benchmark questions (FinanceBench supported)
- optionally filters to a specific document via
--filter-doc - for each question: retrieves context, generates answer, collects results
- scores results using RAGAS (faithfulness, answer relevancy, context precision)
- writes
per_question.jsonlandeval_results.jsonto output directory