# hkust-knowcomp/autoschemakg architecture

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

- Interactive diagram: https://gitdiagram.com/hkust-knowcomp/autoschemakg
- Repository: https://github.com/hkust-knowcomp/autoschemakg

## Overview

AutoSchemaKG constructs knowledge graphs from unstructured text, induces conceptual schemas, and supports graph hosting, retrieval-augmented multi-hop QA, and evaluation. Its main workflow extracts triples, converts and conceptualizes them into graph-ready data, then supports indexing and retrieval. The graph also preserves the documented quality, factuality, and general-task evaluation branches. Several internal links are grounded in the README and source index; unsampled implementation details are not inferred as direct calls.

Main entry points: [`atlas_rag/kg_construction/triple_extraction.py`](https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/kg_construction/triple_extraction.py) (Triple extractor), [`atlas_mutihopqa.py`](https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_mutihopqa.py) (Multi-hop QA), [`atlas_rag/retriever/hipporag.py`](https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/retriever/hipporag.py) (HippoRAG retrieval), [`atlas_rag/retriever/hipporag2.py`](https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/retriever/hipporag2.py) (HippoRAG2 retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_construction["KG Construction"]
  node_config["Processing config<br/>[triple_config.py]"]
  node_extractor["Triple extractor"]
  node_json_csv["JSON to CSV<br/>[json_to_csv.py]"]
  node_concepts["Concept generation"]
  node_concept_csv["Concept CSV<br/>[concept_to_csv.py]"]
  node_graphml["GraphML conversion<br/>[csv_to_graphml.py]"]
end

subgraph group_generation["LLM Generation"]
  node_triple_prompt["Extraction prompts"]
  node_generator["LLM generator<br/>[llm_generator.py]"]
  node_generation_config["Generation config"]
  node_schema_validation["Schema validation"]
end

subgraph group_storage["Graph and Index"]
  node_neo4j[("Neo4j API<br/>[neo4j_api.py]")]
  node_embedding["Embedding models<br/>[embedding_model.py]"]
  node_graph_index["Graph index"]
  node_neo4j_index["Neo4j index"]
end

subgraph group_retrieval["Retrieval and QA"]
  node_retriever_base["Retriever interface<br/>[base.py]"]
  node_hipporag["HippoRAG retrieval<br/>[hipporag.py]"]
  node_hipporag2["HippoRAG2 retrieval<br/>[hipporag2.py]"]
  node_tog["ToG retrieval<br/>[tog.py]"]
  node_qa["Multi-hop QA<br/>[atlas_mutihopqa.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_kg_eval["KG quality evaluation"]
  node_factuality["Factuality evaluation<br/>[eval.py]"]
  node_general_eval["General task evaluation<br/>[evaluator.py]"]
end

node_user(("KG builder"))

node_user -->|"runs extraction"| node_extractor
node_config -->|"configures"| node_extractor
node_extractor -->|"generates triples"| node_generator
node_extractor -->|"uses prompts"| node_triple_prompt
node_extractor -->|"validates output"| node_schema_validation
node_generator -->|"uses settings"| node_generation_config
node_extractor -->|"converts triples"| node_json_csv
node_extractor -->|"starts conceptualization"| node_concepts
node_concepts -->|"creates concept CSV"| node_concept_csv
node_concepts -->|"converts graph data"| node_graphml
node_extractor -->|"exports graph"| node_graphml
node_extractor -->|"creates index"| node_neo4j_index
node_graph_index -->|"embeds graph data"| node_embedding
node_neo4j_index -.->|"indexes in Neo4j"| node_neo4j
node_qa -->|"loads graph index"| node_graph_index
node_qa -.->|"retrieves context"| node_hipporag
node_qa -.->|"retrieves context"| node_hipporag2
node_qa -.->|"supports ToG retrieval"| node_tog
node_hipporag -->|"encodes queries"| node_embedding
node_hipporag2 -->|"encodes queries"| node_embedding
node_hipporag -->|"generates responses"| node_generator
node_hipporag2 -->|"generates responses"| node_generator
node_hipporag -->|"implements interface"| node_retriever_base
node_hipporag2 -->|"implements interface"| node_retriever_base
node_user -->|"evaluates graph"| node_kg_eval
node_user -->|"evaluates factuality"| node_factuality
node_user -->|"evaluates tasks"| node_general_eval

click node_config "https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/kg_construction/triple_config.py"
click node_extractor "https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/kg_construction/triple_extraction.py"
click node_triple_prompt "https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/llm_generator/prompt/triple_extraction_prompt.py"
click node_generator "https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/llm_generator/llm_generator.py"
click node_generation_config "https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/llm_generator/generation_config.py"
click node_schema_validation "https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/llm_generator/format/validate_json_schema.py"
click node_json_csv "https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/kg_construction/utils/json_processing/json_to_csv.py"
click node_concepts "https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/kg_construction/concept_generation.py"
click node_concept_csv "https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/kg_construction/concept_to_csv.py"
click node_graphml "https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/kg_construction/utils/csv_processing/csv_to_graphml.py"
click node_neo4j "https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/kg_construction/neo4j/neo4j_api.py"
click node_embedding "https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/vectorstore/embedding_model.py"
click node_graph_index "https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/vectorstore/create_graph_index.py"
click node_neo4j_index "https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/vectorstore/create_neo4j_index.py"
click node_retriever_base "https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/retriever/base.py"
click node_hipporag "https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/retriever/hipporag.py"
click node_hipporag2 "https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/retriever/hipporag2.py"
click node_tog "https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/retriever/tog.py"
click node_qa "https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_mutihopqa.py"
click node_kg_eval "https://github.com/hkust-knowcomp/autoschemakg/tree/main/EvaluateKGC"
click node_factuality "https://github.com/hkust-knowcomp/autoschemakg/blob/main/EvaluateFactuality/eval.py"
click node_general_eval "https://github.com/hkust-knowcomp/autoschemakg/blob/main/EvaluateGeneralTask/lm-evaluation-harness/lm_eval/evaluator.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_config,node_extractor,node_json_csv,node_concepts,node_concept_csv,node_graphml toneBlue
class node_triple_prompt,node_generator,node_generation_config,node_schema_validation toneAmber
class node_neo4j,node_embedding,node_graph_index,node_neo4j_index toneMint
class node_retriever_base,node_hipporag,node_hipporag2,node_tog,node_qa toneRose
class node_kg_eval,node_factuality,node_general_eval,node_user toneIndigo
```

## Components

### KG Construction

- [Processing config](https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/kg_construction/triple_config.py): `atlas_rag/kg_construction/triple_config.py`
- [Triple extractor](https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/kg_construction/triple_extraction.py): `atlas_rag/kg_construction/triple_extraction.py`
- [JSON to CSV](https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/kg_construction/utils/json_processing/json_to_csv.py): `atlas_rag/kg_construction/utils/json_processing/json_to_csv.py`
- [Concept generation](https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/kg_construction/concept_generation.py): `atlas_rag/kg_construction/concept_generation.py`
- [Concept CSV](https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/kg_construction/concept_to_csv.py): `atlas_rag/kg_construction/concept_to_csv.py`
- [GraphML conversion](https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/kg_construction/utils/csv_processing/csv_to_graphml.py): `atlas_rag/kg_construction/utils/csv_processing/csv_to_graphml.py`

### LLM Generation

- [Extraction prompts](https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/llm_generator/prompt/triple_extraction_prompt.py): `atlas_rag/llm_generator/prompt/triple_extraction_prompt.py`
- [LLM generator](https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/llm_generator/llm_generator.py): `atlas_rag/llm_generator/llm_generator.py`
- [Generation config](https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/llm_generator/generation_config.py): `atlas_rag/llm_generator/generation_config.py`
- [Schema validation](https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/llm_generator/format/validate_json_schema.py): `atlas_rag/llm_generator/format/validate_json_schema.py`

### Graph and Index

- [Neo4j API](https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/kg_construction/neo4j/neo4j_api.py): `atlas_rag/kg_construction/neo4j/neo4j_api.py`
- [Embedding models](https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/vectorstore/embedding_model.py): `atlas_rag/vectorstore/embedding_model.py`
- [Graph index](https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/vectorstore/create_graph_index.py): `atlas_rag/vectorstore/create_graph_index.py`
- [Neo4j index](https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/vectorstore/create_neo4j_index.py): `atlas_rag/vectorstore/create_neo4j_index.py`

### Retrieval and QA

- [Retriever interface](https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/retriever/base.py): `atlas_rag/retriever/base.py`
- [HippoRAG retrieval](https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/retriever/hipporag.py): `atlas_rag/retriever/hipporag.py`
- [HippoRAG2 retrieval](https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/retriever/hipporag2.py): `atlas_rag/retriever/hipporag2.py`
- [ToG retrieval](https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_rag/retriever/tog.py): `atlas_rag/retriever/tog.py`
- [Multi-hop QA](https://github.com/hkust-knowcomp/autoschemakg/blob/main/atlas_mutihopqa.py): `atlas_mutihopqa.py`

### Evaluation

- [KG quality evaluation](https://github.com/hkust-knowcomp/autoschemakg/tree/main/EvaluateKGC): `EvaluateKGC`
- [Factuality evaluation](https://github.com/hkust-knowcomp/autoschemakg/blob/main/EvaluateFactuality/eval.py): `EvaluateFactuality/eval.py`
- [General task evaluation](https://github.com/hkust-knowcomp/autoschemakg/blob/main/EvaluateGeneralTask/lm-evaluation-harness/lm_eval/evaluator.py): `EvaluateGeneralTask/lm-evaluation-harness/lm_eval/evaluator.py`

### Other components

- **KG builder**

## Connections

- KG builder → Triple extractor: runs extraction (evidence: `README.md`)
- Processing config → Triple extractor: configures (evidence: `README.md`)
- Triple extractor → LLM generator: generates triples (evidence: `atlas_rag/kg_construction/triple_extraction.py`)
- Triple extractor → Extraction prompts: uses prompts (evidence: `atlas_rag/kg_construction/triple_extraction.py`)
- Triple extractor → Schema validation: validates output (evidence: `atlas_rag/kg_construction/triple_extraction.py`)
- LLM generator → Generation config: uses settings (evidence: `atlas_rag/llm_generator/llm_generator.py`)
- Triple extractor → JSON to CSV: converts triples (evidence: `atlas_rag/kg_construction/triple_extraction.py`)
- Triple extractor → Concept generation: starts conceptualization (evidence: `atlas_rag/kg_construction/triple_extraction.py`)
- Concept generation → Concept CSV: creates concept CSV (evidence: `atlas_rag/kg_construction/concept_generation.py`)
- Concept generation → GraphML conversion: converts graph data (evidence: `atlas_rag/kg_construction/concept_generation.py`)
- Triple extractor → GraphML conversion: exports graph (evidence: `atlas_rag/kg_construction/triple_extraction.py`)
- Triple extractor → Neo4j index: creates index (evidence: `atlas_rag/kg_construction/triple_extraction.py`)
- Graph index → Embedding models: embeds graph data (evidence: `atlas_rag/vectorstore/create_graph_index.py`)
- Neo4j index → Neo4j API: indexes in Neo4j
- Multi-hop QA → Graph index: loads graph index (evidence: `atlas_mutihopqa.py`)
- Multi-hop QA → HippoRAG retrieval: retrieves context
- Multi-hop QA → HippoRAG2 retrieval: retrieves context
- Multi-hop QA → ToG retrieval: supports ToG retrieval
- HippoRAG retrieval → Embedding models: encodes queries (evidence: `atlas_rag/retriever/hipporag.py`)
- HippoRAG2 retrieval → Embedding models: encodes queries (evidence: `atlas_rag/retriever/hipporag2.py`)
- HippoRAG retrieval → LLM generator: generates responses (evidence: `atlas_rag/retriever/hipporag.py`)
- HippoRAG2 retrieval → LLM generator: generates responses (evidence: `atlas_rag/retriever/hipporag2.py`)
- HippoRAG retrieval → Retriever interface: implements interface (evidence: `atlas_rag/retriever/hipporag.py`)
- HippoRAG2 retrieval → Retriever interface: implements interface (evidence: `atlas_rag/retriever/hipporag2.py`)
- KG builder → KG quality evaluation: evaluates graph (evidence: `README.md`)
- KG builder → Factuality evaluation: evaluates factuality (evidence: `README.md`)
- KG builder → General task evaluation: evaluates tasks (evidence: `README.md`)
