What the retrieval layer of a Graph RAG system actually looks like
The first version retrieved everything. Every node reachable from the seed entity, up to four hops. The context window hit 8,000 tokens on a basic query about a mid-size Korean manufacturer. The model started confusing entities. I pulled it back to 50 nodes, which is where it still is. I don't love that number. It's a hard cutoff that causes real problems for large corporate groups — Samsung…
The retrieval layer of a Graph Retrieval-Augmented Generation (RAG) system is responsible for gathering relevant information from a knowledge graph based on a user's query. In the system described, the retrieval process initiates from seed entities, such as the company "Samsung SDI" and the concept of "US tariffs on Korean steel" in the example query.
To identify these seed entities, the system employs an entity lookup that checks the normalized names and aliases of entities in the graph. This is achieved through SQL-like queries that search for matches based on normalized name contents and aliases.
Once the seed entities are identified, the system expands the subgraph by following supply chain relationship types, such as "SUPPLIES_TO," "SOURCE_FROM," and "OWNS," with a limit of three hops. This depth ensures the subgraph remains focused on relevant information without including noisy or irrelevant data points. For instance, in the given example, a steel tariff affecting a Korean parts supplier and impacting a construction equipment company would be captured within three hops, while the fourth hop would typically lead to conglomerates that own multiple entities, adding unnecessary noise.
After obtaining the subgraph, the system retrieves source document excerpts, which serve as the factual evidence to support the relationships between entities. These excerpts are then ranked based on their relevance to the query using TF-IDF (Term Frequency-Inverse Document Frequency) ranking. However, there is a challenge in distinguishing between facts obtained from low-confidence entity merges and those from directly verified sources.
Currently, the system flags any fact with a confidence score below 0.80 with "[uncertain]" in the context, but this requires manual adjustment after identifying the issue.
The final context is packaged by ordering the facts by their confidence scores and labeling the uncertain ones accordingly. The model is then provided with the selected facts, with flagged facts treated as preliminary information that requires additional scrutiny. A significant challenge faced in the retrieval layer is handling entities that the graph does not fully resolve, such as a smaller battery cell supplier mentioned in a procurement document.
The system currently lacks a mechanism to flag these unreferenced entities at the retrieval stage, indicating an area for improvement in future development.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.