06 — GraphRAG Γ (gamma) Selection Playbook (Neo4j/GDS)¶
Goal: choose a resolution (γ) per level (C0/C1/C2) that balances coverage and community size for GraphRAG chunk retrieval, and prepare for a later step where we choose the best level overall using a QA evaluation pipeline.
What this notebook does¶
- Loads candidate runs (each run = one
(level, γ)with a distinct--ingest-tag). - Computes metrics from Neo4j for each candidate:
- Entities per community →
p50 / p90 / p95 - Distinct chunks per community →
p50 / p90 / p95 #communities- Global distinct chunk coverage and coverage_ratio (= covered / total chunks)
- Selects a recommended γ per level via an objective‑driven rule:
coverage(maximize coverage),moderate(smaller communities with decent coverage),balanced(default): coverage‑heavy cost with penalties for very large communities and many communities.- Cross‑level summary that lists winners for C0, C1, C2 and writes a selection manifest.
- Hook for QA evaluation: you can later load your retrieval metrics (Recall@K, MRR, nDCG, EM/F1, latency) and pick the final champion level.
ℹ️ You do not need community summaries/embeddings to run this notebook; it works on community structure + chunk links only.
Prerequisites¶
.envcontainsNEO4J_URI,NEO4J_USER,NEO4J_PASSWORDand dataset DB names (NEO4J_DATABASE_FIXED_SIZE/NEO4J_DATABASE_SEMANTIC) if you use per‑dataset DBs.- Your chunk/entity graph is already ingested.
- You executed one or more community builds (one tag per γ value you want to compare).
CLI examples¶
| Text Only | |
|---|---|
1 2 3 4 5 | |
| Text Only | |
|---|---|
1 | |
| Text Only | |
|---|---|
1 2 | |
| dataset | level | ingest_tag | label | gamma | communities | entities_p50 | entities_p90 | entities_p95 | chunks_p50 | chunks_p90 | chunks_p95 | unique_chunks_global | coverage_ratio | total_chunks_dataset | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | fixed_size | C0 | comm_fixed_C0_g0_6 | g0.6 | 0.6 | 80 | 14.0 | 359.3 | 1225.0 | 2.0 | 90.6 | 400.65 | 3928 | 0.976629 | 4022 |
| 1 | fixed_size | C1 | comm_fixed_C1_g0_8 | g0.8 | 0.8 | 18 | 15.0 | 54.7 | 112.0 | 3.0 | 11.5 | 29.55 | 174 | 0.043262 | 4022 |
| 2 | fixed_size | C1 | comm_fixed_C1_g1_0 | g1.0 | 1.0 | 43 | 19.0 | 706.2 | 1504.1 | 3.0 | 297.8 | 872.80 | 3354 | 0.833913 | 4022 |
| 3 | fixed_size | C1 | comm_fixed_C1_g1_2 | g1.2 | 1.2 | 100 | 16.0 | 573.2 | 1317.6 | 3.0 | 312.9 | 747.90 | 3928 | 0.976629 | 4022 |
| 4 | fixed_size | C2 | comm_fixed_C2_g1_6 | g1.6 | 1.6 | 108 | 18.0 | 495.2 | 992.8 | 3.0 | 325.6 | 800.45 | 3930 | 0.977126 | 4022 |
| Text Only | |
|---|---|
| Text Only | |
|---|---|
1 | |
| dataset | level | ingest_tag | label | gamma | communities | entities_p50 | entities_p90 | entities_p95 | chunks_p50 | chunks_p90 | chunks_p95 | unique_chunks_global | coverage_ratio | total_chunks_dataset | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | fixed_size | C0 | comm_fixed_C0_g0_6 | g0.6 | 0.6 | 80 | 14.0 | 359.3 | 1225.0 | 2.0 | 90.6 | 400.65 | 3928 | 0.976629 | 4022 |
| 1 | fixed_size | C1 | comm_fixed_C1_g0_8 | g0.8 | 0.8 | 18 | 15.0 | 54.7 | 112.0 | 3.0 | 11.5 | 29.55 | 174 | 0.043262 | 4022 |
| 2 | fixed_size | C1 | comm_fixed_C1_g1_0 | g1.0 | 1.0 | 43 | 19.0 | 706.2 | 1504.1 | 3.0 | 297.8 | 872.80 | 3354 | 0.833913 | 4022 |
| 3 | fixed_size | C1 | comm_fixed_C1_g1_2 | g1.2 | 1.2 | 100 | 16.0 | 573.2 | 1317.6 | 3.0 | 312.9 | 747.90 | 3928 | 0.976629 | 4022 |
| 4 | fixed_size | C2 | comm_fixed_C2_g1_6 | g1.6 | 1.6 | 108 | 18.0 | 495.2 | 992.8 | 3.0 | 325.6 | 800.45 | 3930 | 0.977126 | 4022 |





















| Text Only | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
| Text Only | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
Using the selected configuration in retrieval¶
Once you've picked a winner per level (and later, the final champion level from QA):
- Use the selected (level, ingest_tag) in your retriever.
- Example CLI to pull chunks for a query:
| PowerShell | |
|---|---|
Tip: If you want to blend multiple levels, run
communities retrievefor each(level, tag)and RRF-merge the chunk IDs.
| Text Only | |
|---|---|
| Text Only | |
|---|---|
1 | |