Arcana.Graph.FusionSearch (Arcana v1.3.3)
View SourceCombines vector search and graph-based search using Reciprocal Rank Fusion.
FusionSearch implements the core GraphRAG retrieval strategy:
- Extract entities from the query
- Run vector search on document chunks (standard RAG)
- Run graph search on the knowledge graph
- Merge results using Reciprocal Rank Fusion (RRF)
Reciprocal Rank Fusion
RRF is a simple but effective method for combining ranked lists:
score(doc) = Σ 1 / (k + rank(doc, list_i))where k is a constant (default: 60) that reduces the impact of high ranks.
Example
# Build graph from extracted data
graph = GraphQuery.build_graph(entities, relationships, chunks, communities)
# Extract entities from query
{:ok, entities} = Arcana.Graph.EntityExtractor.NER.extract("Tell me about OpenAI", [])
# Run vector search
vector_results = Arcana.search(repo, collection, query, top_k: 10)
# Combine with graph search
FusionSearch.search(graph, entities, vector_results)
Summary
Functions
Searches the knowledge graph based on recognized entities.
Merges multiple ranked lists using Reciprocal Rank Fusion.
Combines vector search results with graph search using RRF.
Functions
Searches the knowledge graph based on recognized entities.
Finds entities in the graph matching the provided extracted entities, then traverses relationships to collect connected chunks.
Options
:depth- How many hops to traverse (default: 1)
Merges multiple ranked lists using Reciprocal Rank Fusion.
Options
:k- RRF constant to reduce high-rank impact (default: 60)
Algorithm
For each document, computes:
score = sum(1 / (k + rank)) across all listsHigher scores indicate documents that appear in multiple lists and/or rank highly in individual lists.
Combines vector search results with graph search using RRF.
Takes pre-computed vector search results and entities extracted from the query, runs graph search, then merges both result sets.
Options
:depth- Graph traversal depth (default: 1):limit- Maximum results to return (default: 10):k- RRF constant (default: 60)