ragflow-bench is a standalone Python CLI for benchmarking a running RAGFlow instance over raw HTTP APIs.
It is not part of the RAGFlow repository, does not import RAGFlow source code, and does not depend on RAGFlow internals. It treats RAGFlow as an external service reachable through HTTP.
- benchmark retrieval and answer generation against a live RAGFlow deployment
- support FRAMES, EnterpriseRAG-Bench, and future custom corpora
- upload and parse benchmark documents through RAGFlow HTTP endpoints
- write incremental JSONL results so partial runs survive failures
- score deterministic metrics only: exact match, normalized exact match, source recall, and failure type
- Python 3.11+
- a reachable RAGFlow instance
- a valid RAGFlow API key
- a valid RAGFlow chat model ID for chat-based runs
Default base URL:
http://127.0.0.1:80pip install -e .export RAGFLOW_BASE_URL="http://127.0.0.1:80"
export RAGFLOW_API_KEY="..."
export RAGFLOW_LLM_ID="..."
export MINIMAX_API_KEY="..."
export MINIMAX_BASE_URL="https://api.minimaxi.com/v1"
export MINIMAX_JUDGE_MODEL="MiniMax-M3"
export MINIMAX_JUDGE_TIMEOUT_SECONDS="120"
export MINIMAX_JUDGE_MAX_RETRIES="6"
export MINIMAX_JUDGE_BACKOFF_SECONDS="2.0"
export MINIMAX_JUDGE_MAX_BACKOFF_SECONDS="30.0"
export ZHIPU_API_KEY="..."
export MOONSHOT_API_KEY="..."Rules:
RAGFLOW_BASE_URLdefaults tohttp://127.0.0.1:80RAGFLOW_API_KEYis required unless supplied directly in configRAGFLOW_LLM_IDis required for chat creation and answer generation- Judge providers are
minimax(default),zhipu,kimi, andcustom. Each named provider has a China-mainland endpoint, API-key environment variable, and model preset; explicit judge config values override the preset. minimaxusesMINIMAX_API_KEYandMiniMax-M3;zhipuusesZHIPU_API_KEYandglm-4.7;kimiusesMOONSHOT_API_KEYandkimi-k2.6.- Provider-specific
*_JUDGE_TIMEOUT_SECONDS,*_JUDGE_MAX_RETRIES,*_JUDGE_BACKOFF_SECONDS, and*_JUDGE_MAX_BACKOFF_SECONDSvariables control judge timeout and transient-failure retries. MiniMax keeps the existingMINIMAX_*names. ragflow-benchauto-loads.envfrom the current working directory without overriding already-exported shell variables.envand.env.*are ignored by git.env.examplecontains placeholders only
ragflow-bench --help
ragflow-bench wizard
ragflow-bench doctor
ragflow-bench prepare-frames
ragflow-bench ingest --config configs/frames_smoke.yaml
ragflow-bench retrieve --config configs/frames_smoke.yaml
ragflow-bench run --config configs/frames_smoke.yaml
ragflow-bench run --config configs/frames_smoke.yaml --no-judge
ragflow-bench retry-failed --run-dir outputs/<run>
ragflow-bench artifacts --id 7832948739847349
ragflow-bench artifacts --id 7832948739847349 --restart --limit 100
ragflow-bench score --results outputs/<run>/results.jsonl
ragflow-bench judge --results outputs/<run>/results.jsonl --config configs/frames_oracle.yamldoctor verifies the live RAGFlow connection and probes the HTTP workflow:
- base URL reachable
- API key accepted
- docs-backed health assumptions match the live server where possible
- dataset creation works
- document upload works
- parsing can be started and polled
- retrieval works
- chat creation/session/completion work when
RAGFLOW_LLM_IDis set
If RAGFLOW_LLM_ID is missing, doctor reports partial success and lists available models when possible.
When a config creates a new dataset, doctor also warns if dataset.embedding_model is omitted, because parsing/indexing will then depend on RAGFlow's server-side default dataset behavior.
ragflow-bench wizard interactively writes a YAML config, prints the exact run command, and can optionally run it immediately.
Configs live under configs/ and can be adapted for local corpora or FRAMES mappings.
For new datasets, set dataset.embedding_model explicitly so RAGFlow uses the intended embedding model during parsing/indexing:
dataset:
strategy: create_new_dataset_and_ingest_documents
name: frames-oracle
embedding_model: your-ragflow-embedding-model-id
chunk_method: naiveIf you reuse an existing dataset, ragflow-bench does not override that dataset's embedding model.
Every run writes:
results.jsonlresults.csvsummary.jsonrun_report.mdrun_report_questions.mdconfig.resolved.yamldocument_registry.jsonwhen ingestion is usedtraces/<question_id>.jsonwhen RAGFlow returns an included RAG trace
ragflow-bench run --config ... automatically runs the judge after the benchmark by default. Use --no-judge when you only need raw answers/traces, or when you plan to run compare-runs across async-vs-agent outputs and want to avoid paying for separate per-run judge passes.
Readable Markdown reports are generated after the raw run and refreshed after judge results are available. Generate or refresh them for an existing run with:
ragflow-bench report --run-dir outputs/<run>run_report.md summarizes results, gold-answer judge scores, trace diagnostics, and the final trace optimization plan when available. run_report_questions.md is a compact per-question table with truncated question/answer/reason cells.
ragflow-bench retry-failed --run-dir outputs/<run> reruns rows with non-empty error using the saved resolved config, stores raw retry attempts under retries/, backs up current result artifacts under backups/, replaces matching question_id rows in-place, and rebuilds results.csv plus summary.json.
ragflow-bench artifacts --id <dataset-id> audits all documents in the selected dataset, checks parsing status and structure artifacts through RAGFlow's HTTP API, and prints a summary. It uses RAGFLOW_BASE_URL and RAGFLOW_API_KEY from the environment, and is read-only by default. Add --restart to restart failed, cancelled, and DONE documents without a non-empty structure artifact. Restarts are submitted in batches of 100; --limit N restricts the number of eligible documents submitted, while omitting --limit submits all eligible documents. The command re-audits immediately after submission and does not wait for parsing to finish.
Chat runs can request the new RAGFlow trace payload for either execution path:
chat:
execution_path: async_chat # or rag_agent
collect_rag_trace: true
include_rag_trace: true
disable_web: trueFor execution_path: rag_agent, start the RAGFlow backend with RAGFLOW_ENABLE_RAG_AGENT=true. Trace collection is requested the same way for both paths. If a server does not return a trace, the row is kept and rag_trace_warning explains that the trace was absent.
To compare two identical runs that differ only by execution path, first generate a compare judge profile, then run both benchmarks without the automatic per-run judge pass, then run one isolated compare pass:
ragflow-bench wizard --compare-judge-profile \
--output configs/compare_trace_judge.yaml
ragflow-bench run --config configs/<async-config>.yaml --no-judge
ragflow-bench run --config configs/<agent-config>.yaml --no-judge
ragflow-bench compare-runs \
--async-run outputs/<async-run> \
--agent-run outputs/<agent-run> \
--config configs/compare_trace_judge.yaml \
--output-dir outputs/compare_async_vs_agent_<timestamp>The compare command makes two separate judge passes per matched question when enabled by the profile:
- Answer comparison scores both final answers against the gold answer and chooses
async,agent,tie,both_perfect, orneither_scorable. - Trace comparison loads each row's
traces/<question_id>.jsonsidecar plus retrieval/final-context diagnostics and separately judges which run has better evidence retrieval, context selection, citation support, and trace completeness. Trace judgment does not change answer correctness.
Each compare invocation writes to its own output directory to avoid conflicts between repeated judge runs:
compare_answer_results.jsonland.csvcompare_trace_results.jsonland.csvcompare_summary.jsoncompare_config.resolved.yaml
compare_summary.json includes explicit async_correct_pct, agent_correct_pct, partial-or-better percentages, answer win percentages, and trace win/missing/excluded percentages. Legacy --out outputs/async_vs_agent_compare.jsonl is still accepted for scripts that expect a single combined JSONL output.
Generated compare judge profile shape:
judge:
provider: minimax
include_confidence: true
max_completion_tokens: 8192
timeout_seconds: 120
max_retries: 3
backoff_seconds: 10.0
max_backoff_seconds: 30.0
compare_judge:
passes:
answer: true
trace: true
trace_inputs:
include_trace_sidecar: true
include_raw_retrieval_diagnostics: true
include_final_context_chunks: true
include_citation_chunk_ids: true
include_retrieval_calls: true
include_tool_calls: true
include_timings: true
include_costs: true
include_raw_response: false
limits:
max_trace_chars_per_run: 20000
max_chunks_per_section: 20
max_tool_calls: 30
output:
default_dir: outputs/compare_async_vs_agent_<timestamp>Use the standalone judge command after a run to score free-form answers with the configured provider:
ragflow-bench judge --results outputs/<run>/results.jsonl --config configs/frames_oracle.yamlSwitch models just by changing the configured or overridden model name:
ragflow-bench judge --results outputs/<run>/results.jsonl --config configs/frames_oracle.yaml --model MiniMax-M3The judge command writes:
judge_results.jsonljudge_results.csvjudge_summary.json- refreshed
run_report.mdandrun_report_questions.md
Judge config shape:
judge:
provider: minimax
max_completion_tokens: 8192
timeout_seconds: 120
max_retries: 6
backoff_seconds: 2.0
max_backoff_seconds: 30.0Named providers need only the provider field unless overriding a preset:
judge:
provider: zhipu # ZHIPU_API_KEY, glm-4.7, https://open.bigmodel.cn/api/paas/v4judge:
provider: kimi # MOONSHOT_API_KEY, kimi-k2.6, https://api.moonshot.cn/v1Kimi uses its China-mainland API, enables its supported thinking mode, and omits temperature because Kimi K2.6 controls that parameter. For any other OpenAI-compatible service, select provider: custom and explicitly configure base_url, an API key or api_key_env_var, and a model.
The judge evaluates semantic correctness against the gold answer, so different wording can still be marked correct.
Judge retries only transient failures: HTTP 429, HTTP 5xx, and ReadTimeout. When the provider sends Retry-After, the judge honors it up to the configured max backoff. Authentication and malformed-response errors still fail fast.
FRAMES uses the Hugging Face dataset:
from datasets import load_dataset
load_dataset("google/frames-benchmark", split="test")FRAMES questions and gold answers come from Hugging Face, but RAGFlow still needs a local corpus to ingest. Use:
ragflow-bench prepare-framesBy default this creates:
data/frames/frames_mapping.jsondata/frames/corpus/data/frames/prepare_report.json
The command reads the FRAMES question rows, extracts the referenced Wikipedia links, downloads parsed Wikipedia HTML through MediaWiki's HTTP API, converts it into table-preserving Markdown corpus files, deduplicates repeated pages, and writes the mapping file expected by the FRAMES adapter.
Then run either:
ragflow-bench ingest --config configs/frames_oracle.yaml
ragflow-bench run --config configs/frames_oracle.yamlor retrieve directly, with behavior determined by dataset.strategy:
ragflow-bench retrieve --config configs/frames_smoke.yamlreuse_existing_dataset→ retrieve from the configured existing datasetreuse_existing_dataset_and_ingest_documents→ upload local corpus documents to the configured existing dataset, wait for parsing, then retrievecreate_new_dataset→ create a fresh empty dataset, then retrievecreate_new_dataset_and_ingest_documents→ create a fresh dataset, ingest local corpus documents, wait for parsing, then retrieve
Prepare the Tevatron BrowseComp-Plus corpus as one Markdown file per document ID:
ragflow-bench prepare-browsecomp-plusThis downloads and decrypts the six dataset parquet shards locally, writes data/browsecomp-plus/corpus/<docid>.md, and creates questions.jsonl, documents_manifest.json, and prepare_report.json. gold_docs become expected_sources; evidence_docs remain as evidence_doc_ids for separate retrieval analysis. Use --question-limit and --document-limit for a smaller local run.
Prepare the Onyx EnterpriseRAG-Bench artifacts from Hugging Face:
ragflow-bench prepare-eragbBy default this creates:
data/eragb/corpus/data/eragb/questions.jsonldata/eragb/documents_manifest.jsondata/eragb/prepare_report.json
The command downloads the questions/documents parquet files, converts document rows into local text files, and preserves Onyx doc_id values as document source_uri metadata for source-recall scoring. For small local tests, pass --document-limit and --question-limit.
For lower file-count runs where exact source-reference accuracy is not required, use merged shard mode:
ragflow-bench prepare-eragb --merge-documents --filter-questions-with-missing-docsMerged mode writes deterministic source-type shards, doc_id_to_shard.json, shard_manifest.json, and parser_config.merged.yaml. Shard text contains only a boundary delimiter plus original content to minimize retrieval bias; doc IDs, titles, and source types stay in sidecar manifests. It maps question references to shard URIs by default and labels reference_granularity as shard; do not compare shard recall with document-level leaderboard source recall.
For EnterpriseRAG-Bench judged runs, judge_summary.json includes an enterprise_rag_bench_leaderboard section with the public leaderboard-style score. This metric is ERAGB-only and is not used for FRAMES or custom benchmarks. It follows the public leaderboard description: per-question contribution is correctness times answer completeness, and local errored or judge-excluded rows are reported but omitted from the local denominator.
Recompute the ERAGB leaderboard-style summary manually and compare your run against the public leaderboard table:
LATEST_RUN="$(ls -td outputs/enterprise_rag_bench_full_* | head -1)"
ragflow-bench eragb-leaderboard-summary \
--results "$LATEST_RUN/judge_results.jsonl" \
--download-public-leaderboard \
--out "$LATEST_RUN/eragb_leaderboard_summary.json"If you already downloaded the public leaderboard CSV, use:
ragflow-bench eragb-leaderboard-summary \
--results "$LATEST_RUN/judge_results.jsonl" \
--leaderboard-csv data/leaderboard/leaderboard.csv \
--out "$LATEST_RUN/eragb_leaderboard_summary.json"Download the public Onyx EnterpriseRAG-Bench leaderboard Space raw data from Hugging Face and generate empirical question difficulty:
ragflow-bench question-difficulty \
--download-public-leaderboard \
--out outputs/question_difficulty.jsonlIf you already downloaded the leaderboard Space raw data, point the command at the local directory containing results_*.json files:
ragflow-bench question-difficulty \
--public-results-dir data/leaderboard/raw_data \
--out outputs/question_difficulty.jsonlCompare a local RAGFlow run against the public difficulty ranking. Prefer judge_results.jsonl when available because it contains semantic judge correctness; use results.jsonl when only deterministic exact-match fields are available:
LATEST_RUN="$(ls -td outputs/enterprise_rag_bench_full_* | head -1)"
ragflow-bench question-difficulty \
--download-public-leaderboard \
--local-results "$LATEST_RUN/judge_results.jsonl" \
--out "$LATEST_RUN/question_difficulty.jsonl" \
--summary-out "$LATEST_RUN/question_difficulty_summary.json"For a manually downloaded leaderboard, replace --download-public-leaderboard with --public-results-dir data/leaderboard/raw_data. Partial local runs are compared only on tested question_ids. Local rows with errors are counted as ignored error questions and excluded from accuracy and bucket calculations. Missing many public-easy questions usually points to a retrieval, ingestion, prompt, or scoring issue; missing mostly public-hard questions is expected. Solving public-hard questions is a positive signal, and bucketed accuracy is more useful than overall score alone.
Inspect the easiest public questions missed and hardest public questions solved:
python3 - <<'PY'
import glob, json, os
run = os.environ.get("LATEST_RUN") or sorted(glob.glob("outputs/enterprise_rag_bench_full_*"))[-1]
summary = json.load(open(f"{run}/question_difficulty_summary.json"))
print("Easiest public questions missed:")
for row in summary["easy_public_missed"][:20]:
print(row["question_id"], row["public_correct_rate"], row.get("question", ""))
print("\nHardest public questions solved:")
for row in summary["hard_public_solved"][:20]:
print(row["question_id"], row["public_correct_rate"], row.get("question", ""))
PY- LLM-as-judge quality depends on the selected judge model and prompt; validate cheaper judge models before using them as final benchmark authority
- live server behavior wins over docs when they disagree
- chat validation still depends on the selected live
RAGFLOW_LLM_ID - if parsing fails on a newly created dataset, verify
dataset.embedding_modeland the corresponding provider binding in the live RAGFlow server
This project does not need to live inside the RAGFlow repository. It only speaks to RAGFlow through HTTP.