# Hyper-Extract

> Turn documents into graphs, hypergraphs or chunk corpora from one CLI

- Category: Retrieval & Knowledge (RAG) / Parsing & Ingestion
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/yifanfeng97/Hyper-Extract
- Website: https://yifanfeng97.github.io/Hyper-Extract/
- Canonical page: https://ai-tldr.dev/tools/hyper-extract/

## In short

Hyper-Extract is a command-line tool that converts unstructured documents into structured knowledge. It sits in the Parsing & Ingestion category of the Retrieval & Knowledge (RAG) tools and is open-source, written in Python and licensed Apache-2.0. To get started: install the CLI.

## Overview

Hyper-Extract is a command-line tool that converts unstructured documents into structured knowledge. You point it at a file, pick one of its YAML templates, and it produces a knowledge structure you can query: the project supports nine of them, from raw chunk corpora and simple lists up to graphs, hypergraphs and spatio-temporal graphs. The pitch on the repository is blunt — "Transform documents into structured knowledge with one command."

Extraction is pluggable rather than a single fixed algorithm. The project ships more than eleven extraction engines, including a zero-cost `chunk_rag` baseline plus GraphRAG, LightRAG, Hyper-RAG and KG-Gen, and more than eighty YAML templates covering finance, legal, medical, traditional Chinese medicine, industry and general domains. Ingestion goes beyond plain text: with the `ingest` extra it reads PDF, Word, PowerPoint, Excel, HTML and EPUB.

Around extraction sit the parts that make a knowledge base maintainable. Every fact is attributed to the source document it came from, so you can audit contributions with `he info --sources`, roll a document back, or upsert a newer version of a source and have the old facts retire. Results can be searched with tag scoping, visualised, or exported to an Obsidian vault as Markdown notes linked by wikilinks. Models are configured per provider — OpenAI and Alibaba Bailian supply both LLM and embeddings, while Anthropic, Google Gemini and DeepSeek are LLM-only and pair with an OpenAI-compatible embedder, or you can point everything at a local vLLM server.

## What it does

- Nine knowledge structures, from chunk corpora and lists up to graphs, hypergraphs and spatio-temporal graphs
- Eleven-plus extraction engines including a zero-cost chunk_rag baseline, GraphRAG, LightRAG, Hyper-RAG and KG-Gen
- Over eighty YAML templates across finance, legal, medical, TCM, industry and general domains — no code to write
- Rich document ingestion for PDF, Word, PowerPoint, Excel, HTML and EPUB via the `ingest` extra
- Incremental evolution with provenance: audit which document contributed what, roll back a document, or upsert an updated source
- Obsidian export that turns an extracted graph into Markdown notes linked by wikilinks
- Provider-agnostic configuration for OpenAI, Anthropic, Google Gemini, DeepSeek, Alibaba Bailian or a local vLLM server

## Getting started

Hyper-Extract needs Python 3.11+ and installs as a CLI called `he`. Install it, configure one model provider, then extract and query a document.

1. Install the CLI

   The README installs it as a uv tool; pipx works too.

```bash
# Install uv first (if you haven't)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install Hyper-Extract CLI
uv tool install hyperextract
# or: pipx install hyperextract
```

2. Configure a provider

   OpenAI and Bailian give you the LLM and embeddings in one key. Anthropic, Gemini and DeepSeek are LLM-only, so pair them with an OpenAI-compatible embedder. A local vLLM pair needs no cloud key.

```bash
# OpenAI (LLM + embeddings in one key)
he config init -p openai -k YOUR_OPENAI_API_KEY

# DeepSeek (LLM only — pair with an OpenAI embedder)
he config llm -p deepseek -k YOUR_DEEPSEEK_API_KEY
he config embedder -p openai -k YOUR_OPENAI_API_KEY

# Local vLLM (on-premise)
he config llm -p vllm -u http://localhost:8000/v1 -k dummy -m Qwen/Qwen3.5-9B
he config embedder -p vllm -u http://localhost:8001/v1 -k dummy -m BAAI/bge-m3
```

3. Extract, query and visualise

   Pick a template with `-t`, write the result to an output directory, then search or display it.

```bash
# Extract knowledge from a document
he parse examples/en/tesla.md -t general/biography_graph -o ./output/ -l en

# Query it
he search ./output/ "What are Tesla's major achievements?"

# Visualize
he show ./output/

# Export to an Obsidian vault (Markdown notes + [[wikilinks]])
he export obsidian ./output/ -o ./vault/
```

4. Keep it current and auditable

   Feed an updated version of a source under the same name and the old facts roll back. Tags scope searches, and `he info --sources` shows which documents contributed what.

```bash
he feed ./output/ updated-tesla.md --source tesla.md

he tag ./output/ --source tesla.md --add biography
he search ./output/ "inventions" --tag biography

he info ./output/ --sources
```

5. Or drive it from Python

   The same templates are available through a small Python API.

```python
from hyperextract import Template

ka = Template.create("general/biography_graph")

with open("examples/en/tesla.md") as f:
    result = ka.parse(f.read())

result.show()
```

## When to use it

- Reach for it to turn a stack of papers or reports into a browsable knowledge graph instead of reading them end to end
- Reach for it when you want to compare extraction strategies — chunk baseline against GraphRAG, LightRAG or Hyper-RAG — without rewriting a pipeline for each
- Reach for it for domain extraction where a template already exists, across finance, legal, medical or industrial documents
- Reach for it when provenance matters: you need to know which source produced a fact, and to retire it when that source changes
