# composable-models/llm_multiagent_debate architecture

> Architecture diagram of the GitHub repository composable-models/llm_multiagent_debate, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/composable-models/llm_multiagent_debate
- Repository: https://github.com/composable-models/llm_multiagent_debate

## Overview

##### Project Type and Purpose
- This is a research‐oriented, modular experimental framework for “multiagent debate” on language model tasks.
- It is not a full‐stack application or web service; rather, it’s a collection of task‐specific pipelines that generate answers via a debate of multiple LLM agents, then evaluate those answers.

##### File Structure Analysis
- Root:
- README.md – high‐level description and instructions
- requirements.txt – Python dependencies, likely including an LLM client library (e.g., OpenAI SDK)
- Subfolders (each implements one task domain):
- math/
– gen_math.py (generation pipeline)
- gsm/
– gen_gsm.py (generation)
– eval_gsm.py (evaluation)
- biography/
– article.json (input data)
– gen_conversation.py (generation)
– eval_conversation.py (evaluation)
- mmlu/
– gen_mmlu.py (generation)
– eval_mmlu.py (evaluation)
- Pattern: for each domain you have a “gen_*.py” script (runs the debate) and an “eval_*.py” script (computes metrics).

##### Key Architectural Insights from README
- Each generation script:
a. Loads a dataset (e.g., article.json or external GSM/MMLU data).
b. Spawns two or more LLM agents.
c. Orchestrates a debate via repeated prompt exchanges.
d. Collects final answer(s) and logs debate transcripts.
- Each evaluation script:
a. Reads debate outputs.
b. Compares against ground‐truth.
c. Computes accuracy or other metrics.

##### Main Components
A. Dataset Layer (Input)
– article.json, GSM dataset, MMLU dataset, Math problem set
B. Generation Pipeline (Per Task Module)
– Scripts: gen_math.py, gen_gsm.py, gen_conversation.py, gen_mmlu.py
– Common multiagent debate engine (shared orchestration logic)
– Represent with a group of processing blocks
C. LLM Service (External)
– OpenAI API or other LLM provider
D. Debate Log Store
– Generated transcripts and final answers (could be files or in‐memory)
E. Evaluation Pipeline (Per Task Module)
– Scripts: eval_gsm.py, eval_conversation.py, eval_mmlu.py (and potentially eval_math)
– Metrics computation
– Represent with processing blocks culminating in reports
F. Results/Reports
– Accuracy, reasoning metrics, saved to files or printed to console

##### Architectural Patterns and Principles
- Modular design by domain: math, GSM, biography, MMLU.
- Separation of concerns: generation (debate orchestration) vs evaluation (metric computation).
- Single point of integration with external LLM service.
- Data‐driven: each pipeline reads from a dataset, writes logs, then evaluation reuses logs.

## Diagram (Mermaid)

```mermaid
flowchart TD
  subgraph "Datasets"
    math_data["Math Problems"]:::dataStore
    gsm_data["GSM Dataset"]:::dataStore
    bio_data["article.json"]:::dataStore
    mmlu_data["MMLU Dataset"]:::dataStore
  end

  subgraph "Generation Pipelines"
    gm["gen_math.py"]:::processing
    gg["gen_gsm.py"]:::processing
    gb["gen_conversation.py"]:::processing
    gmmlu["gen_mmlu.py"]:::processing
  end

  llm["LLM Service (OpenAI GPT-4)"]:::external

  logs["Logs/Outputs"]:::dataStore

  subgraph "Evaluation Pipelines"
    egsm["eval_gsm.py"]:::processing
    ebio["eval_conversation.py"]:::processing
    emmlu["eval_mmlu.py"]:::processing
  end

  results["Results/Reports"]:::dataStore

  subgraph "Project Config"
    readme["README.md"]:::processing
    req["requirements.txt"]:::processing
  end

  math_data -->|"input dataset"| gm
  gsm_data -->|"input dataset"| gg
  bio_data -->|"input dataset"| gb
  mmlu_data -->|"input dataset"| gmmlu

  gm -->|"prompt requests"| llm
  gg -->|"prompt requests"| llm
  gb -->|"prompt requests"| llm
  gmmlu -->|"prompt requests"| llm

  llm -->|"responses"| gm
  llm -->|"responses"| gg
  llm -->|"responses"| gb
  llm -->|"responses"| gmmlu

  gm -->|"debate transcripts"| logs
  gg -->|"debate transcripts"| logs
  gb -->|"debate transcripts"| logs
  gmmlu -->|"debate transcripts"| logs

  logs -->|"transcripts + ground-truth"| egsm
  gsm_data -->|"ground-truth labels"| egsm

  logs -->|"transcripts + ground-truth"| ebio
  bio_data -->|"ground-truth labels"| ebio

  logs -->|"transcripts + ground-truth"| emmlu
  mmlu_data -->|"ground-truth labels"| emmlu

  egsm -->|"metrics"| results
  ebio -->|"metrics"| results
  emmlu -->|"metrics"| results

  readme -->|"documentation"| results
  req -->|"dependencies"| results

  click bio_data "https://github.com/composable-models/llm_multiagent_debate/blob/main/biography/article.json"
  click gm "https://github.com/composable-models/llm_multiagent_debate/blob/main/math/gen_math.py"
  click gg "https://github.com/composable-models/llm_multiagent_debate/blob/main/gsm/gen_gsm.py"
  click gb "https://github.com/composable-models/llm_multiagent_debate/blob/main/biography/gen_conversation.py"
  click gmmlu "https://github.com/composable-models/llm_multiagent_debate/blob/main/mmlu/gen_mmlu.py"
  click egsm "https://github.com/composable-models/llm_multiagent_debate/blob/main/gsm/eval_gsm.py"
  click ebio "https://github.com/composable-models/llm_multiagent_debate/blob/main/biography/eval_conversation.py"
  click emmlu "https://github.com/composable-models/llm_multiagent_debate/blob/main/mmlu/eval_mmlu.py"
  click readme "https://github.com/composable-models/llm_multiagent_debate/blob/main/README.md"
  click req "https://github.com/composable-models/llm_multiagent_debate/blob/main/requirements.txt"

  classDef dataStore fill:#c8e6c9,stroke:#2e7d32,color:#2e7d32
  classDef processing fill:#bbdefb,stroke:#1565c0,color:#1565c0
  classDef external fill:#e1bee7,stroke:#6a1b9a,color:#6a1b9a
```
