๐ง Consensus Pipeline
September 3, 2026 ยท View on GitHub
Multi-agent debate framework for academic research. Instead of one AI writing a literature review for you โ an AI team interviews you, debates each claim, reaches consensus with per-claim confidence scores, and verifies every citation against the source abstracts.
๐ ไธญๆๆๆกฃ ยท ๐ฆ GitHub Releases
โก Quick Start
Pick one of three paths (start with 1 or 2):
๐ 1. One-shot installer (fastest)
# Windows PowerShell
irm https://github.com/fangqian616/consensus-pipeline/raw/main/install.ps1 | iex
# macOS / Linux
curl -fsSL https://github.com/fangqian616/consensus-pipeline/raw/main/install.sh | bash
One command clones + installs deps + prints your MCP config.
๐ค 2. DSH plugin (AI-driven, recommended)
git clone --depth 1 https://github.com/fangqian616/consensus-pipeline.git
npx -p @deepseek-ai/dsh dsh plugin --profile web add file:./consensus-pipeline/dsh-plugin
Then tell DSH "ๅ ฑ่ฏ็ฎก็บฟๅผๅง้ๆฑ่ฐ็ " โ it runs the requirement interview โ department config โ multi-round debate โ confidence-annotated report. The ๐ ๆงๅถๅฐ floating button (bottom-right) shows live progress, atomic verification, and full-text upload.
๐ฅ๏ธ 3. Streamlit / CLI (manual)
git clone https://github.com/fangqian616/consensus-pipeline.git
cd consensus-pipeline
pip install -r requirements.txt
# Set the key (export on Linux/macOS, $env: on PowerShell)
export DEEPSEEK_API_KEY="sk-your-key-here"
streamlit run app.py # web UI, browser opens
python run_pipeline_v2.py --topic "Your Topic" # headless CLI
A full run is an offline batch job โ start it and let it run in the background, no need to watch. Full details on all three paths (MCP config, full-text upload, custom endpoints) โ ๐ Usage
โ Why Not Just Ask ChatGPT?
A single LLM produces confident-sounding answers with no cross-validation โ hallucinations slip through, conflicting perspectives get flattened, and you can't tell which conclusions are solid vs. speculative.
Consensus Pipeline replaces one-shot generation with structured multi-agent debate as a quality gate: every claim is challenged by independent "departments," contradictions are surfaced explicitly, and final conclusions carry confidence annotations (e.g., "42/77 papers, high confidence").
Think of it as built-in peer review โ not a single author, but an adversarial committee.
๐ธ What It Looks Like
Step 1: Requirement Interview
The pipeline starts by interviewing you โ an AI agent asks clarifying questions to understand your research scope, constraints, and goals.
Step 2: Smart Department Configuration
Based on your topic, the AI auto-generates 10+ specialized debate departments with multiple debaters per department. Each debater argues from a different methodological perspective.
Step 3: Multi-Round Debate
Watch debaters argue in real-time. Each round, debaters present their position, challenge others' assumptions, and refine their arguments. The pipeline runs 3-8 rounds per department (default), stopping early once debaters converge via dynamic termination.
Step 4: Structured Output
Debate results are structured into JSON with clear roles, positions, and consensus points โ ready for report generation.
Step 5: Report with Confidence Annotations
The final report includes per-claim confidence scores, methodology comparison matrices, and verified citations. Every conclusion tells you how many papers support it.
Full example report (148 papers, energy economics): see examples/final_report.md
Bonus: Auto-Generated Code & References
The pipeline also generates runnable Python code for key methods and compiles a verified reference list.
Example Output
Here's what a real report excerpt looks like โ note the per-claim confidence annotations:
Deep learning methods dominate short-term energy load forecasting (42/77 papers, high confidence)
LSTM and Transformer-based models consistently outperform traditional ARIMA methods by 10-40% in MAE metrics across multiple benchmark datasets. However, the methodology review department flagged widespread data leakage concerns โ several studies used overlapping train/test splits that inflated apparent accuracy gains.
Graph neural networks show emerging potential in energy network optimization (3/77 papers, low confidence โ trend not established)
While GNNs demonstrate structural advantages for modeling grid topology, current evidence is limited to small-scale test networks (< 100 nodes). Cross-department validation rated this claim as "promising but insufficiently validated."
Each claim survives adversarial challenge from multiple AI agents before appearing in the report. Claims that can't be verified from available abstracts are explicitly separated rather than silently scored.
๐ฏ What It Does
Consensus Pipeline takes a research topic and produces a structured literature review through multi-agent debate.
The pipeline in one sentence: Search papers โ 3-layer QC filter โ 11 departments debate each claim โ cross-department validation โ generate report with confidence scores.
Key difference from tools like Elicit/Consensus: Those tools extract and summarize. This tool debates. Each finding has to survive adversarial challenge from multiple AI agents before it makes it into the report.
Core capabilities:
- ๐ Multi-source paper search โ OpenAlex + Semantic Scholar + arXiv, auto-deduplication
- ๐๏ธ 11-department multi-agent debate โ each department has 2-4 debaters arguing from different perspectives
- ๐ Per-claim confidence annotation โ every conclusion tagged with evidence count (e.g., "42/77 papers, high confidence")
- โ NLI citation verification โ every claim checked against source abstracts, unverifiable claims excluded from scoring
- ๐ Structured report output โ Markdown + DOCX + PDF export, bilingual (CN/EN)
Full feature list:
- โ Multi-source paper search (OpenAlex + Semantic Scholar + arXiv)
- โ 3-layer QC: hard filter โ LLM classify โ importance tagging (219 โ 77 papers, ~65% exclusion)
- โ 10-11 debate departments, each with 2-4 debaters arguing from different perspectives
- โ Multi-round debate with dynamic termination โ stance quantification (CV) + Kendall's W agreement; debate stops early once debaters converge instead of running fixed rounds
- โ Cross-department validation (one department checks another's work)
- โ Per-claim confidence annotation (e.g., "42/77 papers, high confidence")
- โ NLI citation verification โ per-claim verdicts (โ /โ ๏ธ/โ), with unverifiable claims (๐ needs-fulltext / ๐ญ title-only) explicitly excluded from the confidence score, not silently counted
- โ Citation-mismatch vs overstatement classification โ when both abstract AND full text are neutral, the verifier tells you why: โ ๏ธ wrong-paper citation vs โ๏ธ overstated wording
- โ Full-text NLI upgrade โ abstract-neutral claims auto-recheck against the paper's real full text (OA via Unpaywall/Semantic Scholar, or your uploaded PDF)
- โ Meta-narrative claim filtering โ report self-statistics ("this review included 215 papers") are excluded from verification, so they can't poison the confidence score
- โ Department-to-department consensus handoff โ later departments see earlier departments' conclusions (no more isolated debate silos)
- โ Faithful-paraphrase rule โ the report only transcribes what papers explicitly state (no invented data levels / mechanism directions)
- โ Full-text supplementation system โ upload paywalled-paper PDFs, debate-midway breakpoint asks which "missing-but-necessary" papers to import, imported papers are force-included in the report
- โ Auto-generated runnable code for research methods
- โ PDF/DOCX export
- โ
Bilingual output (
--lang enor--lang zh) - โ Streamlit UI with real-time debate monitoring + manual/auto convergence modes
- โ DSH control panel โ atomic-verification card, full-text batch upload, one-click re-verify with progress bar, pending-import list (pause / continue / skip)
- โ
One-shot installer โ
irm โฆinstall.ps1 | iex/curl โฆinstall.sh | bash - โ
DSH plugin bundle โ
dsh plugin addwith auto-clone of the project - โ Seed-paper import โ your own PDFs are force-included in the debate + report
What's still rough:
- โ ๏ธ Some UI labels are bilingual (Chinese/English mix) in English mode
- โ ๏ธ No GPU needed, but a full run takes a while (time and cost vary by topic and paper count)
- โ ๏ธ Cross-department pairing logic is basic (two-layer fallback, not optimized)
๐๏ธ How It Works
| Phase | Stage | What happens |
|---|---|---|
| 0 | Requirement Interview | AI interviews you about scope, constraints & goals |
| 0.5 | Domain Config | AI generates the domain config (zero hardcoding) |
| 1 | Structuring | Scope & constraint extraction |
| 2 | Discussion | Multi-angle requirement discussion |
| 3 | Config Recommendation | Department configuration recommendation |
| 3.5 | QC Gate | 3-layer quality filter: hard_filter โ LLM_classify โ tag_layer |
| 4 | Paper Search | OpenAlex + Semantic Scholar + arXiv โ dedup, abstract backfill |
| 4.9 | Full-text Fetch | Auto-fetch OA full text (Unpaywall โ Semantic Scholar โ OpenAlex) |
| 5 | Department Debate (v2) | 11 departments debate; stance quantification (CV) + Kendall's W โ dynamic termination |
| 5.5 | Full-text Gate | Interactive breakpoint โ import the few missing-but-necessary paywalled PDFs |
| 6 | Cross-Debate | Departments validate each other's conclusions |
| 7 | Report Generation | Literature review + confidence annotations + code + PDF/DOCX export |
| 7.5 | Citation Verification | NLI verification of every claim against source abstracts / full text |
11 Research Departments
| Department | What They Debate |
|---|---|
| Literature Search | Which databases to query, what keywords to use, how broad vs. precise |
| Metadata Inspector | DOI verification, metadata completeness, source reliability |
| Citation Network | Citation analysis, impact metrics, influence mapping |
| Methodology Review | 7-dimension evaluation: accuracy, efficiency, interpretability, etc. |
| Data Validation | Data source quality, reproducibility, potential biases |
| Counter-Evidence | Anti-mainstream findings, controversy identification |
| Topic Clustering | Thematic grouping, trend detection, gap identification |
| Visualization | Chart analysis, distribution patterns, data representation |
| Report Integration | Synthesize department conclusions into the final structured report |
| Programming | Which tools/methods to recommend, runnable code generation |
| Tutorial | How to use research tools, methodological guidance |
Confidence Annotation
Every conclusion in the report carries a confidence tag:
Deep learning methods dominate short-term energy load forecasting (42/77 papers, high confidence)
Graph neural networks show emerging potential in energy network optimization (3/77 papers, low confidence โ trend not established)
No more unsupported claims.
Citation Verification Report (NLI)
After the report is generated, a dedicated verifier checks every claim against the retrieved abstracts using natural language inference โ no claim ships unexamined.
Each claim gets an explicit verdict:
- โ Verified โ the abstract directly supports the claim
- โ ๏ธ Partially verified โ only part of the claim is supported
- โ Contradicted โ the abstract says otherwise
- โ Unverified โ evidence is insufficient (counted in the score)
Claims that cannot be judged from abstracts alone are honestly separated, not silently counted:
- ๐ Needs full-text โ the abstract doesn't cover this claim (excluded from scoring)
- ๐ญ Title-only โ no abstract available (excluded from scoring)
The overall confidence score therefore reflects only claims the verifier could actually judge. Author metadata is injected during verification, so the checker first confirms "this is the right paper" before judging the content โ catching mismatched citations that merely look plausible.
Full-Text Supplementation System
Paywalled papers are the honest gap: the verifier can only judge a claim from its abstract, and many claims need the real full text. The pipeline closes this gap in two steps:
- Phase 4.9 โ automatic (zero user effort). Before debate, the pipeline crawls OA full text for every retrieved paper (Unpaywall โ Semantic Scholar โ OpenAlex) and matches any PDFs you've placed in
fulltext_papers/. - Phase 5.5 โ interactive breakpoint. After the first few debate departments, the pipeline extracts every paper the debate actually cites, finds the ones that are both missing full text and necessary (consensus-cited or cross-department), and asks you to import just those few.
- Full-text NLI upgrade. When an abstract is neutral, the verifier fetches the full text and re-checks: entail โ โ verified; contradict โ โ; still neutral โ classified as โ ๏ธ citation mismatch (wrong paper) or โ๏ธ overstated claim (right paper, wording too strong).
- Force-include. Papers you import are marked
weight=coreand guaranteed a spot in the report โ your uploads never go to waste.
Upload PDFs two ways:
- DSH control panel โ batch upload (any filename; the DOI is auto-extracted from inside the PDF), then one-click re-verify
- Drop files into
fulltext_papers/, then run--rerun-67to regenerate just the report + verification stage
QC Department (3-Layer Filter)
The biggest quality gate. Three layers ensure zero pollution:
- Layer 1 โ Hard Filter: Remove obviously off-topic papers via LLM-generated exclusion signals
- Layer 2 โ LLM Classify: LLM judges each paper's domain membership
- Layer 3 โ Importance Tagging: Classify into core / method / background tiers
Result on energy economics: 219 โ 77 papers, 64.8% exclusion rate.
Dynamic Domain Config
No hardcoded keywords. The LLM generates everything based on your topic โ exclusion signals, query rotation, tier definitions. Change from "ML in Energy Economics" to "LLM in Healthcare"? Zero code changes.
๐ Usage
Three ways to run Consensus Pipeline. Pick one:
| Entry | Best for |
|---|---|
| ๐ One-shot installer | Fastest start โ one command clones + installs + prints config |
| ๐ค DSH / MCP (AI agent) | Let an AI agent drive it from chat (DeepSeek Harness, Claude, Cursorโฆ) |
| ๐ฅ๏ธ Streamlit / CLI (manual) | Run locally yourself, watch debates, script it |
๐ Way 1: One-Shot Installer (recommended)
Send someone a single command and it self-installs. No separate clone / pip / config steps.
Windows (PowerShell):
irm https://github.com/fangqian616/consensus-pipeline/raw/main/install.ps1 | iex
macOS / Linux:
curl -fsSL https://github.com/fangqian616/consensus-pipeline/raw/main/install.sh | bash
What it does: git clone โ pip install -r requirements.txt โ prints the mcp.json snippet for your MCP client.
Then paste the printed snippet into your MCP client (mcpServers.consensus-pipeline โ python mcp_server.py). Supported: Claude Desktop, Cursor, Codex, and any MCP-compatible agent.
๐ก Requires
gitandpython3.10+. The firstpip installtakes 1-2 minutes.
๐ค Way 2: AI Agent (DSH / MCP)
DSH (DeepSeek Harness) โ native tools + control panel
Install as a bundle (auto-registers native tools + the /consensus-pipeline/ panel):
git clone --depth 1 https://github.com/fangqian616/consensus-pipeline.git
npx -p @deepseek-ai/dsh dsh plugin --profile web add file:./consensus-pipeline/dsh-plugin
Or, for local development, link the plugin dir into DSH's node_modules and restart.
On first use, the plugin auto-clones the full project to ~/.dsh/consensus-pipeline (so the Python mcp_server.py is always present โ no manual clone needed). The ๐ ๆงๅถๅฐ floating button appears bottom-right.
Daily use:
- Tell the agent your research direction in chat โ it runs the requirement interview, then starts the pipeline.
- Click ๐ ๆงๅถๅฐ to open the panel โ live progress, atomic verification, full-text upload.
- At the Phase 5.5 breakpoint, a โณ pending-import list appears: pause, drop in paywalled PDFs, continue.
๐ก Tip: To start the pipeline via DSH, try saying: "ๅ ฑ่ฏ็ฎก็บฟๅผๅง้ๆฑ่ฐ็ " โ DSH will launch the requirement interview and guide you through the full pipeline.
Any MCP client (Claude Desktop / Cursor / Codexโฆ)
The MCP server is zero-dependency (pure stdlib). Point any MCP client at it:
{
"mcpServers": {
"consensus-pipeline": {
"command": "python",
"args": ["/path/to/consensus-pipeline/mcp_server.py"]
}
}
}
The one-shot installer above prints exactly this snippet for you.
๐ฅ๏ธ Way 3: Streamlit / CLI (manual)
Run it yourself โ visual UI or headless script.
Streamlit Web UI
git clone https://github.com/fangqian616/consensus-pipeline.git
cd consensus-pipeline
pip install -r requirements.txt
streamlit run app.py
Browser opens to http://localhost:8501. In the sidebar: paste your DeepSeek API key, pick a language, then start the academic pipeline โ the AI interviewer asks about your topic, generates the debate departments, and the multi-round debate runs with live monitoring.
CLI (headless)
git clone https://github.com/fangqian616/consensus-pipeline.git
cd consensus-pipeline
pip install -r requirements.txt
Set the API key:
# Linux/macOS
export DEEPSEEK_API_KEY="sk-your-key-here"
# Windows (PowerShell)
$env:DEEPSEEK_API_KEY="sk-your-key-here"
# โฆor create a .env in the project root: DEEPSEEK_API_KEY=sk-your-key-here
Run the v2 pipeline (recommended โ stance quantification + dynamic termination):
python run_pipeline_v2.py --topic "Machine Learning in Energy Economics" --lang en
# ไธญๆ๏ผ้ป่ฎค๏ผ
python run_pipeline_v2.py --topic "็ขณๅธๅบไปทๆ ผ้ขๆตไธ่ฝๆบ่ฝฌๅๅ
ณ่ๆบๅถ็ ็ฉถ"
Optional requirement research first (Phase 0-3 โ department config):
python run_requirement_research.py --topic "ไฝ ็่ฏพ้ข"
Re-run only the report + verification stage (after adding full-text PDFs):
python run_pipeline_v2.py --topic "ไฝ ็่ฏพ้ข" --output-dir "v2_run_output/<run-dir>" --rerun-67
Output lands in v2_run_output/<date>_<topic>/ (v2) or run_output/ (v1) โ Markdown + DOCX reports, citation_verification.json, debate logs, and generated charts.
Full-Text Supplementation (paywalled papers)
Papers behind paywalls can't be verified from their abstract alone. Two ways to close the gap:
- DSH control panel โ batch-upload paywalled PDFs (any filename; DOI auto-extracted), one-click re-verify with a progress bar, pending-import list with pause / continue / skip.
- CLI
--rerun-67โ drop PDFs intofulltext_papers/, then regenerate only the report + verification stage (reuses the finished debate).
Custom API Endpoint (optional)
Any OpenAI-compatible API works:
export DEEPSEEK_API_KEY="your-key"
export DEEPSEEK_MODEL="deepseek-v4-flash" # or deepseek-v4-pro
python run_pipeline_v2.py --topic "Your Topic" --lang en
๐ Prerequisites
| Requirement | Details |
|---|---|
| Python 3.10+ | 3.11+ recommended |
| DeepSeek API Key | Register โ required for LLM calls |
| git | For the one-shot installer / clone |
| Internet | Access to DeepSeek API (custom endpoints supported) |
๐ก No GPU needed. No database needed. Paper retrieval uses free open APIs (arXiv / Semantic Scholar / OpenAlex).
โ๏ธ Configuration
API Keys
| Variable | Required | Description |
|---|---|---|
DEEPSEEK_API_KEY | โ Yes | API key for LLM calls |
EASYSCHOLAR_SECRET_KEY | No | Enhanced journal ranking (optional, falls back to 209-journal local registry) |
Supported Models
| Provider | API URL | Tested With |
|---|---|---|
| DeepSeek | https://api.deepseek.com/v1 | deepseek-v4-flash (debate), deepseek-v4-pro (verify/report) |
| OpenAI | https://api.openai.com/v1 | gpt-4o (compatible) |
| Custom | Any OpenAI-compatible endpoint | Any model |
Set API key and model in the Streamlit sidebar, or via environment variables.
๐ Project Structure
consensus-pipeline/
โโโ install.ps1 / install.sh # One-shot installers (clone + pip + mcp.json)
โโโ app.py # Streamlit main app
โโโ router.py # AI Router โ smart department config
โโโ debate_engine.py # Core debate engine
โโโ config_manager.py # Config persistence & presets
โโโ run_pipeline.py # CLI runner (v1)
โโโ run_pipeline_v2.py # CLI runner (v2) โ stance quantification + dynamic termination
โโโ stance_quant_v2.py # v2 stance quantification (CV + Kendall's W convergence)
โโโ run_requirement_research.py # Requirement research (Phase 0-3)
โโโ paper_importer.py # Seed-paper import (PDF โ metadata)
โโโ consensus_meter.py # Consensus gauge dashboard
โโโ mcp_server.py # MCP server (zero-dependency)
โโโ panel.html # DSH control panel (verification card + full-text upload)
โโโ dsh-plugin/ # DSH plugin bundle (mounts /consensus-pipeline/ + native tools)
โ โโโ index.js # panel routes + JSON-RPC tools + auto-clone
โ โโโ cordis.patch.yml # bundle patch
โโโ fulltext_papers/ # User-uploaded paywalled-paper PDFs (gitignored)
โโโ quality_controller.py # QC department (3-layer filter)
โโโ domain_config_generator.py # Dynamic domain config
โโโ docx_exporter.py # Word export
โโโ pdf_exporter.py # PDF export
โโโ academic/ # Academic research module
โ โโโ search_engine.py # Multi-source paper search
โ โโโ journal_classifier.py # Journal quality sieve
โ โโโ journal_registry.py # 209-journal local registry
โ โโโ cross_validator.py # Cross-validation & topic clustering
โ โโโ report_generator.py # Report generation with confidence
โ โโโ report_visualizer.py # Report charts
โ โโโ visualizer.py # Academic charts (trends, distributions)
โโโ requirement/ # Requirement & verification module
โ โโโ interviewer.py # AI interview agent
โ โโโ structurer.py # Scope & constraint extraction
โ โโโ discussion_group.py # Multi-angle requirement discussion
โ โโโ config_recommender.py # Department config recommendation
โ โโโ citation_verifier.py # NLI citation verification (full-text upgrade + mismatch/overstatement)
โ โโโ fact_checker.py # Key-conclusion fact checking
โโโ templates/ # Debate prompt templates
โโโ presets/ # Built-in presets
โโโ docs/ # Quickstart & preset guides
โโโ examples/ # Screenshots & example outputs
โโโ user_profiles/ # Interview profiles
๐บ๏ธ Roadmap
| Priority | Feature | Status |
|---|---|---|
| P0 | Fix UI labels bilingual in EN mode | In progress |
| P1 | Semantic citation verification | โ Shipped in v0.12 (NLI-based) |
| P1 | Sub-topic query splitting | Planned |
| P1 | Publication bias detection (funnel plot) | Planned |
| P2 | Cross-language retrieval (CNKI + bilingual alignment) | Planned |
| P2 | Incremental update capability | Planned |
| P2 | Evaluation metrics for debate quality | Planned |
โ FAQ
Q: How long does a full run take? A: It takes a while โ the exact time depends on topic and paper count. The debate phase is the bottleneck; more departments = more API calls.
Q: How much does it cost? A: It varies with topic, paper count, and current DeepSeek pricing. A full run is inexpensive โ check the latest pricing for an exact number.
Q: Which models are supported? A: Any OpenAI-compatible API. Tested primarily with DeepSeek. Should work with local models via custom endpoints โ haven't tested yet.
Q: What languages does the output support?
A: Academic pipeline: Chinese (--lang zh, default) and English (--lang en). Some UI labels are still bilingual in English mode โ working on it.
Q: Can I customize the departments? A: Yes. The AI auto-generates departments based on your topic, and you can edit/add/remove them in the Streamlit UI before starting the debate.
Q: How is this different from Elicit or Consensus.app? A: Those tools extract and summarize. This tool debates โ each finding has to survive adversarial challenge from multiple AI agents before it makes it into the report. The trade-off: slower and more expensive, but catches contradictions that single-pass summarization misses.
Q: Is the debate actually worth it? A: Yes, clearly. I ran both modes. Without debate, the report just summarizes what papers claim. With debate, agents from different perspectives challenge each other โ and those challenges make it into the report. Example: the "accuracy" agent reported decomposition methods achieve 10-40% error reduction. The "methodology rigor" agent flagged widespread data leakage in those same papers. Both perspectives are in the final report. Without debate, only the accuracy claim would've survived. What I can't quantify yet is how much better the overall report is โ working on evaluation metrics.
๐ค Contributing
PRs welcome! Especially:
- ๐ Bug fixes
- ๐ Documentation improvements
- ๐ญ New debater perspectives
- ๐ Evaluation benchmarks for multi-agent debate quality
๐ License
MIT License
This is a student project, actively developed and tested. Feedback, bug reports, and "have you tried X?" suggestions are all welcome.
If Consensus Pipeline helps your research, a โญ on GitHub means a lot โ it helps others find the project.