Better Nearest Neighbor Graph Indices via (Efficient) LLM-Guided Pruning
Organizations: University of Wisconsin–Madison · MIT
Abstract
Graph-based approximate nearest neighbor search (ANNS) is widely used for large-scale semantic search. Its indices are constructed primarily based on geometric relationships among embeddings of an input dataset (e.g., documents or images), rather than explicitly optimizing for semantic relevance. However, when using these indices for downstream query retrieval, performance is evaluated based on the semantic relevance of the retrieved results to the query. This creates a fundamental "geometry-semantic" mismatch between how the indices are constructed and how their retrieval results are evaluated. While existing LLM-based reranking methods can partially mitigate this mismatch at query time, they leave this underlying structural problem in the graph unresolved. We therefore propose LLM-Guided Graph Pruning (LGP), a general framework that addresses this mismatch directly by leveraging LLM reasoning to refine an existing ANN graph index itself. LGP identifies structurally "low-value" neighbors of nodes and replaces them with LLM-selected alternatives that provide useful semantic information while retaining desired geometric structures of the original graph, including sparsity and efficient navigability. Experiments on representative semantic retrieval benchmarks show that LGP consistently improves end-to-end retrieval performance over both vanilla greedy graph search and LLM-based reranking across widely used graph-based ANN indices such as DiskANN and HNSW.
Figures & tables
| Greedy search | Rerank | |||
| Dataset | NDCG@10 | Recall@10 | NDCG@10 | Recall@10 |
| Biology | 24.69 / 37.06 +50.1% | 28.66 / 44.63 +55.7% | 28.30 / 41.57 +46.9% | 30.71 / 46.19 +50.4% |
| Earth Science | 20.60 / 27.92 +35.5% | 22.70 / 30.59 +34.8% | 23.29 / 30.06 +29.1% | 25.51 / 33.03 +29.5% |
| Economics | 19.56 / 22.35 +14.3% | 20.77 / 25.61 +23.3% | 19.98 / 25.42 +27.2% | 21.92 / 28.84 +31.6% |
| Psychology | 28.31 / 34.76 +22.8% | 34.51 / 41.61 +20.6% | 32.78 / 41.46 +26.5% | 34.40 / 44.10 +28.2% |
| Robotics | 19.48 / 21.68 +11.3% | 24.83 / 27.12 +9.2% | 25.67 / 28.63 +11.5% | 28.61 / 31.16 +8.9% |
| Greedy search | Rerank | |||
| Dataset (Task) | NDCG@10 | Recall@10 | NDCG@10 | Recall@10 |
| VisualNews (0) | 16.41 / 15.45 | 21.00 / 20.00 | 15.23 / 15.97 +4.9% | 21.00 / 21.00 |
| MSCOCO (0) | 32.45 / 32.88 +1.3% | 51.00 / 52.00 +2.0% | 45.09 / 46.09 +2.2% | 56.00 / 57.00 +1.8% |
| Fashion200K (0) | 1.80 / 1.82 +1.1% | 2.63 / 2.63 | 4.53 / 3.56 | 4.97 / 3.97 |
| WebQA (1) | 5.99 / 6.61 +10.4% | 7.50 / 8.00 +6.7% | 8.29 / 8.93 +7.7% | 8.00 / 9.00 +12.5% |
| EDIS (2) | 6.76 / 11.29 +67.0% | 9.07 / 14.74 +62.5% | 11.02 / 15.67 +42.2% | 12.80 / 18.71 +46.2% |
| Benchmark (Exact NN ref.) | Search width | Greedy search | Rerank | ||||||
| NDCG@10 | Recall@10 | NDCG@10 | Recall@10 | ||||||
| Vanilla | LGP | Vanilla | LGP | Vanilla | LGP | Vanilla | LGP | ||
| BRIGHT (28.50 / 34.18) | 10 | 11.90 | 15.74 +32.3% | 13.53 | 18.27 +35.0% | 13.01 | 17.28 +32.8% | 13.53 | 18.27 +35.0% |
| 20 | 17.12 | 21.30 +24.4% | 20.01 | 25.05 +25.2% | 18.92 | 23.83 +26.0% | 20.95 | 26.68 +27.4% | |
| 50 | 23.09 | 25.03 +8.4% | 27.43 | 29.51 +7.6% | 26.31 | 28.47 +8.2% | 29.95 | 32.56 +8.7% | |
| 100 | 26.10 | 26.87 +3.0% | 31.05 | 31.73 +2.2% | 30.24 | 31.28 +3.4% | 34.94 | 35.61 +1.9% | |
| Benchmark (Exact NN ref.) | Computation budget | Greedy search | Rerank | ||||||
| NDCG@10 | Recall@10 | NDCG@10 | Recall@10 | ||||||
| Vanilla | LGP | Vanilla | LGP | Vanilla | LGP | Vanilla | LGP | ||
| BRIGHT (28.50 / 34.18) | 100 | 3.96 | 5.02 +26.9% | 2.96 | 4.15 +40.0% | 4.28 | 5.40 +26.1% | 3.07 | 4.12 +34.3% |
| 200 | 10.50 | 13.98 +33.2% | 11.62 | 15.60 +34.3% | 11.67 | 15.41 +32.0% | 12.32 | 16.40 +33.1% | |
| 300 | 16.69 | 19.80 +18.6% | 19.18 | 23.19 +20.9% | 18.70 | 22.46 +20.1% | 20.35 | 24.61 +21.0% | |
| 500 | 22.92 | 24.57 +7.2% | 27.14 | 28.83 +6.2% | 26.04 | 27.79 +6.7% | 28.70 | 30.82 +7.4% | |
| Greedy search | Rerank | |||||||
| Dataset | NDCG@5 | NDCG@10 | Recall@5 | Recall@10 | NDCG@5 | NDCG@10 | Recall@5 | Recall@10 |
| TheoremQA-Theorems | 38.64 / 39.47 | 42.39 / 43.34 | 45.05 / 45.71 | 54.81 / 56.12 | 38.26 / 40.76 | 41.85 / 43.52 | 44.86 / 48.15 | 55.47 / 56.12 |
| Biology | 42.71 / 42.19 | 48.06 / 47.39 | 42.13 / 41.40 | 57.25 / 56.09 | 50.85 / 52.83 | 54.67 / 55.74 | 48.63 / 49.20 | 59.90 / 58.90 |
| Pony | 14.84 / 17.11 | 12.83 / 14.48 | 3.83 / 4.36 | 6.71 / 8.04 | 17.82 / 19.92 | 14.80 / 16.28 | 4.72 / 5.62 | 7.37 / 8.78 |
| NDCG@5 | NDCG@10 | Recall@5 | Recall@10 | |||||
| Retrieval | Vanilla | LGP | Vanilla | LGP | Vanilla | LGP | Vanilla | LGP |
| Greedy search | 10.89 | 12.33 +13.2% | 12.04 | 13.81 +14.7% | 11.52 | 13.06 +13.4% | 15.34 | 17.60 +14.7% |
| LLM rerank | 15.91 | 18.19 +14.3% | 16.34 | 18.70 +14.4% | 15.31 | 17.37 +13.5% | 18.19 | 20.66 +13.6% |
| Greedy search | LLM reranking | ||||
| Dataset | Model | Vanilla | LGP | Vanilla | LGP |
| Pony | Qwen3-8B | 17.08 | 17.00 | 19.54 | 19.83 |
| Qwen3-32B | 17.08 | 17.80 | 19.54 | 20.07 | |
| Psychology | Qwen3-8B | 28.31 | 29.82 | 32.55 | 34.75 |
| Qwen3-32B | 28.31 | 34.76 | 32.69 | 41.46 | |
| Dataset | Queries | Documents |
| Biology | 103 | 57,359 |
| Earth Science | 116 | 121,249 |
| Economics | 103 | 50,220 |
| Psychology | 101 | 52,835 |
| Robotics | 101 | 61,961 |
| StackOverflow | 117 | 107,081 |
| Dataset | Task | Query target | Queries | Candidates |
| VisualNews | 0 | 19,995 | 542,246 | |
| MSCOCO | 0 | 24,809 | 5,000 | |
| Fashion200K | 0 | 1,719 | 201,824 | |
| WebQA | 1 | 2,455 | 544,457 | |
| EDIS | 2 | 3,241 | 1,047,067 | |
| WebQA | 2 | 2,511 | 403,196 |
| Benchmark | Role | Model |
| BRIGHT | Embedding | Diver-Retriever-4B-1020 |
| BRIGHT | Embedding | Qwen3-Embedding-4B |
| BRIGHT | Graph refinement / reranking | Qwen3-32B |
| M-BEIR | Embedding | CLIP (ViT-B/32) |
| M-BEIR | Graph refinement / reranking | Qwen3-VL-30B-A3B-Instruct |
Appendix figures & tables7 assets
Supplementary material from the paper’s appendix.
Appendix
| Greedy search | Rerank | |||||||
| Dataset | NDCG@5 | NDCG@10 | Recall@5 | Recall@10 | NDCG@5 | NDCG@10 | Recall@5 | Recall@10 |
| Biology | 22.22 / 32.66 | 24.69 / 37.06 | 21.42 / 32.10 | 28.66 / 44.63 | 26.95 / 39.15 | 28.30 / 41.57 | 26.22 / 38.47 | 30.71 / 46.19 |
| Earth Science | 19.80 / 26.32 | 20.60 / 27.92 | 19.13 / 25.80 | 22.70 / 30.59 | 21.91 / 28.03 | 23.29 / 30.06 | 20.62 / 27.30 | 25.51 / 33.03 |
| Economics | 18.68 / 21.00 | 19.56 / 22.35 | 15.62 / 18.81 | 20.77 / 25.61 | 18.84 / 24.01 | 19.98 / 25.42 | 16.09 / 22.46 | 21.92 / 28.84 |
| Psychology | 26.62 / 32.37 | 28.31 / 34.76 | 26.62 / 31.62 | 34.51 / 41.61 | 32.88 / 40.20 | 32.78 / 41.46 | 29.47 / 35.11 | 34.40 / 44.10 |
| Robotics | 19.05 / 21.19 | 19.48 / 21.68 | 20.59 / 22.35 | 24.83 / 27.12 | 25.68 / 28.47 | 25.67 / 28.63 | 24.27 / 25.98 | 28.61 / 31.16 |
| Greedy search | Rerank | |||||||
| Dataset (Task) | NDCG@5 | NDCG@10 | Recall@5 | Recall@10 | NDCG@5 | NDCG@10 | Recall@5 | Recall@10 |
| VisualNews (0) | 15.80 / 14.54 | 16.41 / 15.45 | 19.00 / 17.00 | 21.00 / 20.00 | 14.26 / 15.02 | 15.23 / 15.97 | 18.00 / 18.00 | 21.00 / 21.00 |
| MSCOCO (0) | 28.26 / 28.33 | 32.45 / 32.88 | 38.00 / 38.00 | 51.00 / 52.00 | 42.72 / 43.72 | 45.09 / 46.09 | 49.00 / 50.00 | 56.00 / 57.00 |
| Fashion200K (0) | 1.51 / 1.51 | 1.80 / 1.82 | 1.79 / 1.79 | 2.63 / 2.63 | 4.41 / 3.41 | 4.53 / 3.56 | 3.97 / 2.97 | 4.97 / 3.97 |
| WebQA (1) | 5.38 / 6.00 | 5.99 / 6.61 | 6.00 / 6.50 | 7.50 / 8.00 | 8.29 / 8.76 | 8.29 / 8.93 | 8.00 / 8.50 | 8.00 / 9.00 |
| EDIS (2) | 5.87 / 9.89 | 6.76 / 11.29 | 6.49 / 10.57 | 9.07 / 14.74 | 10.33 / 14.22 | 11.02 / 15.67 | 10.63 / 14.05 | 12.80 / 18.71 |
| Pony | Psychology | Biology | ||||
| Variant | Greedy | Rerank | Greedy | Rerank | Greedy | Rerank |
| Proximity only | 16.89 | 18.94 | 33.71 | 39.52 | 33.07 | 37.69 |
| Coverage only | 17.84 | 20.22 | 33.18 | 39.30 | 37.06 | 41.17 |
| Separation only | 17.19 | 20.02 | 33.45 | 39.68 | 39.22 | 45.71 |
| Balanced | 17.80 | 20.07 | 34.76 | 41.46 | 37.06 | 41.57 |
| Pony | Psychology | Biology | ||||
| Variant | Greedy | Rerank | Greedy | Rerank | Greedy | Rerank |
| Redundancy only | 17.36 | 20.22 | 32.38 | 38.04 | 33.93 | 39.74 |
| Coverage only | 17.73 | 20.03 | 34.30 | 41.15 | 34.41 | 38.86 |
| Lexicographic | 17.80 | 20.07 | 34.76 | 41.46 | 37.06 | 41.57 |
| Embedding | Mean out-degree | Changed neighborhoods (%) | |
| Vanilla | LGP | ||
| Diver | 15.60 | 15.66 | 88.5 |
| Qwen3-Embedding | 15.88 | 15.80 | 88.9 |
| Dataset | Nodes | Build time (min) | LGP time (s/node) | LLM calls | Tokens (M) | ||
| Vanilla | LGP | Input | Output | ||||
| Pony | 7,894 | 1.49 | 109.46 | 0.83 | 7,894 | 23.95 | 0.22 |
| Psychology | 52,835 | 11.84 | 691.40 | 0.79 | 52,835 | 124.56 | 1.50 |
| Benchmark (Exact NN ref.) | Computation budget | Greedy search | Rerank | ||||||
| NDCG@10 | Recall@10 | NDCG@10 | Recall@10 | ||||||
| Vanilla | LGP | Vanilla | LGP | Vanilla | LGP | Vanilla | LGP | ||
| BRIGHT (28.50 / 34.18) | 100 | 3.96 | 5.02 +26.9% | 2.96 | 4.15 +40.0% | 4.28 | 5.40 +26.1% | 3.07 | 4.12 +34.3% |
| 200 | 10.50 | 13.98 +33.2% | 11.62 | 15.60 +34.3% | 11.67 | 15.41 +32.0% | 12.32 | 16.40 +33.1% | |
| 300 | 16.69 | 19.80 +18.6% | 19.18 | 23.19 +20.9% | 18.70 | 22.46 +20.1% | 20.35 | 24.61 +21.0% | |
| 500 | 22.92 | 24.57 +7.2% | 27.14 | 28.83 +6.2% | 26.04 | 27.79 +6.7% | 28.70 | 30.82 +7.4% | |