Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

vecto-graph

Vector Graph RAG Recommender with pure vector search.

A Graph-RAG Recommender represents the cutting edge of recommendation architecture. It solves the biggest limitation of traditional RAG: flat vector search misses relational structure. [1, 2]

While standard RAG can find products that sound like a query, it cannot inherently understand that:

"User A bought Item X, which shares a supplier with Item Y, which is frequently bundled with Item Z."

Graph-RAG merges the semantic capabilities of Large Language Models (LLMs) with the explicit, multi-hop reasoning of a Knowledge Graph (KG). [2, 3, 4, 5]


The Architecture: How It Works

Instead of searching a flat database of text snippets, a Graph-RAG recommendation pipeline runs in three distinct phases. [2, 6]

[ User Prompt ]
        │
        ▼
[ 1. Vector Search ]
        │
        ▼
[ 2. Graph Traversal ]
        │
        ▼
[ 3. LLM Generation ]

Example:

"Find a sci-fi thriller"
        │
        ▼
Finds "Interstellar"
as a starting node
        │
        ▼
Traverses relationships
to discover "Inception"
        │
        ▼
Generates a personalized
recommendation explaining why

1. Graph-Based Ingestion

During data ingestion, data is organized into a network of nodes (users, products, categories, brands, attributes) and edges (purchased, viewed, works-with, designed-by). [3, 5]

2. Hybrid Retrieval

When a query enters the system, it first performs traditional vector search to locate relevant starting nodes (for example, a specific movie or product). It then executes multi-hop graph traversals to retrieve a structured subgraph of interconnected context, such as products frequently purchased together by users with similar preferences. [2, 5, 7, 8]

3. Structured Contextualization

This highly targeted structural map is converted into text and provided to the LLM. The LLM acts as the final re-ranker and conversational agent, generating a natural language recommendation. [6, 9, 10]


Why It Excels for Recommendations

1. Multi-Hop Reasoning

Traditional vector databases struggle when a recommendation requires connecting multiple pieces of related information.

For example, if a user asks for a laptop compatible with a specific audio mixer, a vector search might only retrieve the mixer's manual. Graph-RAG can traverse:

Audio Mixer
    │
    ▼
Required Ports
    │
    ▼
Compatible Laptops

This enables recommendations based on explicit relationships rather than textual similarity alone. [4, 5]

2. Visualizable, Auditable Logic

Embeddings in vector space are essentially black boxes of numbers.

Graphs, on the other hand, are explicit, deterministic, and visual. In enterprise environments this provides an audit trail, allowing developers to trace the exact reasoning path:

User
 │
 ▼
Likes Genre
 │
 ▼
Directed by Director
 │
 ▼
Recommended Movie

This transparency makes it much easier to understand why an LLM produced a specific recommendation. [11, 12]

3. Native Collaborative Filtering + Content Matching

Graphs naturally combine the two major recommendation strategies:

  • Content-Based Filtering — Connects users to items based on shared tags, materials, descriptions, or attributes.
  • Collaborative Filtering — Connects users through behavioral relationships, such as "People who bought this also bought..."

4. Solving the "Lost in the Middle" Problem

With traditional RAG, developers often stuff large product catalogs or lengthy reviews into an LLM prompt and hope it identifies meaningful patterns.

This frequently causes the Lost in the Middle problem, where important information buried within long contexts is overlooked.

Graph-RAG removes irrelevant information before prompting the LLM, supplying only the highly relevant network of connected data. [6, 13]


Real-World Example: Movie Discovery

Imagine building a conversational recommendation engine for a streaming platform. [14]

User Query

"Recommend me sci-fi thrillers like Interstellar."

Traditional RAG

Traditional RAG retrieves movies whose descriptions contain words such as:

  • space
  • gravity
  • wormhole

However, it often misses deeper creative relationships between films. [14]

Graph-RAG

Graph-RAG starts at the Interstellar node and traverses relationships:

Interstellar
├── Directed by ──► Christopher Nolan
│                    │
│                    ▼
│                Inception
│
└── Composed by ──► Hans Zimmer
                     │
                     ▼
                 Inception

The resulting relationship graph is provided to the LLM, which generates a recommendation such as:

"I recommend Inception. While it takes place in dreams rather than deep space, it features the same mind-bending direction by Christopher Nolan and a powerful score by Hans Zimmer."


Implementation Considerations

Implementing Graph-RAG typically involves choosing between:

  • In-memory graph libraries

    • NetworkX (ideal for small datasets and experimentation)
  • Production graph databases

    • Neo4j
    • Amazon Neptune
    • FalkorDB

The appropriate choice depends on the size of your graph, query complexity, and scalability requirements. [13]


References

  1. https://medium.com/graph-praxis/graph-rag-in-2026-a-practitioners-guide-to-what-actually-works-dca4962e7517
  2. https://medium.com/@elammarisoufiane/rag-in-2026-architecture-shifts-emerging-patterns-and-what-it-means-for-java-developers-6f2803e39787
  3. https://gradientflow.substack.com/p/graphrag-design-patterns-challenges
  4. https://medium.com/@community_md101/how-graphrag-improves-llm-accuracy-and-discovery-c56292284720
  5. https://www.ibm.com/think/topics/graphrag
  6. https://www.youtube.com/watch?v=ztlbNva16UM&t=151
  7. https://www.reddit.com/r/AI_Agents/comments/1m4rmlz/graphrag_is_fixing_a_real_problem_with_ai_agents/
  8. https://www.youtube.com/watch?v=Bz3z9CTPmoY&t=282
  9. https://arxiv.org/html/2503.06430v1
  10. https://arxiv.org/html/2604.19128v1
  11. https://www.youtube.com/watch?v=knDDGYHnnSI&t=518
  12. https://www.youtube.com/watch?v=Aw7iQjKAX2k
  13. https://www.meilisearch.com/blog/graph-rag
  14. https://neo4j.com/blog/developer/unleashing-the-power-of-graphrag/

About

Vector Graph RAG Recommender with pure vector search.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors