The following step-by-step guide walks through the process to visualize a knowledge graph after it's been constructed by graphrag. Note that some of the settings recommended below are based on our own experience of what works well. Feel free to change and explore other settings for a better visualization experience!
Before building an index, please review your settings.yaml
configuration file and ensure that graphml snapshots is enabled.
snapshots:
graphml: true
(Optional) To support other visualization tools and exploration, additional parameters can be enabled that provide access to vector embeddings.
embed_graph:
enabled: true # will generate node2vec embeddings for nodes
umap:
enabled: true # will generate UMAP embeddings for nodes
After running the indexing pipeline over your data, there will be an output folder (defined by the storage.base_dir
setting).
- Output Folder: Contains artifacts from the LLM’s indexing pass.
In the output folder, look for a file named merged_graph.graphml
. graphml is a standard file format supported by many visualization tools. We recommend trying Gephi.
- Install and open Gephi
- Navigate to the
output
folder containing the various parquet files. - Import the
merged_graph.graphml
file into Gephi. This will result in a fairly plain view of the undirected graph nodes and edges.
- Go to
Tools
->Plugins
. - Search for "Leiden Algorithm".
- Click
Install
and restart Gephi.
- In the
Statistics
tab on the right, clickRun
forAverage Degree
andLeiden Algorithm
.
- For the Leiden Algorithm, adjust the settings:
- Quality function: Modularity
- Resolution: 1
- Go to the
Appearance
pane in the upper left side of Gephi.
- Select
Nodes
, thenPartition
, and click the color palette icon in the upper right. - Choose
Cluster
from the dropdown. - Click the
Palette...
hyperlink, thenGenerate...
. - Uncheck
Limit number of colors
, clickGenerate
, and thenOk
. - Click
Apply
to color the graph. This will color the graph based on the partitions discovered by Leiden.
- In the
Appearance
pane in the upper left, selectNodes
->Ranking
- Select the
Sizing
icon in the upper right. - Choose
Degree
and set:- Min: 10
- Max: 150
- Click
Apply
.
- In the
Layout
tab in the lower left, selectOpenORD
.
- Set
Liquid
andExpansion
stages to 50, and everything else to 0. - Click
Run
and monitor the progress.
- Select
Force Atlas 2
in the layout options.
- Adjust the settings:
- Scaling: 15
- Dissuade Hubs: checked
- LinLog mode: uncheck
- Prevent Overlap: checked
- Click
Run
and wait. - Press
Stop
when it looks like the graph nodes have settled and no longer change position significantly.
- Turn on text labels in the appropriate section.
- Configure and resize them as needed.
Your final graph should now be visually organized and ready for analysis!