<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Franciscofarinasalguero on Medium]]></title>
        <description><![CDATA[Stories by Franciscofarinasalguero on Medium]]></description>
        <link>https://medium.com/@franciscofarinasalguero?source=rss-8264e04c8891------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*eEtCSDOIr-CTXRyp</url>
            <title>Stories by Franciscofarinasalguero on Medium</title>
            <link>https://medium.com/@franciscofarinasalguero?source=rss-8264e04c8891------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 09:15:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@franciscofarinasalguero/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[GraphRAG: Enhancing RAG systems with Knowledge Graph Capabilities]]></title>
            <link>https://medium.com/syntonize/graphrag-enhancing-rag-systems-with-knowledge-graph-capabilities-dc1cbd282783?source=rss-8264e04c8891------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc1cbd282783</guid>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[graphrag]]></category>
            <dc:creator><![CDATA[Franciscofarinasalguero]]></dc:creator>
            <pubDate>Wed, 11 Jun 2025 16:42:43 GMT</pubDate>
            <atom:updated>2025-06-11T16:42:43.504Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we explore the concepts of Retrieval-Augmented Generation (RAG) and Knowledge Graphs, and how combining them leads to a powerful new paradigm: GraphRAG. By integrating knowledge graph retrieval into a RAG system, language models can access a richer, more robust, and more structured context. This approach enhances traditionald RAG applications by enabling deeper reasoning across interconnected and diverse information sources.</p><h3>Review: How a RAG System Works</h3><p>Retrieval-Augmented Generation (RAG) is a framework that augments a language model with an external knowledge retrieval mechanism to improve factual correctness and scalability in knowledge-intensive tasks such as question answering or summarization. By storing relevant information to the task at hand in an external database, we can take advantage of the reasoning power and general knowledge of state-of-the-art LLMs, while making sure that the LLM is working on updated, relevant information, reducing hallucination and guiding the LLMs to the right topics and sources.<br> In a way, a RAG system is very much like pairing a very smart student with a knowledgeable professor that will understand the student’s tasks and provide him with the right bibliography that will allow the student to complete his task and reach his own conclusions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H5gOsv86PxoOBLHqJ3TGaA.png" /></figure><p>A typical RAG system works in two main stages:</p><h4><strong>Retrieval Stage (the role of the knowledgeable Professor):</strong></h4><p>Given an input query (e.g. a question), the system uses a retriever — usually a dense vector retriever like DPR (Dense Passage Retriever) — to search a large corpus (e.g. Wikipedia) and retrieve the most relevant documents or passages. In the same way a professor might use its knowledge to understand the question and then go to the library and pick the relevant books to answer the question, typical RAG retrievers have a similar mechanism. The trick is to embed the question into a vectorial representation (also called embeddings) and then use a very fast operation (like cosine similarity) to compare it against the embeddings of all the documents stored in the database.</p><h4><strong>Generation Stage (the role of the brilliant student):</strong></h4><p>The retrieved documents are passed to a generator, like a Large Language Model, paired with the original task to be carried (like a question to be answered). Then the LLM is able to answer the question taking into account the most relevant information stored in our database.</p><p>As cool as RAG systems are, they still have their limitations, namely they tend to only be as good as their retrieval mechanism. For complex tasks such as analytical or reasoning tasks that should take into account multiple sources of information, or multiple facts that are distributed over the database, the simple similarity-based retrieval mechanism quickly falls short, unable <strong>to</strong> capture the whole breadth of documents in the database that would be required to complete the task.</p><p>One example of this kind of task in which RAG fails to deliver would be asking the question “What are the main themes in the dataset?” The more numerous and diverse the sources of information the Generator needs to complete the task, the more problems the Retriever will face.</p><p>Going back to our student-professor analogy, if instead of an undergrad-level essay we have a PhD student trying to write his thesis, we can see how a simple trip to the university library <strong>won’t</strong> be enough to provide the student with sufficient information. A more complex way of finding the right publications is required, like academic search engines and citation databases. These tools have the advantage of presenting the corpus of knowledge in an interconnected representation, where the researcher can navigate a web of publications connected by citations.</p><p>This is where Knowledge Graphs take the spotlight.</p><h3>Knowledge Graphs</h3><p>A graph is a common data structure used in computer science that stores data as a set of nodes connected by edges. A <strong>Knowledge Graph</strong> uses this data structure as a means of storing information where nodes represent concepts (known as <strong>Entities</strong>) and edges represent how these concepts relate to each other (their <strong>Relationships</strong>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9n-ZYn8KB_YhGmy9XTlfOw.png" /><figcaption>Simple example that covers some USA facts from WWII</figcaption></figure><p>What makes a Knowledge Graph more than just a generic graph is the presence of semantic meaning — this is where <em>ontologies</em> play a critical role.</p><p>An <strong>ontology</strong> is a formal and explicit specification of a shared conceptualization. In the context of a Knowledge Graph, an ontology defines the types of entities that can exist, the properties that describe them, and the relationships that can exist between them.</p><p>The ontology provides a schema or vocabulary for the graph, ensuring that data is structured in a meaningful and interoperable way. It answers questions like:</p><ul><li><em>What kinds of entities can exist in the graph?</em></li><li><em>What relationships can exist between them?</em></li><li><em>What attributes or properties does each entity have?</em></li></ul><p>For a simple example, we can define the following ontology to create a graph about actors and events in WWII.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*v4lj-_F9KEL6UfMmGzKGEA.png" /></figure><h4>Constructing Knowledge Graphs from Unstructured data.</h4><p>We already know the constituents of Knowledge Graphs: <strong><em>Entities</em> </strong>and <strong><em>Relationships</em></strong>, and know the rules of the game as designed in our <strong><em>Ontology</em></strong>. But how might we extract these constituents from our knowledge base, and use them to create a graph from scratch or update our existing graph? The approach will differ slightly depending on whether we are working with structured or unstructured data.</p><p>The general steps (which can generally be performed by an LLM) to construct a Knowledge Graph from unstructured data are:</p><ul><li><strong>Named Entity Recognition (NER)</strong> to identify entities like people, places, and organizations.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*-W4DqMGZMF3sGwHvTsJgow.png" /></figure><ul><li><strong>Relation Extraction</strong> to find connections between entities,</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*UhMzu96_ZhY2OgPFTQYBOw.png" /></figure><ul><li><strong>Coreference Resolution</strong> to ensure different mentions of the same entity are linked.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*Fvqx4QBsp371HN5HrFL5DA.png" /></figure><p>Once we have our list of entities and relationships, which follow the designed ontology, we can use them to create our graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bREbC6Jcg5RgHNoG4flTfg.png" /></figure><p>*When working with structured data, the entities and relationships tend to be explicitly or implicitly defined. The approach for entity and relation extraction will differ depending on the format of our unstructured data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CC2mccdXyVwsQAMbfFPf3Q.png" /></figure><h3>Graph operations</h3><p>The power of having a graph representation of knowledge is that we can then benefit from a number of graph operations and measures which exploit the nature of this data structure to aggregate information, extract complex insights from it, and find deeper relationships between seemingly unrelated pieces of knowledge. These operations make a Knowledge Graph a suitable information retrieval mechanism for a RAG system.</p><p>The GraphRAG paradigm consists <strong>of</strong> extracting information from our Knowledge Graph <strong>to</strong> augment the prompts to our LLM generator with useful information.</p><p>Although not the main topic of this article, thus why they will <strong>not </strong>be covered in any detail, I find it useful to know some of these operations which prove useful when working with knowledge graphs. These operations and <strong>measures </strong>give us ways of extracting information from our graph to provide to our generator.</p><p>A non-exhaustive list of some important operations one should aim to understand are:</p><h4><strong>Graph Traversals</strong></h4><p>Graph traversal is the process of visiting nodes in a graph by following edges according to some logic or strategy. At each step, we move from one node to another by selecting an adjacent node through one of its edges. The steps involved are:</p><ol><li><strong>Selecting a starting node</strong>: This can be done randomly or based on a specific criterion, such as the similarity between a node’s text content and a user query.</li><li><strong>Traversing the graph</strong>: Step by step, we choose the next node to visit, often based on heuristics, edge weights, or similarity scores.</li><li><strong>Determining a stopping criterion</strong>: We stop traversing when a condition is met, such as reaching a fixed number of steps, covering a desired amount of information, or meeting a semantic threshold.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/0*FC_GTTKRoTYn0KQh.gif" /></figure><h4><strong><em>Pathfinding</em></strong></h4><p>Find the shortest or most relevant path between two nodes, extacting relevant information from each node in the shortest path. The steps involved are:</p><ol><li>Selecting start and end nodes</li><li>Finding the shortest path betwen them thorugh path finding algorithms</li><li>Aggregate the information present in all the nodes that from the path between the start and end nodes.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/0*d_2Vra5toLwaudCr.gif" /></figure><h4><strong><em>Neighborhood Aggregation</em></strong></h4><p>Gathering information from neighboring nodes, that is, all nodes connected to a single node. We can get different depth neighborhoods by aggregating “neighorgs of neighbors” as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/0*Rv_jmeIOX5TkkL_t.gif" /></figure><h4><strong><em>Centrality Measures</em></strong></h4><p>Identify important nodes in the graph. Centrality measures help prioritize which knowledge is more influential or central.</p><p><em>Degree Centrality</em>: How many connections a node has. In-Degree reflects how many incoming edges a node has, while out-degree reflects how many outgoing edges a node has.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*V6t90dSKJcMd0n-d.png" /><figcaption><a href="https://jacobjameson.com/posts/2022-11-01-SNA/2022-11-01-SNA.html">https://jacobjameson.com/posts/2022-11-01-SNA/2022-11-01-SNA.html</a></figcaption></figure><p><em>Betweenness Centrality</em>: how many shortest paths between nodes in the network pass through each node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tZuTrF3yIDKCd9qK.png" /><figcaption><a href="https://jacobjameson.com/posts/2022-11-01-SNA/2022-11-01-SNA.html">https://jacobjameson.com/posts/2022-11-01-SNA/2022-11-01-SNA.html</a></figcaption></figure><h4><strong><em>Community Detection</em></strong></h4><p>Community detection is the process of identifying clusters or groups of nodes in a graph that are more densely connected internally than with the rest of the network. These <strong>communities</strong> often represent meaningful structures such as similar topics, user groups, or document clusters. Two well-known algorithms for community detection are:</p><p><em>Louvain Algorithm: </em><strong>modularity-based algorithm</strong> that detects communities by maximizing modularity — a measure of the density of edges inside communities versus between them.</p><p><em>Leiden Algorithm: </em>improves on Louvain by <strong>guaranteeing well-connected communities</strong> and avoiding disconnected components. It also converges faster and is more stable. Like Louvain, it optimizes modularity but with an extra refinement step to ensure better community quality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*32pLPO7hoYgsx3ZV" /><figcaption><a href="https://flowkit.readthedocs.io/en/stable/notebooks/advanced/clustering_comparison_leiden_vs_louvain.html">https://flowkit.readthedocs.io/en/stable/notebooks/advanced/clustering_comparison_leiden_vs_louvain.html</a></figcaption></figure><h3>GraphRAG: Knowledge Aggregation through Community Detection and Summarization</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*bbgnpDWx3b3Kih2D.jpg" /><figcaption><a href="https://microsoft.github.io/graphrag/">https://microsoft.github.io/graphrag/</a></figcaption></figure><p>GraphRAG (Graph Retrieval-Augmented Generation) is a Microsoft-proposed enhancement to standard RAG systems that incorporates a Knowledge Graph and leverages various graph operations. It emphasizes knowledge aggregation through community detection and summarization to improve the quality of retrieved context for generation.</p><ol><li><strong>Graph Construction</strong>: Nodes and edges are created using entity and relationship extraction methods. The number of <strong>coreferences</strong> for a relationship is used as <strong>edge weights</strong>, capturing the strength or frequency of connections.</li><li><strong>Community Detection</strong>: Using the Leiden algorithm, GraphRAG identifies dense subgraphs or communities within the retrieval graph. These represent semantically coherent clusters of content likely to address the query from similar or complementary perspectives.</li><li><strong>Cluster-wise Summarization</strong>: For each detected community, the system performs targeted summarization, producing a concise representation of the knowledge in the cluster. The result is a list of community-level summaries.</li><li><strong>Community Answers</strong>: Given the community summaries and the user’s question, a Large Language Model generates an answer per community.</li><li><strong>Global Answer</strong>: Finally, the LLM aggregates all community answers into a single, comprehensive response.</li></ol><p>By aggregating knowledge through graph-based techniques, GraphRAG reduces redundancy, improves coverage, and enables more informative responses — especially for complex or multi-faceted queries. This method demonstrates substantial improvements over traditional RAG baselines in both comprehensiveness and diversity of generated answers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc1cbd282783" width="1" height="1" alt=""><hr><p><a href="https://medium.com/syntonize/graphrag-enhancing-rag-systems-with-knowledge-graph-capabilities-dc1cbd282783">GraphRAG: Enhancing RAG systems with Knowledge Graph Capabilities</a> was originally published in <a href="https://medium.com/syntonize">Syntonize</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>