Skip to content

Commit 9762f33

Browse files
authored
Add visualization guide (#1340)
1 parent a6d9b0c commit 9762f33

File tree

10 files changed

+111
-1
lines changed

10 files changed

+111
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "patch",
3+
"description": "add visualization guide to doc site"
4+
}

dictionary.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ onclick
9696
pymdownx
9797
linenums
9898
twemoji
99+
Gephi
100+
gephi
101+
Gephi's
99102

100103
# Verbs
101104
binarize
@@ -183,4 +186,4 @@ kwds
183186
astrotechnician
184187
epitheg
185188
unspooled
186-
unnavigated
189+
unnavigated

docs/get_started.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,6 @@ graphrag query \
125125
```
126126

127127
Please refer to [Query Engine](query/overview.md) docs for detailed information about how to leverage our Local and Global search mechanisms for extracting meaningful insights from data after the Indexer has wrapped up execution.
128+
129+
# Visualizing the Graph
130+
Check out our [visualization guide](visualization_guide.md) for a more interactive experience in debugging and exploring the knowledge graph.
69.3 KB
Loading
1.27 MB
Loading
232 KB
Loading
96.8 KB
Loading
151 KB
Loading

docs/visualization_guide.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Visualizing and Debugging Your Knowledge Graph
2+
3+
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!
4+
5+
## 1. Run the Pipeline
6+
Before building an index, please review your `settings.yaml` configuration file and ensure that graphml snapshots is enabled.
7+
```yaml
8+
snapshots:
9+
graphml: true
10+
```
11+
(Optional) To support other visualization tools and exploration, additional parameters can be enabled that provide access to vector embeddings.
12+
```yaml
13+
embed_graph:
14+
enabled: true # will generate node2vec embeddings for nodes
15+
umap:
16+
enabled: true # will generate UMAP embeddings for nodes
17+
```
18+
After running the indexing pipeline over your data, there will be an output folder (defined by the `storage.base_dir` setting).
19+
- **Output Folder**: Contains artifacts from the LLM’s indexing pass.
20+
21+
## 2. Locate the Knowledge Graph
22+
In the output folder, look for a file named `merged_graph.graphml`. graphml is a standard [file format](http://graphml.graphdrawing.org) supported by many visualization tools. We recommend trying [Gephi](https://gephi.org).
23+
24+
## 3. Open the Graph in Gephi
25+
1. Install and open Gephi
26+
2. Navigate to the `output` folder containing the various parquet files.
27+
3. Import the `merged_graph.graphml` file into Gephi. This will result in a fairly plain view of the undirected graph nodes and edges.
28+
29+
<p align="center">
30+
<img src="img/viz_guide/gephi-initial-graph-example.png" alt="A basic graph visualization by Gephi" width="300"/>
31+
</p>
32+
33+
## 4. Install the Leiden Algorithm Plugin
34+
1. Go to `Tools` -> `Plugins`.
35+
2. Search for "Leiden Algorithm".
36+
3. Click `Install` and restart Gephi.
37+
38+
## 5. Run Statistics
39+
1. In the `Statistics` tab on the right, click `Run` for `Average Degree` and `Leiden Algorithm`.
40+
41+
<p align="center">
42+
<img src="img/viz_guide/gephi-network-overview-settings.png" alt="A view of Gephi's network overview settings" width="300"/>
43+
</p>
44+
45+
2. For the Leiden Algorithm, adjust the settings:
46+
- **Quality function**: Modularity
47+
- **Resolution**: 1
48+
49+
## 6. Color the Graph by Clusters
50+
1. Go to the `Appearance` pane in the upper left side of Gephi.
51+
52+
<p align="center">
53+
<img src="img/viz_guide/gephi-appearance-pane.png" alt="A view of Gephi's appearance pane" width="500"/>
54+
</p>
55+
56+
2. Select `Nodes`, then `Partition`, and click the color palette icon in the upper right.
57+
3. Choose `Cluster` from the dropdown.
58+
4. Click the `Palette...` hyperlink, then `Generate...`.
59+
5. Uncheck `Limit number of colors`, click `Generate`, and then `Ok`.
60+
6. Click `Apply` to color the graph. This will color the graph based on the partitions discovered by Leiden.
61+
62+
## 7. Resize Nodes by Degree Centrality
63+
1. In the `Appearance` pane in the upper left, select `Nodes` -> `Ranking`
64+
2. Select the `Sizing` icon in the upper right.
65+
2. Choose `Degree` and set:
66+
- **Min**: 10
67+
- **Max**: 150
68+
3. Click `Apply`.
69+
70+
## 8. Layout the Graph
71+
1. In the `Layout` tab in the lower left, select `OpenORD`.
72+
73+
<p align="center">
74+
<img src="img/viz_guide/gephi-layout-pane.png" alt="A view of Gephi's layout pane" width="400"/>
75+
</p>
76+
77+
2. Set `Liquid` and `Expansion` stages to 50, and everything else to 0.
78+
3. Click `Run` and monitor the progress.
79+
80+
## 9. Run ForceAtlas2
81+
1. Select `Force Atlas 2` in the layout options.
82+
83+
<p align="center">
84+
<img src="img/viz_guide/gephi-layout-forceatlas2-pane.png" alt="A view of Gephi's ForceAtlas2 layout pane" width="400"/>
85+
</p>
86+
87+
2. Adjust the settings:
88+
- **Scaling**: 15
89+
- **Dissuade Hubs**: checked
90+
- **LinLog mode**: uncheck
91+
- **Prevent Overlap**: checked
92+
3. Click `Run` and wait.
93+
4. Press `Stop` when it looks like the graph nodes have settled and no longer change position significantly.
94+
95+
## 10. Add Text Labels (Optional)
96+
1. Turn on text labels in the appropriate section.
97+
2. Configure and resize them as needed.
98+
99+
Your final graph should now be visually organized and ready for analysis!

mkdocs.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ nav:
5454
- Microsoft Research Blog: "blog_posts.md"
5555
- Extras:
5656
- CLI: "cli.md"
57+
- Visualization Guide: "visualization_guide.md"
5758
- Operation Dulce:
5859
- About: "data/operation_dulce/ABOUT.md"
5960
- Document: "data/operation_dulce/Operation Dulce v2 1 1.md"

0 commit comments

Comments
 (0)