How brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system works
Purpose and Entry Points
This is a hybrid misinformation-detection application. It accepts free-form text, extracts verifiable claims, classifies them quickly, and conditionally escalates uncertain claims to retrieval-augmented LLM verification. The FastAPI service starts at app/main.py; the browser UI is served from app/static/index.html and calls the API through app/static/app.js.
API and Application Boundary
app/main.py owns HTTP integration, exposing analysis, knowledge-base mutation, and health endpoints. It converts request payloads into application models from app/models.py, invokes the orchestration pipeline, and returns structured reports. Static frontend assets remain a separate presentation layer under app/static/.
Multi-Agent Orchestration Pipeline
app/agents/pipeline.py is the primary control-flow coordinator. It implements the staged agent flow:
1. extract one or more claims from submitted text;
2. classify each claim;
3. route based on classifier confidence;
4. retrieve evidence and verify when escalation is needed;
5. assemble a transparent report with verdicts, confidence, rationale, and evidence.
This pipeline is the principal boundary between API delivery and decision logic.
Fast Classification and Confidence Routing
app/services/classifier.py provides the fast-path true/false/uncertain prediction and confidence interface. It supports a production model integration point while retaining heuristic fallback behavior. Configuration in app/config.py supplies the confidence threshold (default documented as 0.78), which determines whether a result is accepted directly or sent through RAG verification.
Evidence Retrieval / Knowledge Base
app/services/retriever.py encapsulates semantic retrieval against a FAISS-backed curated evidence store. Claims are embedded and used to fetch top matching evidence snippets for the verifier. scripts/build_kb.py is the offline knowledge-base construction entry point; the API’s KB-add route provides a runtime mutation path. The FAISS index and its source corpus form a material local persistence boundary, though generated artifacts are not represented in the supplied tree.
LLM Verification Boundary
app/services/verifier.py consumes a claim plus retrieved evidence and produces a grounded verdict and rationale. It can use OpenAI when enabled through OPENAI_API_KEY, OPENAI_MODEL, and USE_OPENAI; OpenAI is therefore an optional external inference dependency. Retrieval evidence is passed into this stage to constrain reasoning and support source-backed reporting.
Models, Runtime, and Deployment Shape
app/models.py defines shared request/report contracts across HTTP, pipeline, and services. The runtime is Python with FastAPI and Uvicorn (uvicorn app.main:app), plus FAISS for local vector search and optional transformer/OpenAI model inference. scripts/train_classifier.py provides the model-training/export path for replacing the classifier fallback with a fine-tuned transformer checkpoint.
Main entry points: main.py FastAPI service · retriever.py Evidence retriever · pipeline.py Analysis pipeline · classifier.py Fast classifier
Components 16
Presentation
- Browser UI
app/static/index.html - API client
app/static/app.js
API Runtime
- FastAPI service · Serves analysis, KB mutation, and health endpoints.
app/main.py - Shared contracts · Request and report models shared across layers.
app/models.py - Runtime configuration · Supplies the confidence threshold and integration settings.
app/config.py
Decision Pipeline
- Analysis pipeline · Coordinates claim-level staged analysis and report assembly.
app/agents/pipeline.py - Claim extraction
- Fast classifier · Returns true, false, or uncertain with confidence.
app/services/classifier.py - Confidence routing · Accepts confident classifications or escalates uncertain claims.
- Grounded verifier · Produces a verdict and rationale from claim evidence.
app/services/verifier.py
Knowledge & Model Lifecycle
- Evidence retriever · Embeds claims and fetches relevant evidence.
app/services/retriever.py - Curated evidence store · Local persistence for searchable evidence.
- KB builder · Builds the local evidence index from source corpus.
scripts/build_kb.py - Classifier training · Exports a fine-tuned classifier checkpoint.
scripts/train_classifier.py - Classifier model · Production model integration point with heuristic fallback.
Other components
- OpenAI inference · Enabled by runtime environment settings.
Connections 18
- Browser UI → API client: loads
- API client → FastAPI service: API requests
- FastAPI service → Shared contracts: parses and returns
- FastAPI service → Analysis pipeline: submits text
- FastAPI service → Evidence retriever: KB-add route
- Analysis pipeline → Claim extraction: extracts claims
- Claim extraction → Fast classifier: per claim
- Fast classifier → Confidence routing: label + confidence
- Runtime configuration → Confidence routing: threshold
- Confidence routing → Analysis pipeline: accept fast verdict
- Confidence routing → Evidence retriever: escalate
- Evidence retriever → Curated evidence store: semantic search
- Evidence retriever → Grounded verifier: evidence snippets
- Grounded verifier → Analysis pipeline: grounded verdict
- Grounded verifier → OpenAI inference: optional inference
- KB builder → Curated evidence store: builds
- Classifier training → Classifier model: exports
- Fast classifier → Classifier model: uses when available