# mims-harvard/ark architecture

> Architecture diagram of the GitHub repository mims-harvard/ark, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mims-harvard/ark
- Repository: https://github.com/mims-harvard/ark

## Overview

ARK is an agentic knowledge-graph retriever: a question is explored through model-selected global search and neighborhood traversal, then candidate entities are collected and returned. The repository also includes graph preprocessing, benchmark evaluation, and optional trajectory distillation and fine-tuned model serving. Runtime links are based on excerpts or the source index; broader capability links use README documentation where source details were not sampled.

Main entry points: [`src/core/graph.py`](https://github.com/mims-harvard/ark/blob/main/src/core/graph.py) (Knowledge graph), [`main.py`](https://github.com/mims-harvard/ark/blob/main/main.py) (Experiment runner), [`src/agents/graph_explorer/graph_explorer.py`](https://github.com/mims-harvard/ark/blob/main/src/agents/graph_explorer/graph_explorer.py) (Explorer agent), [`utils.py`](https://github.com/mims-harvard/ark/blob/main/utils.py) (Model selection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_retrieval["Adaptive retrieval"]
  node_runner["Experiment runner<br/>[main.py]"]
  node_explorer["Explorer agent<br/>[graph_explorer.py]"]
  node_global["Global search<br/>[search_in_graph.py]"]
  node_neighbor["Neighborhood search"]
  node_connections["Connection search"]
  node_answers["Answer selection<br/>[add_to_answers.py]"]
  node_finish["Finish exploration<br/>[finish.py]"]
  node_toolbase["Tool interface<br/>[tool.py]"]
end

subgraph group_graph["Graph and search"]
  node_graphstore[("Knowledge graph<br/>[graph.py]")]
  node_bm25[("Lexical index<br/>[index.py]")]
  node_embedding[("Embedding index<br/>[embedding_index.py]")]
  node_node["Graph entities<br/>[node.py]"]
end

subgraph group_models["Language models"]
  node_modelselect["Model selection<br/>[utils.py]"]
  node_litellm["LiteLLM model<br/>[LiteLLMModel.py]"]
  node_qwen["Qwen model<br/>[QwenModel.py]"]
  node_transformers["Transformers model"]
  node_finetuned["Fine-tuned Qwen"]
  node_vllmqwen["VLLM Qwen<br/>[VLLMQwenModel.py]"]
end

subgraph group_data["Benchmark data"]
  node_preprocess["Graph preprocessing<br/>[summary_utils.py]"]
  node_benchmark[("STaRK datasets")]
  node_evaluation["Result evaluation<br/>[eval.py]"]
end

subgraph group_distill["Distillation and serving"]
  node_trajectory["Training trajectories<br/>[utils.py]"]
  node_finetune["Policy fine-tuning"]
  node_config["Training configuration<br/>[config.py]"]
  node_server["VLLM server<br/>[VLLMServer.py]"]
end

node_user(("Questioner"))

node_user -->|"submits query"| node_runner
node_runner -->|"starts agents"| node_explorer
node_runner -->|"loads graph"| node_graphstore
node_runner -->|"loads model"| node_modelselect
node_explorer -->|"requests decisions"| node_modelselect
node_modelselect -->|"selects model"| node_litellm
node_modelselect -->|"selects model"| node_qwen
node_modelselect -->|"selects model"| node_vllmqwen
node_modelselect -->|"selects model"| node_finetuned
node_explorer -->|"dispatches tools"| node_global
node_explorer -->|"dispatches tools"| node_neighbor
node_explorer -->|"dispatches tools"| node_answers
node_explorer -->|"dispatches tools"| node_finish
node_explorer -->|"uses interface"| node_toolbase
node_global -->|"searches nodes"| node_graphstore
node_neighbor -->|"expands neighborhood"| node_graphstore
node_connections -->|"finds paths"| node_graphstore
node_graphstore -->|"uses lexical index"| node_bm25
node_graphstore -->|"uses embeddings"| node_embedding
node_bm25 -->|"returns entities"| node_node
node_graphstore -->|"loads entities"| node_node
node_answers -->|"selects entities"| node_graphstore
node_benchmark -->|"converts data"| node_preprocess
node_preprocess -->|"provides graph files"| node_graphstore
node_runner -->|"runs benchmark queries"| node_benchmark
node_runner -->|"evaluates results"| node_evaluation
node_runner -->|"records trajectories"| node_trajectory
node_trajectory -->|"trains policy"| node_finetune
node_finetune -->|"reads settings"| node_config
node_finetune -.->|"produces adapter"| node_finetuned
node_server -.->|"serves model"| node_vllmqwen
node_finetuned -->|"supports retrieval"| node_runner

click node_runner "https://github.com/mims-harvard/ark/blob/main/main.py"
click node_explorer "https://github.com/mims-harvard/ark/blob/main/src/agents/graph_explorer/graph_explorer.py"
click node_global "https://github.com/mims-harvard/ark/blob/main/src/agents/graph_explorer/tools/search_in_graph.py"
click node_neighbor "https://github.com/mims-harvard/ark/blob/main/src/agents/graph_explorer/tools/search_in_neighborhood.py"
click node_connections "https://github.com/mims-harvard/ark/blob/main/src/agents/graph_explorer/tools/find_connections.py"
click node_answers "https://github.com/mims-harvard/ark/blob/main/src/agents/graph_explorer/tools/add_to_answers.py"
click node_finish "https://github.com/mims-harvard/ark/blob/main/src/agents/graph_explorer/tools/finish.py"
click node_graphstore "https://github.com/mims-harvard/ark/blob/main/src/core/graph.py"
click node_bm25 "https://github.com/mims-harvard/ark/blob/main/src/core/index.py"
click node_embedding "https://github.com/mims-harvard/ark/blob/main/src/core/embedding_index.py"
click node_node "https://github.com/mims-harvard/ark/blob/main/src/core/node.py"
click node_toolbase "https://github.com/mims-harvard/ark/blob/main/src/agents/graph_explorer/tools/tool.py"
click node_modelselect "https://github.com/mims-harvard/ark/blob/main/utils.py"
click node_litellm "https://github.com/mims-harvard/ark/blob/main/src/models/LiteLLMModel.py"
click node_qwen "https://github.com/mims-harvard/ark/blob/main/src/models/QwenModel.py"
click node_transformers "https://github.com/mims-harvard/ark/blob/main/src/models/TransformersModel.py"
click node_finetuned "https://github.com/mims-harvard/ark/blob/main/src/models/FineTunedQwenModel.py"
click node_vllmqwen "https://github.com/mims-harvard/ark/blob/main/src/models/VLLMQwenModel.py"
click node_preprocess "https://github.com/mims-harvard/ark/blob/main/preprocessing/summary_utils.py"
click node_benchmark "https://github.com/mims-harvard/ark/tree/main/preprocessing"
click node_evaluation "https://github.com/mims-harvard/ark/blob/main/eval.py"
click node_trajectory "https://github.com/mims-harvard/ark/blob/main/fine_tuning/utils.py"
click node_finetune "https://github.com/mims-harvard/ark/blob/main/fine_tuning/graph_fine_tuning.py"
click node_config "https://github.com/mims-harvard/ark/blob/main/fine_tuning/config.py"
click node_server "https://github.com/mims-harvard/ark/blob/main/src/servers/VLLMServer.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_runner,node_explorer,node_global,node_neighbor,node_connections,node_answers,node_finish,node_toolbase toneBlue
class node_graphstore,node_bm25,node_embedding,node_node toneAmber
class node_modelselect,node_litellm,node_qwen,node_transformers,node_finetuned,node_vllmqwen toneMint
class node_preprocess,node_benchmark,node_evaluation toneRose
class node_trajectory,node_finetune,node_config,node_server,node_user toneIndigo
```

## Components

### Adaptive retrieval

- [Experiment runner](https://github.com/mims-harvard/ark/blob/main/main.py): `main.py`
- [Explorer agent](https://github.com/mims-harvard/ark/blob/main/src/agents/graph_explorer/graph_explorer.py): `src/agents/graph_explorer/graph_explorer.py`
- [Global search](https://github.com/mims-harvard/ark/blob/main/src/agents/graph_explorer/tools/search_in_graph.py): `src/agents/graph_explorer/tools/search_in_graph.py`
- [Neighborhood search](https://github.com/mims-harvard/ark/blob/main/src/agents/graph_explorer/tools/search_in_neighborhood.py): `src/agents/graph_explorer/tools/search_in_neighborhood.py`
- [Connection search](https://github.com/mims-harvard/ark/blob/main/src/agents/graph_explorer/tools/find_connections.py): `src/agents/graph_explorer/tools/find_connections.py`
- [Answer selection](https://github.com/mims-harvard/ark/blob/main/src/agents/graph_explorer/tools/add_to_answers.py): `src/agents/graph_explorer/tools/add_to_answers.py`
- [Finish exploration](https://github.com/mims-harvard/ark/blob/main/src/agents/graph_explorer/tools/finish.py): `src/agents/graph_explorer/tools/finish.py`
- [Tool interface](https://github.com/mims-harvard/ark/blob/main/src/agents/graph_explorer/tools/tool.py): `src/agents/graph_explorer/tools/tool.py`

### Graph and search

- [Knowledge graph](https://github.com/mims-harvard/ark/blob/main/src/core/graph.py): `src/core/graph.py`
- [Lexical index](https://github.com/mims-harvard/ark/blob/main/src/core/index.py): `src/core/index.py`
- [Embedding index](https://github.com/mims-harvard/ark/blob/main/src/core/embedding_index.py): `src/core/embedding_index.py`
- [Graph entities](https://github.com/mims-harvard/ark/blob/main/src/core/node.py): `src/core/node.py`

### Language models

- [Model selection](https://github.com/mims-harvard/ark/blob/main/utils.py): `utils.py`
- [LiteLLM model](https://github.com/mims-harvard/ark/blob/main/src/models/LiteLLMModel.py): `src/models/LiteLLMModel.py`
- [Qwen model](https://github.com/mims-harvard/ark/blob/main/src/models/QwenModel.py): `src/models/QwenModel.py`
- [Transformers model](https://github.com/mims-harvard/ark/blob/main/src/models/TransformersModel.py): `src/models/TransformersModel.py`
- [Fine-tuned Qwen](https://github.com/mims-harvard/ark/blob/main/src/models/FineTunedQwenModel.py): `src/models/FineTunedQwenModel.py`
- [VLLM Qwen](https://github.com/mims-harvard/ark/blob/main/src/models/VLLMQwenModel.py): `src/models/VLLMQwenModel.py`

### Benchmark data

- [Graph preprocessing](https://github.com/mims-harvard/ark/blob/main/preprocessing/summary_utils.py): `preprocessing/summary_utils.py`
- [STaRK datasets](https://github.com/mims-harvard/ark/tree/main/preprocessing): `preprocessing`
- [Result evaluation](https://github.com/mims-harvard/ark/blob/main/eval.py): `eval.py`

### Distillation and serving

- [Training trajectories](https://github.com/mims-harvard/ark/blob/main/fine_tuning/utils.py): `fine_tuning/utils.py`
- [Policy fine-tuning](https://github.com/mims-harvard/ark/blob/main/fine_tuning/graph_fine_tuning.py): `fine_tuning/graph_fine_tuning.py`
- [Training configuration](https://github.com/mims-harvard/ark/blob/main/fine_tuning/config.py): `fine_tuning/config.py`
- [VLLM server](https://github.com/mims-harvard/ark/blob/main/src/servers/VLLMServer.py): `src/servers/VLLMServer.py`

### Other components

- **Questioner**

## Connections

- Questioner → Experiment runner: submits query (evidence: `README.md`)
- Experiment runner → Explorer agent: starts agents (evidence: `main.py`)
- Experiment runner → Knowledge graph: loads graph
- Experiment runner → Model selection: loads model (evidence: `utils.py`)
- Explorer agent → Model selection: requests decisions (evidence: `src/agents/graph_explorer/graph_explorer.py`)
- Model selection → LiteLLM model: selects model (evidence: `utils.py`)
- Model selection → Qwen model: selects model (evidence: `utils.py`)
- Model selection → VLLM Qwen: selects model (evidence: `utils.py`)
- Model selection → Fine-tuned Qwen: selects model (evidence: `utils.py`)
- Explorer agent → Global search: dispatches tools (evidence: `src/agents/graph_explorer/graph_explorer.py`)
- Explorer agent → Neighborhood search: dispatches tools (evidence: `src/agents/graph_explorer/graph_explorer.py`)
- Explorer agent → Answer selection: dispatches tools (evidence: `src/agents/graph_explorer/graph_explorer.py`)
- Explorer agent → Finish exploration: dispatches tools (evidence: `src/agents/graph_explorer/graph_explorer.py`)
- Explorer agent → Tool interface: uses interface (evidence: `src/agents/graph_explorer/graph_explorer.py`)
- Global search → Knowledge graph: searches nodes (evidence: `src/agents/graph_explorer/tools/search_in_graph.py`)
- Neighborhood search → Knowledge graph: expands neighborhood (evidence: `src/agents/graph_explorer/tools/search_in_neighborhood.py`)
- Connection search → Knowledge graph: finds paths (evidence: `src/agents/graph_explorer/tools/find_connections.py`)
- Knowledge graph → Lexical index: uses lexical index (evidence: `src/core/graph.py`)
- Knowledge graph → Embedding index: uses embeddings (evidence: `src/core/graph.py`)
- Lexical index → Graph entities: returns entities (evidence: `src/core/index.py`)
- Knowledge graph → Graph entities: loads entities (evidence: `src/core/graph.py`)
- Answer selection → Knowledge graph: selects entities (evidence: `src/agents/graph_explorer/graph_explorer.py`)
- STaRK datasets → Graph preprocessing: converts data (evidence: `README.md`)
- Graph preprocessing → Knowledge graph: provides graph files (evidence: `README.md`)
- Experiment runner → STaRK datasets: runs benchmark queries (evidence: `README.md`)
- Experiment runner → Result evaluation: evaluates results (evidence: `README.md`)
- Experiment runner → Training trajectories: records trajectories (evidence: `README.md`)
- Training trajectories → Policy fine-tuning: trains policy (evidence: `fine_tuning/graph_fine_tuning.py`)
- Policy fine-tuning → Training configuration: reads settings (evidence: `fine_tuning/graph_fine_tuning.py`)
- Policy fine-tuning → Fine-tuned Qwen: produces adapter (evidence: `README.md`)
- VLLM server → VLLM Qwen: serves model (evidence: `README.md`)
- Fine-tuned Qwen → Experiment runner: supports retrieval (evidence: `README.md`)
