# tsinghua-fib-lab/cola architecture

> Architecture diagram of the GitHub repository tsinghua-fib-lab/cola, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tsinghua-fib-lab/cola
- Repository: https://github.com/tsinghua-fib-lab/cola

## Overview

COLA is a single-script stance-detection prototype. It reads tweets and targets from a CSV, generates linguistic, target-expert, and social-media-user analyses, drafts arguments for and against each stance, then asks for a final label and writes the enriched rows to CSV. The graph follows the orchestration and model calls visible in cola.py; the README gives the research context but no further implementation detail.

Main entry points: [`cola.py`](https://github.com/tsinghua-fib-lab/cola/blob/main/cola.py) (Row Predictor)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_input_csv["Input CSV"]
node_loader["CSV Loader<br/>[cola.py]"]
node_predictor["Row Predictor<br/>[cola.py]"]
node_linguist["Linguist Analysis<br/>[cola.py]"]
node_expert["Expert Analysis<br/>[cola.py]"]
node_user_analysis["User Analysis<br/>[cola.py]"]
node_debate["Stance Arguments<br/>[cola.py]"]
node_judgement["Final Judgment<br/>[cola.py]"]
node_role_completion["Role Completion<br/>[cola.py]"]
node_completion["Prompt Completion<br/>[cola.py]"]
node_openai["OpenAI API"]
node_output_csv["Result CSV"]

node_input_csv -->|"reads CSV"| node_loader
node_loader -->|"returns rows"| node_predictor
node_predictor -->|"analyzes tweet"| node_linguist
node_predictor -->|"analyzes target"| node_expert
node_predictor -->|"analyzes context"| node_user_analysis
node_predictor -->|"requests arguments"| node_debate
node_predictor -->|"requests label"| node_judgement
node_linguist -->|"requests analysis"| node_role_completion
node_expert -->|"requests analysis"| node_role_completion
node_user_analysis -->|"requests analysis"| node_role_completion
node_debate -->|"submits arguments"| node_completion
node_judgement -->|"submits judgment"| node_completion
node_role_completion -->|"calls chat API"| node_openai
node_completion -->|"calls chat API"| node_openai
node_predictor -->|"writes results"| node_output_csv

click node_loader "https://github.com/tsinghua-fib-lab/cola/blob/main/cola.py"
click node_predictor "https://github.com/tsinghua-fib-lab/cola/blob/main/cola.py"
click node_linguist "https://github.com/tsinghua-fib-lab/cola/blob/main/cola.py"
click node_expert "https://github.com/tsinghua-fib-lab/cola/blob/main/cola.py"
click node_user_analysis "https://github.com/tsinghua-fib-lab/cola/blob/main/cola.py"
click node_debate "https://github.com/tsinghua-fib-lab/cola/blob/main/cola.py"
click node_judgement "https://github.com/tsinghua-fib-lab/cola/blob/main/cola.py"
click node_role_completion "https://github.com/tsinghua-fib-lab/cola/blob/main/cola.py"
click node_completion "https://github.com/tsinghua-fib-lab/cola/blob/main/cola.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_input_csv,node_output_csv toneIndigo
class node_loader,node_predictor,node_linguist,node_expert,node_debate,node_judgement,node_role_completion,node_completion toneTeal
class node_user_analysis toneBlue
class node_openai toneMint
```

## Components

### Other components

- **Input CSV**
- [CSV Loader](https://github.com/tsinghua-fib-lab/cola/blob/main/cola.py): `cola.py`
- [Row Predictor](https://github.com/tsinghua-fib-lab/cola/blob/main/cola.py): `cola.py`
- [Linguist Analysis](https://github.com/tsinghua-fib-lab/cola/blob/main/cola.py): `cola.py`
- [Expert Analysis](https://github.com/tsinghua-fib-lab/cola/blob/main/cola.py): `cola.py`
- [User Analysis](https://github.com/tsinghua-fib-lab/cola/blob/main/cola.py): `cola.py`
- [Stance Arguments](https://github.com/tsinghua-fib-lab/cola/blob/main/cola.py): `cola.py`
- [Final Judgment](https://github.com/tsinghua-fib-lab/cola/blob/main/cola.py): `cola.py`
- [Role Completion](https://github.com/tsinghua-fib-lab/cola/blob/main/cola.py): `cola.py`
- [Prompt Completion](https://github.com/tsinghua-fib-lab/cola/blob/main/cola.py): `cola.py`
- **OpenAI API**
- **Result CSV**

## Connections

- Input CSV → CSV Loader: reads CSV (evidence: `cola.py`)
- CSV Loader → Row Predictor: returns rows (evidence: `cola.py`)
- Row Predictor → Linguist Analysis: analyzes tweet (evidence: `cola.py`)
- Row Predictor → Expert Analysis: analyzes target (evidence: `cola.py`)
- Row Predictor → User Analysis: analyzes context (evidence: `cola.py`)
- Row Predictor → Stance Arguments: requests arguments (evidence: `cola.py`)
- Row Predictor → Final Judgment: requests label (evidence: `cola.py`)
- Linguist Analysis → Role Completion: requests analysis (evidence: `cola.py`)
- Expert Analysis → Role Completion: requests analysis (evidence: `cola.py`)
- User Analysis → Role Completion: requests analysis (evidence: `cola.py`)
- Stance Arguments → Prompt Completion: submits arguments (evidence: `cola.py`)
- Final Judgment → Prompt Completion: submits judgment (evidence: `cola.py`)
- Role Completion → OpenAI API: calls chat API (evidence: `cola.py`)
- Prompt Completion → OpenAI API: calls chat API (evidence: `cola.py`)
- Row Predictor → Result CSV: writes results (evidence: `cola.py`)
