Skip to main content

Overview

This guide walks you through creating a knowledge graph from a collection of documents. You’ll extract entities and relationships, deduplicate them, and explore the results in an interactive browser viewer.
Before you begin, make sure you’ve installed sift-kg and configured your API key.

Your First Knowledge Graph

Let’s build a knowledge graph from a folder of documents. For this example, we’ll assume you have some PDFs or text files in a ./documents/ folder.
1

Initialize your project

Create configuration files in your current directory:
This creates:
  • .env.example — Template for your API keys
  • sift.yaml — Project settings
Copy .env.example to .env and add your API key:
Edit .env and set your API key:
.env
You can override the model for any command with the --model flag:
2

Extract entities and relations

Point sift-kg at your documents folder:
This will:
  • Read all supported files (PDF, DOCX, XLSX, HTML, images, 75+ formats)
  • Chunk the text into manageable pieces
  • Use your LLM to extract entities and relationships
  • Save results to output/extractions/
Example output:
Schema-free mode (the default) runs a schema discovery step — the LLM samples your documents and designs entity/relation types tailored to your corpus. The discovered schema is saved to output/discovered_domain.yaml and reused on subsequent runs.
3

Build the knowledge graph

Construct a NetworkX graph from all extractions:
This will:
  • Load all extraction results
  • Automatically deduplicate near-identical names (plurals, Unicode variants, case differences)
  • Fix reversed edge directions when the LLM swaps source/target types
  • Flag low-confidence relations for review
  • Save the graph to output/graph_data.json
Example output:
4

Find and resolve duplicates

Use the LLM to find entities that likely refer to the same real-world thing:
This creates output/merge_proposals.yaml with proposed entity merges.Example output:
For large graphs (1000+ entities), use --embeddings to group similar entities semantically:
This requires pip install sift-kg[embeddings].
5

Review and approve merges

Review the proposed merges interactively:
This walks through each proposal, showing:
  • The canonical entity
  • The proposed merge members
  • The LLM’s confidence and reasoning
For each proposal, you can:
  • Approve — Mark as CONFIRMED
  • Reject — Mark as REJECTED
  • Skip — Leave as DRAFT to review later
High-confidence proposals (>0.85) are auto-approved. You can adjust thresholds:
Alternative: Edit output/merge_proposals.yaml directly in your text editor. Change status: DRAFT to CONFIRMED or REJECTED. This is recommended for high-accuracy use cases (genealogy, legal review).
6

Apply your decisions

Merge the confirmed entities and remove rejected relations:
Example output:
7

Generate a narrative summary

Create a prose report with entity profiles and relationship chains:
This produces output/narrative.md with:
  • An overview of the graph
  • Key relationship chains between top entities
  • A timeline (when dates exist in the data)
  • Entity profiles grouped by thematic community
Example output:
8

Explore in your browser

Open an interactive graph viewer:
This opens output/graph.html in your browser with:
  • Community regions — Colored zones grouping related entities
  • Hover preview — See entity names and connections
  • Focus mode — Double-click to isolate neighborhoods
  • Search — Find entities by name
  • Filters — Toggle by type, community, source document, confidence
  • Trail breadcrumb — Track your exploration path
Focus Mode Navigation:
  • Double-click any entity to enter focus mode
  • Arrow keys to step through connections
  • Enter/Right to shift focus to a neighbor
  • Backspace/Left to go back along your path
  • Escape to exit focus mode

Search Entities from the CLI

You can search your knowledge graph directly from the terminal:
Example output:
Show connected entities:
Show descriptions (requires running sift narrate first):

Export Your Graph

Export to various formats for use in other tools:
Use GraphML/GEXF when you want to control node sizing, edge weighting, custom color schemes, or apply graph algorithms (centrality, community detection) in dedicated tools. SQLite is useful for ad-hoc SQL queries or publishing with Datasette.

Complete Pipeline Example

Here’s the full workflow in one go:

Real-World Examples

Explore these knowledge graphs generated entirely by sift-kg:

Transformers Papers

12 foundational AI papers mapped as a concept graph
  • 425 entities
  • Cost: ~$0.72
  • Domain: academic

FTX Collapse

The FTX cryptocurrency exchange collapse from 9 articles
  • 431 entities
  • Domain: osint

Epstein Depositions

Giuffre v. Maxwell depositions extracted from a scanned PDF
  • 190 entities
  • Used OCR for scanned documents
Explore all three live — no install, no API key required.

Advanced Configuration

You can configure defaults in sift.yaml so you don’t need flags on every command:
sift.yaml
Settings priority: CLI flags > env vars > .env > sift.yaml > defaults You can override anything from sift.yaml with a flag:

Using Bundled Domains

sift-kg ships with specialized domains:

schema-free (default)

Auto-discovers entity and relation types from your data

general

PERSON, ORGANIZATION, LOCATION, EVENT, DOCUMENT

osint

Investigations: SHELL_COMPANY, FINANCIAL_ACCOUNT, beneficial ownership

academic

Literature review: CONCEPT, THEORY, METHOD, FINDING, PUBLICATION
List all available domains:
Use a bundled domain:
Or set it in sift.yaml:
sift.yaml

Next Steps

Core Concepts

Understand how sift-kg processes documents

CLI Reference

Explore all available commands

Domains

Learn about schema-free vs. structured domains

Entity Resolution

Deep dive into the deduplication workflow