# tung-phan-dinh/aixiv-rag architecture

> Architecture diagram of the GitHub repository tung-phan-dinh/aixiv-rag, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tung-phan-dinh/aixiv-rag
- Repository: https://github.com/tung-phan-dinh/aixiv-rag

## Overview

aiXiv-RAG is a research harness for measuring how RAG answers change when the underlying arXiv geoscience corpus is filtered. Its main workflow ingests an immutable corpus, embeds it, applies configured snapshots, retrieves top-k evidence, generates answers, and records runs for analysis. Ablation orchestration owns the experiment loop; reporting computes retrieval and answer-change metrics, with an optional independent LLM judge and run comparison. Edges follow the README pipeline and indexed module references; unsampled implementation details are not inferred.

Main entry points: [`src/rageblate/ablate.py`](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/ablate.py) (Ablation runner), [`src/rageblate/retrieve.py`](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/retrieve.py) (Top-k retrieval), [`src/rageblate/data.py`](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/data.py) (Loaded corpus context), [`src/rageblate/snapshot.py`](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/snapshot.py) (Corpus snapshots)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_corpus["Corpus preparation"]
  node_ingest["Corpus ingestion<br/>[ingest.py]"]
  node_corpus_store[("Immutable corpus<br/>[data.py]")]
  node_embed["Document embeddings<br/>[embed.py]"]
  node_config["Configuration loading<br/>[config.py]"]
end

subgraph group_retrieval["Snapshot retrieval"]
  node_topics["Topic rules<br/>[topics.py]"]
  node_snapshot["Corpus snapshots<br/>[snapshot.py]"]
  node_context["Loaded corpus context<br/>[data.py]"]
  node_index["Exact search index<br/>[index.py]"]
  node_retrieve["Top-k retrieval<br/>[retrieve.py]"]
end

subgraph group_experiment["Experiment execution"]
  node_rag["Answer prompting<br/>[rag.py]"]
  node_llm["Cached model clients<br/>[llm.py]"]
  node_plan["Call planning<br/>[plan.py]"]
  node_ablate["Ablation runner<br/>[ablate.py]"]
  node_results[("Run results<br/>[paths.py]")]
  node_ask["Single-question answering<br/>[ask.py]"]
end

subgraph group_analysis["Evaluation and reporting"]
  node_audit["Question audit<br/>[audit.py]"]
  node_metrics["Experiment metrics<br/>[metrics.py]"]
  node_judge["Answer quality judge<br/>[judge.py]"]
  node_report["Run reports<br/>[report.py]"]
  node_compare["Run comparison<br/>[compare.py]"]
end

node_researcher(("Researcher"))
node_kaggle[("Kaggle arXiv dump")]
node_model_service(("OpenAI or Ollama"))

node_researcher -->|"starts ingestion"| node_ingest
node_kaggle -->|"provides dump"| node_ingest
node_ingest -->|"writes corpus"| node_corpus_store
node_corpus_store -->|"supplies documents"| node_embed
node_embed -->|"produces vectors"| node_context
node_corpus_store -->|"loads rows"| node_context
node_config -->|"loads snapshot rules"| node_snapshot
node_topics -->|"matches topic rules"| node_snapshot
node_context -->|"filters corpus rows"| node_snapshot
node_context -->|"provides vectors"| node_index
node_snapshot -->|"selects index rows"| node_index
node_researcher -->|"submits query"| node_retrieve
node_retrieve -->|"loads corpus context"| node_context
node_retrieve -->|"resolves snapshot"| node_snapshot
node_retrieve -->|"searches vectors"| node_index
node_researcher -->|"asks question"| node_ask
node_ask -->|"gets evidence"| node_retrieve
node_ask -->|"requests answer"| node_rag
node_rag -->|"completes prompt"| node_llm
node_llm -->|"sends request"| node_model_service
node_researcher -->|"starts experiment"| node_ablate
node_ablate -->|"loads corpus context"| node_context
node_ablate -->|"selects snapshots"| node_snapshot
node_ablate -->|"retrieves evidence"| node_retrieve
node_ablate -->|"generates answers"| node_rag
node_ablate -->|"prices calls"| node_plan
node_ablate -->|"writes run data"| node_results
node_researcher -->|"audits questions"| node_audit
node_audit -->|"checks retrieval"| node_retrieve
node_researcher -->|"requests report"| node_report
node_report -->|"reads run data"| node_results
node_report -->|"computes measures"| node_metrics
node_researcher -->|"judges run"| node_judge
node_judge -->|"reads answers"| node_results
node_judge -->|"requests judgments"| node_llm
node_judge -->|"adds judge section"| node_report
node_researcher -->|"compares runs"| node_compare
node_compare -->|"compares measures"| node_metrics
node_compare -->|"uses report output"| node_report

click node_ingest "https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/ingest.py"
click node_corpus_store "https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/data.py"
click node_embed "https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/embed.py"
click node_config "https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/config.py"
click node_topics "https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/topics.py"
click node_snapshot "https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/snapshot.py"
click node_context "https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/data.py"
click node_index "https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/index.py"
click node_retrieve "https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/retrieve.py"
click node_rag "https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/rag.py"
click node_llm "https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/llm.py"
click node_plan "https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/plan.py"
click node_ablate "https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/ablate.py"
click node_results "https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/paths.py"
click node_ask "https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/ask.py"
click node_audit "https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/audit.py"
click node_metrics "https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/metrics.py"
click node_judge "https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/judge.py"
click node_report "https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/report.py"
click node_compare "https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/compare.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_ingest,node_corpus_store,node_embed,node_config toneBlue
class node_topics,node_snapshot,node_context,node_index,node_retrieve,node_kaggle toneAmber
class node_rag,node_llm,node_plan,node_ablate,node_results,node_ask toneMint
class node_audit,node_metrics,node_judge,node_report,node_compare toneRose
class node_researcher,node_model_service toneIndigo
```

## Components

### Corpus preparation

- [Corpus ingestion](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/ingest.py): `src/rageblate/ingest.py`
- [Immutable corpus](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/data.py): `src/rageblate/data.py`
- [Document embeddings](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/embed.py): `src/rageblate/embed.py`
- [Configuration loading](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/config.py): `src/rageblate/config.py`

### Snapshot retrieval

- [Topic rules](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/topics.py): `src/rageblate/topics.py`
- [Corpus snapshots](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/snapshot.py): `src/rageblate/snapshot.py`
- [Loaded corpus context](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/data.py): `src/rageblate/data.py`
- [Exact search index](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/index.py): `src/rageblate/index.py`
- [Top-k retrieval](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/retrieve.py): `src/rageblate/retrieve.py`

### Experiment execution

- [Answer prompting](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/rag.py): `src/rageblate/rag.py`
- [Cached model clients](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/llm.py): `src/rageblate/llm.py`
- [Call planning](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/plan.py): `src/rageblate/plan.py`
- [Ablation runner](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/ablate.py): `src/rageblate/ablate.py`
- [Run results](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/paths.py): `src/rageblate/paths.py`
- [Single-question answering](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/ask.py): `src/rageblate/ask.py`

### Evaluation and reporting

- [Question audit](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/audit.py): `src/rageblate/audit.py`
- [Experiment metrics](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/metrics.py): `src/rageblate/metrics.py`
- [Answer quality judge](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/judge.py): `src/rageblate/judge.py`
- [Run reports](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/report.py): `src/rageblate/report.py`
- [Run comparison](https://github.com/tung-phan-dinh/aixiv-rag/blob/main/src/rageblate/compare.py): `src/rageblate/compare.py`

### Other components

- **Researcher**
- **Kaggle arXiv dump**
- **OpenAI or Ollama**

## Connections

- Researcher → Corpus ingestion: starts ingestion (evidence: `README.md`)
- Kaggle arXiv dump → Corpus ingestion: provides dump (evidence: `README.md`)
- Corpus ingestion → Immutable corpus: writes corpus (evidence: `README.md`)
- Immutable corpus → Document embeddings: supplies documents (evidence: `README.md`)
- Document embeddings → Loaded corpus context: produces vectors (evidence: `README.md`)
- Immutable corpus → Loaded corpus context: loads rows (evidence: `src/rageblate/data.py`)
- Configuration loading → Corpus snapshots: loads snapshot rules (evidence: `src/rageblate/snapshot.py`)
- Topic rules → Corpus snapshots: matches topic rules (evidence: `src/rageblate/snapshot.py`)
- Loaded corpus context → Corpus snapshots: filters corpus rows (evidence: `README.md`)
- Loaded corpus context → Exact search index: provides vectors (evidence: `src/rageblate/index.py`)
- Corpus snapshots → Exact search index: selects index rows (evidence: `src/rageblate/index.py`)
- Researcher → Top-k retrieval: submits query (evidence: `README.md`)
- Top-k retrieval → Loaded corpus context: loads corpus context (evidence: `src/rageblate/retrieve.py`)
- Top-k retrieval → Corpus snapshots: resolves snapshot (evidence: `src/rageblate/retrieve.py`)
- Top-k retrieval → Exact search index: searches vectors (evidence: `src/rageblate/retrieve.py`)
- Researcher → Single-question answering: asks question (evidence: `README.md`)
- Single-question answering → Top-k retrieval: gets evidence (evidence: `src/rageblate/ask.py`)
- Single-question answering → Answer prompting: requests answer (evidence: `src/rageblate/ask.py`)
- Answer prompting → Cached model clients: completes prompt (evidence: `src/rageblate/rag.py`)
- Cached model clients → OpenAI or Ollama: sends request (evidence: `src/rageblate/llm.py`)
- Researcher → Ablation runner: starts experiment (evidence: `README.md`)
- Ablation runner → Loaded corpus context: loads corpus context (evidence: `src/rageblate/ablate.py`)
- Ablation runner → Corpus snapshots: selects snapshots (evidence: `src/rageblate/ablate.py`)
- Ablation runner → Top-k retrieval: retrieves evidence (evidence: `README.md`)
- Ablation runner → Answer prompting: generates answers (evidence: `src/rageblate/ablate.py`)
- Ablation runner → Call planning: prices calls (evidence: `src/rageblate/ablate.py`)
- Ablation runner → Run results: writes run data (evidence: `README.md`)
- Researcher → Question audit: audits questions (evidence: `README.md`)
- Question audit → Top-k retrieval: checks retrieval (evidence: `src/rageblate/audit.py`)
- Researcher → Run reports: requests report (evidence: `README.md`)
- Run reports → Run results: reads run data (evidence: `README.md`)
- Run reports → Experiment metrics: computes measures (evidence: `src/rageblate/report.py`)
- Researcher → Answer quality judge: judges run (evidence: `README.md`)
- Answer quality judge → Run results: reads answers (evidence: `README.md`)
- Answer quality judge → Cached model clients: requests judgments (evidence: `src/rageblate/judge.py`)
- Answer quality judge → Run reports: adds judge section (evidence: `src/rageblate/judge.py`)
- Researcher → Run comparison: compares runs (evidence: `README.md`)
- Run comparison → Experiment metrics: compares measures (evidence: `src/rageblate/compare.py`)
- Run comparison → Run reports: uses report output (evidence: `src/rageblate/compare.py`)
