How samiullah07/fyp-llm works
1. This repository is a Python system for multi-agent, retrieval-augmented literature analysis. The core runtime is not a generic web app; it is centered on an orchestration pipeline that searches a paper corpus, drafts content, verifies claims, and assembles final outputs.
2. The primary execution layer appears in agents/:
- planner_agent.py decides what to do next.
- search_agent.py retrieves supporting material.
- summariser_agent.py condenses retrieved evidence.
- verifier_agent.py checks factual consistency or citation quality.
- assembler_agent.py combines intermediate outputs into the final response.
This is the main “brain” of the system and is the most important boundary for an architecture diagram.
3. Workflow composition is separated from the agents themselves in graph/:
- workflow_graph.py likely defines the end-to-end agent workflow.
- baseline_graph.py likely encodes a simpler comparison pipeline.
This suggests the project compares different orchestration strategies rather than only serving one fixed flow.
4. The retrieval and data-access core lives in src/:
- document_reader.py handles source document ingestion/parsing.
- retrieval.py performs search over indexed content.
- models.py holds shared domain structures.
- api_clients.py abstracts calls to external model or service APIs.
- mab_selector.py implements a multi-armed bandit selector for choosing strategies.
- config.py centralizes runtime configuration.
This package is the main boundary between orchestration logic and the underlying knowledge/retrieval layer.
5. Corpus creation and indexing are explicitly versioned under data/corpus/ and data/processed/:
- data/corpus/builder.py builds corpus artifacts.
- corpus_*.json and corpus_combined.json are prepared knowledge sources.
- data/processed/papers_index.faiss and papers_index.pkl indicate a local FAISS vector index plus metadata.
The system therefore uses an offline preprocessing step to build a searchable corpus, then serves retrieval from the precomputed index at runtime.
6. tools/ contains external-data and vector infrastructure helpers:
- openalex_client.py suggests integration with the OpenAlex scholarly metadata API.
- vector_store.py likely wraps vector indexing/search operations.
These are support modules for populating and querying the literature corpus, not the main orchestration path.
7. Evaluation is a major first-class subsystem in evaluation/:
- evaluator.py, metrics.py, and cost_tracker.py measure quality and cost.
- baseline.py compares against baseline behavior.
- ablation_study.py runs variant comparisons.
- annotation_tool.ipynb and the kappa/statistics tests indicate manual labeling and inter-annotator agreement analysis.
This repo is built not only to run the agent pipeline, but also to experimentally measure it.
8. The data/eval/ tree stores experiment outputs, logs, and reports:
- result CSV/JSON files for evaluations and MAB runs.
- baseline and experimental text outputs.
- verifier and assembler logs.
- statistical summaries and annotation artifacts.
For an architecture diagram, this is the persistence layer for experiments and traceability, not user content storage.
9. The top-level entrypoints suggest multiple ways to run or demo the system:
- main.py is likely the primary CLI or orchestration entrypoint.
- app.py and demo_app.py are likely UI-facing launch points.
- app_styles.py supports the presentation layer.
The repository therefore has a separation between core agent execution and a lightweight front-end/demo layer.
10. configs/ and config.py indicate prompt- and runtime-configuration management:
- configs/prompts.py centralizes LLM prompts or agent instructions.
This is important because the behavior of planner/search/summarizer/verifier agents is driven by prompt configuration rather than hardcoded logic alone.
11. utils/logger.py and the extensive logs under data/eval/logs/ and data/eval/verifier_logs/ show that observability is built into the workflow. The system records intermediate agent behavior, which supports debugging, reproducibility, and evaluation.
12. In terms of data flow, the likely high-level path is:
curated papers and metadata -> corpus builder -> FAISS index -> retrieval/search agent -> summarization and verification agents -> assembler -> evaluation/logging.
The alternate path is the baseline workflow, which is kept separate for comparison experiments.
13. The repository is organized more like an experimental agentic research platform than a production service. The most important architectural boundaries are:
- orchestration vs retrieval/indexing,
- runtime inference vs offline corpus building,
- experimental evaluation vs baseline comparison,
- core logic vs UI/demo entrypoints.
14. Tests in test_evaluation.py, test_kappa.py, test_mab.py, test_mab_quick.py, and test_statistics.py reinforce that the project’s main technical concerns are experimental correctness, selection strategy behavior, and evaluation methodology rather than generic application CRUD or serving.
Main entry points: workflow_graph.py Workflow graph · search_agent.py Search · prompts.py Prompts · evaluator.py Evaluator
Components 29
Runtime agents
Core multi-agent execution path for literature analysis.
- Planner · Decides the next action in the agent loop.
agents/planner_agent.py - Search · Retrieves supporting evidence from the corpus.
agents/search_agent.py - Summariser · Condenses retrieved evidence into usable summaries.
agents/summariser_agent.py - Verifier · Checks factual consistency and citation quality.
agents/verifier_agent.py - Assembler · Combines intermediate outputs into a final response.
agents/assembler_agent.py
Workflow graphs
Composition layer that wires agents into end-to-end flows.
- Workflow graph · Defines the main multi-agent workflow.
graph/workflow_graph.py - Baseline graph · Defines a simpler reference pipeline for experiments.
graph/baseline_graph.py
Retrieval stack
Corpus building, indexing, retrieval, and shared domain/data support.
- Reader · Parses and ingests source documents.
src/document_reader.py - Retrieval · Searches indexed content for supporting material.
src/retrieval.py - Models · Shared domain objects used across the system.
src/models.py - API clients · Wraps external model and service API calls.
src/api_clients.py - MAB selector · Chooses among strategies using a multi-armed bandit.
src/mab_selector.py - Runtime config · Centralizes runtime settings and environment-driven behavior.
src/config.py - Prompts · Central prompt and instruction templates for agents.
configs/prompts.py - Corpus builder · Builds corpus artifacts from curated papers and metadata.
data/corpus/builder.py - FAISS index · Precomputed local vector index for retrieval.
data/processed/papers_index.faiss - OpenAlex client · Fetches scholarly metadata for corpus population.
tools/openalex_client.py - Vector store · Handles vector indexing and lookup support.
tools/vector_store.py - Logger · Shared logging utilities used across runtime and evaluation.
utils/logger.py
Evaluation
Experimentation, metrics, baselines, and persisted run artifacts.
- Evaluator · Runs quality evaluation over outputs and runs.
evaluation/evaluator.py - Metrics · Computes quality metrics for experiments.
evaluation/metrics.py - Cost tracker · Tracks inference and experiment cost.
evaluation/cost_tracker.py - Baseline eval · Evaluates baseline behavior against the experimental pipeline.
evaluation/baseline.py - Ablation study · Runs variant comparisons across system configurations.
evaluation/ablation_study.py - Eval artifacts · Persisted outputs, logs, annotations, and reports for experiments.
data/eval
Entrypoints
CLI and lightweight UI/demo launch paths.
Connections 35
- Workflow graph → Planner: orchestrates · The workflow graph coordinates planner-driven execution.
- Workflow graph → Search: routes to · Workflow sends retrieval steps to the search agent.
- Workflow graph → Summariser: routes to · Workflow sends evidence condensation to the summariser.
- Workflow graph → Verifier: routes to · Workflow sends claims to verification.
- Workflow graph → Assembler: routes to · Workflow sends intermediate outputs to assembly.
- Baseline graph → Search: uses · Baseline pipeline still depends on retrieval.
- Baseline graph → Assembler: finishes with · Baseline pipeline assembles a final response.
- Reader → Corpus builder: feeds · Document ingestion contributes to corpus construction.
- OpenAlex client → Corpus builder: enriches · External metadata helps populate corpus artifacts.
- Corpus builder → Vector store: indexes · Built corpus data is prepared for vector storage.
- Vector store → FAISS index: persists · Vector store writes to the FAISS-backed index.
- FAISS index → Retrieval: powers · The precomputed index is queried at runtime.
- Retrieval → Search: serves · Search agent depends on retrieval over indexed corpus.
- Prompts → Planner: guides · Prompt configuration influences planner behavior.
- Prompts → Search: guides · Prompt configuration influences search behavior.
- Prompts → Summariser: guides · Prompt configuration influences summarisation behavior.
- Prompts → Verifier: guides · Prompt configuration influences verification behavior.
- API clients → Planner: connects · Agents rely on external API calls through shared clients.
- Runtime config → Workflow graph: configures · Runtime settings shape workflow execution.
- Runtime config → MAB selector: configures · Strategy selection depends on runtime config.
- MAB selector → Workflow graph: adapts · Bandit selection can influence orchestration strategy.
- Evaluator → Metrics: computes · Evaluation uses metric definitions.
- Evaluator → Cost tracker: tracks · Evaluation records runtime cost.
- Baseline eval → Eval artifacts: writes · Baseline comparisons persist experiment outputs.
- Ablation study → Eval artifacts: writes · Ablation runs persist reports and results.
- Evaluator → Eval artifacts: stores · Evaluation artifacts are written to the eval data tree.
- Logger → Eval artifacts: logs · Workflow and verifier logs are stored with evaluation artifacts.
- Main CLI → Workflow graph: runs · Main entrypoint executes the primary workflow.
- App → Workflow graph: launches · App entrypoint launches the core workflow through a UI.
- Demo app → App: reuses · Demo application likely reuses the same presentation layer.
- App → Styles: uses · UI launch path depends on presentation styles.
- Main CLI → Evaluator: invokes · Primary execution can feed into evaluation runs.
- Search → Models: reads/writes · Retrieval results use shared domain structures.
- Assembler → Logger: emits · Final assembly is traced through logs.
- Verifier → Logger: emits · Verification activity is logged for traceability.