# xing-kj/hipporag2 architecture

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

- Interactive diagram: https://gitdiagram.com/xing-kj/hipporag2
- Repository: https://github.com/xing-kj/hipporag2

## Overview

HippoRAG 2 is an LLM memory framework: users index documents, then retrieve relevant passages and generate answers, with retrieval and QA also available separately. Indexing extracts entities and triples to build a graph; retrieval links queries to graph nodes, propagates scores, and ranks passages. The README also documents OpenAI and local vLLM deployments and evaluation. Source excerpts are partial, so edges for unsampled runtime details are limited to relationships named by the SOURCE INDEX or README.

Main entry points: [`src/hipporag/HippoRAG.py`](https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/HippoRAG.py) (HippoRAG API), [`src/hipporag/llm/openai_gpt.py`](https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/llm/openai_gpt.py) (OpenAI LLM), [`src/hipporag/information_extraction/openie_vllm_offline.py`](https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/information_extraction/openie_vllm_offline.py) (Offline OpenIE), [`src/hipporag/evaluation/base.py`](https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/evaluation/base.py) (Evaluation interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Memory orchestration"]
  node_hipporag["HippoRAG API<br/>[HippoRAG.py]"]
  node_openie["OpenIE extraction<br/>[openie_openai.py]"]
  node_offline_openie["Offline OpenIE"]
  node_graph_store[("Graph and embeddings<br/>[embedding_store.py]")]
  node_config["Runtime configuration<br/>[config_utils.py]"]
  node_misc_utils["Graph utilities<br/>[misc_utils.py]"]
  node_logging["Logging<br/>[logging_utils.py]"]
end

subgraph group_models["Model integrations"]
  node_embedding_base["Embedding interface<br/>[base.py]"]
  node_embedding_models["Embedding backends"]
  node_llm_base["LLM interface<br/>[base.py]"]
  node_openai_llm["OpenAI LLM<br/>[openai_gpt.py]"]
  node_vllm["Offline vLLM<br/>[vllm_offline.py]"]
  node_llm_utils["LLM utilities<br/>[llm_utils.py]"]
end

subgraph group_prompts["Prompt and ranking"]
  node_prompt_manager["Template manager"]
  node_prompt_templates["Task templates"]
  node_rerank["Passage reranking<br/>[rerank.py]"]
  node_filter_prompt["Rerank prompt"]
end

subgraph group_eval["Evaluation"]
  node_evaluation["Evaluation interface<br/>[base.py]"]
  node_qa_eval["QA evaluation<br/>[qa_eval.py]"]
  node_retrieval_eval["Retrieval evaluation<br/>[retrieval_eval.py]"]
  node_eval_utils["Evaluation utilities<br/>[eval_utils.py]"]
end

node_user(("User"))
node_external_llm{{"LLM service"}}

node_user -->|"indexes and queries"| node_hipporag
node_hipporag -->|"extracts triples"| node_openie
node_hipporag -->|"selects extractor"| node_offline_openie
node_hipporag -->|"stores graph data"| node_graph_store
node_hipporag -->|"encodes text"| node_embedding_models
node_embedding_models -->|"implements"| node_embedding_base
node_hipporag -->|"reranks passages"| node_rerank
node_rerank -->|"uses prompt"| node_filter_prompt
node_hipporag -->|"renders prompts"| node_prompt_manager
node_prompt_manager -->|"loads templates"| node_prompt_templates
node_offline_openie -->|"renders prompts"| node_prompt_manager
node_offline_openie -->|"runs extraction"| node_vllm
node_openie -->|"requests inference"| node_openai_llm
node_openai_llm -->|"implements"| node_llm_base
node_vllm -->|"implements"| node_llm_base
node_openai_llm -.->|"calls model"| node_external_llm
node_hipporag -->|"configures runtime"| node_config
node_hipporag -->|"evaluates results"| node_evaluation
node_evaluation -->|"supports QA"| node_qa_eval
node_evaluation -->|"supports retrieval"| node_retrieval_eval
node_qa_eval -->|"uses metrics"| node_eval_utils
node_retrieval_eval -->|"uses metrics"| node_eval_utils
node_openai_llm -->|"uses helpers"| node_llm_utils
node_hipporag -->|"uses graph helpers"| node_misc_utils
node_hipporag -->|"logs operations"| node_logging

click node_hipporag "https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/HippoRAG.py"
click node_openie "https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/information_extraction/openie_openai.py"
click node_offline_openie "https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/information_extraction/openie_vllm_offline.py"
click node_graph_store "https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/embedding_store.py"
click node_config "https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/utils/config_utils.py"
click node_embedding_base "https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/embedding_model/base.py"
click node_embedding_models "https://github.com/xing-kj/hipporag2/tree/main/src/hipporag/embedding_model"
click node_llm_base "https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/llm/base.py"
click node_openai_llm "https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/llm/openai_gpt.py"
click node_vllm "https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/llm/vllm_offline.py"
click node_prompt_manager "https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/prompts/prompt_template_manager.py"
click node_prompt_templates "https://github.com/xing-kj/hipporag2/tree/main/src/hipporag/prompts/templates"
click node_rerank "https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/rerank.py"
click node_filter_prompt "https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/prompts/filter_default_prompt.py"
click node_evaluation "https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/evaluation/base.py"
click node_qa_eval "https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/evaluation/qa_eval.py"
click node_retrieval_eval "https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/evaluation/retrieval_eval.py"
click node_eval_utils "https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/utils/eval_utils.py"
click node_llm_utils "https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/utils/llm_utils.py"
click node_misc_utils "https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/utils/misc_utils.py"
click node_logging "https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/utils/logging_utils.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_hipporag,node_openie,node_offline_openie,node_graph_store,node_config,node_misc_utils,node_logging,node_user toneBlue
class node_embedding_base,node_embedding_models,node_llm_base,node_openai_llm,node_vllm,node_llm_utils toneAmber
class node_prompt_manager,node_prompt_templates,node_rerank,node_filter_prompt toneMint
class node_evaluation,node_qa_eval,node_retrieval_eval,node_eval_utils toneRose
class node_external_llm toneIndigo
```

## Components

### Memory orchestration

- [HippoRAG API](https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/HippoRAG.py): `src/hipporag/HippoRAG.py`
- [OpenIE extraction](https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/information_extraction/openie_openai.py): `src/hipporag/information_extraction/openie_openai.py`
- [Offline OpenIE](https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/information_extraction/openie_vllm_offline.py): `src/hipporag/information_extraction/openie_vllm_offline.py`
- [Graph and embeddings](https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/embedding_store.py): `src/hipporag/embedding_store.py`
- [Runtime configuration](https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/utils/config_utils.py): `src/hipporag/utils/config_utils.py`
- [Graph utilities](https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/utils/misc_utils.py): `src/hipporag/utils/misc_utils.py`
- [Logging](https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/utils/logging_utils.py): `src/hipporag/utils/logging_utils.py`

### Model integrations

- [Embedding interface](https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/embedding_model/base.py): `src/hipporag/embedding_model/base.py`
- [Embedding backends](https://github.com/xing-kj/hipporag2/tree/main/src/hipporag/embedding_model): `src/hipporag/embedding_model`
- [LLM interface](https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/llm/base.py): `src/hipporag/llm/base.py`
- [OpenAI LLM](https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/llm/openai_gpt.py): `src/hipporag/llm/openai_gpt.py`
- [Offline vLLM](https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/llm/vllm_offline.py): `src/hipporag/llm/vllm_offline.py`
- [LLM utilities](https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/utils/llm_utils.py): `src/hipporag/utils/llm_utils.py`

### Prompt and ranking

- [Template manager](https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/prompts/prompt_template_manager.py): `src/hipporag/prompts/prompt_template_manager.py`
- [Task templates](https://github.com/xing-kj/hipporag2/tree/main/src/hipporag/prompts/templates): `src/hipporag/prompts/templates`
- [Passage reranking](https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/rerank.py): `src/hipporag/rerank.py`
- [Rerank prompt](https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/prompts/filter_default_prompt.py): `src/hipporag/prompts/filter_default_prompt.py`

### Evaluation

- [Evaluation interface](https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/evaluation/base.py): `src/hipporag/evaluation/base.py`
- [QA evaluation](https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/evaluation/qa_eval.py): `src/hipporag/evaluation/qa_eval.py`
- [Retrieval evaluation](https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/evaluation/retrieval_eval.py): `src/hipporag/evaluation/retrieval_eval.py`
- [Evaluation utilities](https://github.com/xing-kj/hipporag2/blob/main/src/hipporag/utils/eval_utils.py): `src/hipporag/utils/eval_utils.py`

### Other components

- **User**
- **LLM service**

## Connections

- User → HippoRAG API: indexes and queries
- HippoRAG API → OpenIE extraction: extracts triples (evidence: `src/hipporag/HippoRAG.py`)
- HippoRAG API → Offline OpenIE: selects extractor (evidence: `src/hipporag/HippoRAG.py`)
- HippoRAG API → Graph and embeddings: stores graph data (evidence: `src/hipporag/HippoRAG.py`)
- HippoRAG API → Embedding backends: encodes text (evidence: `src/hipporag/HippoRAG.py`)
- Embedding backends → Embedding interface: implements (evidence: `src/hipporag/embedding_model/APIEmbedding.py`)
- HippoRAG API → Passage reranking: reranks passages (evidence: `src/hipporag/HippoRAG.py`)
- Passage reranking → Rerank prompt: uses prompt (evidence: `src/hipporag/rerank.py`)
- HippoRAG API → Template manager: renders prompts (evidence: `src/hipporag/HippoRAG.py`)
- Template manager → Task templates: loads templates (evidence: `src/hipporag/prompts/prompt_template_manager.py`)
- Offline OpenIE → Template manager: renders prompts (evidence: `src/hipporag/information_extraction/openie_vllm_offline.py`)
- Offline OpenIE → Offline vLLM: runs extraction (evidence: `src/hipporag/information_extraction/openie_vllm_offline.py`)
- OpenIE extraction → OpenAI LLM: requests inference (evidence: `src/hipporag/information_extraction/openie_openai.py`)
- OpenAI LLM → LLM interface: implements (evidence: `src/hipporag/llm/openai_gpt.py`)
- Offline vLLM → LLM interface: implements (evidence: `src/hipporag/llm/vllm_offline.py`)
- OpenAI LLM → LLM service: calls model
- HippoRAG API → Runtime configuration: configures runtime (evidence: `src/hipporag/HippoRAG.py`)
- HippoRAG API → Evaluation interface: evaluates results (evidence: `src/hipporag/HippoRAG.py`)
- Evaluation interface → QA evaluation: supports QA (evidence: `src/hipporag/evaluation/qa_eval.py`)
- Evaluation interface → Retrieval evaluation: supports retrieval (evidence: `src/hipporag/evaluation/retrieval_eval.py`)
- QA evaluation → Evaluation utilities: uses metrics (evidence: `src/hipporag/evaluation/qa_eval.py`)
- Retrieval evaluation → Evaluation utilities: uses metrics (evidence: `src/hipporag/evaluation/retrieval_eval.py`)
- OpenAI LLM → LLM utilities: uses helpers (evidence: `src/hipporag/llm/openai_gpt.py`)
- HippoRAG API → Graph utilities: uses graph helpers (evidence: `src/hipporag/HippoRAG.py`)
- HippoRAG API → Logging: logs operations (evidence: `src/hipporag/HippoRAG.py`)
