GraphRAG vs. traditional RAG: Unveiling Avengers data secrets
What if we could delve deeper into the world of Avengers with cutting-edge AI? Can traditional keep up with the intricate relationships of our favorite superheroes? How can graph-based methods uncover hidden connections among the Avengers?
The goal of this article is to provide an answer to these questions. Let’s start with an understanding of the rationale behind graph-based methods.
Understanding RAG
(RAG) has been instrumental in leveraging the power of Generative AI models. The journey began with the recognition of the capabilities of foundational models, which then were enriched with domain-specific data to enhance their performance. This enrichment process paved the way for RAG and the decisive step of fine-tuning these models with specific datasets.
Traditional RAG solutions have relied predominantly on vector databases. These databases store data as high-dimensional vectors, allowing for efficient similarity search. By transforming texts into embeddings, vector databases enable quick retrieval of relevant information based on the proximity of vectors in the embedding space.
However, vector databases come with inherent challenges:
Relationship discovery: While vector databases excel at finding similar items, they often struggle to uncover deeper relationships among data points.
Large content handling: The usage of embeddings is limited by the context window size of the model, which means that large documents or datasets can be challenging to manage and query effectively.
Model training: The models are not inherently trained with your data but use embeddings as contextual inputs, which can limit their understanding and reasoning capabilities.
Exploring graph-based alternatives
Graph-based approaches offer a promising alternative to traditional vector-based RAG solutions. By structuring data into graphs, it’s possible to uncover intricate relationships among entities and concepts that vector databases might miss. Graph-based methods offer significant advantages and should be considered before resorting to extensive model fine-tuning, which can be expensive.
In the world of graph-based solutions, Microsoft Research has developed GraphRAG (), which represents a significant advancement in the realm of RAG by integrating knowledge graphs with LLMs. What follows is how GraphRAG enhances document search and knowledge discovery.
Document search and knowledge graph creation
GraphRAG leverages Large Language Models (LLMs) to create knowledge graphs from input documents. These graphs are then used to organize data hierarchically into semantic clusters, enabling more intuitive and effective search and retrieval.
Key process steps in GraphRAG include:
- Chunk data, vectorize it, and store it in a vector database.
- Chunk data, scan data to extract entities (mainly nouns) and their relationships using LLMs to detect them.
- Create a graph where entities are nodes and relationships are edges.
- The graph is “colored” with the data retrieved in step 1, which means that the data in the graph is clustered hierarchically to create communities (clusters) in several layers.
Query-focused summarization (QFS)
At query time, GraphRAG utilizes the pre-built structures to provide relevant materials for the LLM context window. This is executed through:
- Global search: For deducing answers to questions by utilizing community-generated summaries.
- Local search: For analyzing specific entities through investigation of their neighboring nodes and related concepts.
These strategies enable GraphRAG to function with reduced latency in comparison to conventional context window–based data, as it depends on memory-based operations instead of transferring extensive datasets through the context window.
Demo
Understanding the concepts is just the beginning; now, let’s see them in action! We explore two compelling examples: one leveraging a GraphRAG solution and the other utilizing a traditional RAG connected to identical vectorized data, but without the graph overlay.
Prerequisites
- Dataset: Both examples utilize the same dataset, comprising .txt files containing the scripts of several Avengers films ().
- Core technologies: Each solution employs as the primary language model and for data vectorization within Azure AI Search.
- GraphRAG implementation: The GraphRAG solution is built using the GitHub repository , which offers a deployment of a knowledge graph–powered RAG in Azure.
- Traditional RAG implementation: The traditional RAG is constructed using Azure AI Studio, integrating hybrid and semantic search functionalities.
Results
Let’s compare how both solutions behave under the same questions. I have tested four questions with the idea of seeing how different the answers are. For GraphRAG, I have tested global and local queries.
- Who is Ant Man?
- Who is the most popular Avenger?
- Which superpowers do Hulk and Captain America have in common?
- Which Avengers live in the same city?
Outputs
1. Who is Ant Man?
Traditional RAG:
GraphRAG — global query:
### Overview of Ant-Man
Ant-Man, whose real name is Scott Lang, is a multifaceted character known for his dual identity as both a regular person and a superhero. He is a central figure in various critical operations and missions, leveraging his unique ability to shrink and grow in size, which is facilitated by the Ant-Man suit [Data: Reports (18, 19, 25)].
### Key Roles and Missions
Scott Lang plays a pivotal role in several high-stakes missions. He is a key participant in a highly secretive operation called The Mission, where he utilizes his skills as a thief to retrieve a prototype of a signal decoy [Data: Reports (21)]. Additionally, he is central to the Time Travel Test, being the individual sent back in time and brought back, with the success of the experiment hinging on his experience and safety [Data: Reports (23)]. His technical expertise is also crucial for getting the Time Machine operational, underscoring his importance to the mission’s success [Data: Reports (56)].
### Relationships and Mentorship
Scott Lang has a mentor-mentee relationship with Dr. Hank Pym, who guides and trains him for important missions. This relationship highlights Scott’s growing confidence and understanding of the mission’s objectives [Data: Reports (24)]. He also has a complex relationship with Darren Cross, marked by both adversarial and cooperative dynamics, which is crucial for the mission’s success [Data: Reports (21)].
### Personal Connections and Community Involvement
Scott is deeply involved in his community, interacting with significant characters like Tony Stark and the Avengers. His admiration and respect for Captain America are notable, highlighting the influence Captain America has on him [Data: Reports (85)]. Despite his superhero duties, Scott maintains personal connections, such as being thanked by Luis for saving his life, indicating moments of heroism and deep connections within his community [Data: Reports (20)].
### Challenges and Personal Struggles
Scott Lang’s history of crime and his current house arrest status present legal and ethical challenges for his community. Despite these challenges, his commitment to his missions and his desire to provide for his daughter Cassie drive his actions [Data: Reports (18)]. His experience of being trapped in the quantum realm for five years, which felt like only five hours to him, is a pivotal event in his life. This incident, referred to as the Quantum Realm Incident, was caused by Thanos’s actions and has driven Scott to seek control over the chaos of the quantum realm [Data: Reports (25)].
### Conclusion
Ant-Man, or Scott Lang, is a complex and essential character within his community and the broader superhero landscape. His unique abilities, critical roles in high-stakes missions, and personal connections make him a key figure in the ongoing efforts to maintain balance and order in a world filled with extraordinary challenges [Data: Reports (18, 19, 21, 23, 25, +more)].
CPU times: user 122 ms, sys: 8.77 ms, total: 131 ms
Wall time: 33.8 s
GraphRAG — local query:
# Ant-Man: A Comprehensive Overview
## Introduction
Ant-Man, also known as Scott Lang, is a multifaceted superhero within the Marvel Universe. His unique ability to shrink and grow in size, thanks to a specialized suit, sets him apart from other heroes. Despite being less popular compared to figures like the Hulk, Ant-Man plays a significant role in various conflicts and missions [Data: Entities (208, 204, 186, 214, 1242)].
## Scott Lang’s Background
Scott Lang, the man behind the Ant-Man persona, has a complex history marked by both personal and professional challenges. Initially a criminal, Lang was given a choice between staying in prison or taking on the role of Ant-Man. His technical skills, particularly in bypassing advanced security systems, made him a suitable candidate for the Ant-Man suit [Data: Entities (204, 186)].
Lang’s personal life is also intricate. He has a strained relationship with his family, particularly due to his failure to pay child support. Despite these challenges, Lang is deeply committed to his daughter, Cassie, and strives to be a part of her life [Data: Entities (214, 186)].
## The Ant-Man Suit
The Ant-Man suit, developed by Dr. Hank Pym, is central to Scott Lang’s superhero identity. This suit allows the wearer to change size, becoming either incredibly small or significantly larger. The suit’s capabilities are enhanced by the Pym Particle, a groundbreaking discovery by Dr. Pym that alters the distance between atoms [Data: Entities (309, 181, 185); Relationships (705, 694)].
## Key Relationships
### Hank Pym
Dr. Hank Pym, the original Ant-Man and the creator of the Pym Particle, serves as a mentor to Scott Lang. Pym’s research and the legend of Ant-Man inspired further advancements in shrinking technology. Despite some tension, Pym’s guidance is crucial to Lang’s development as Ant-Man [Data: Entities (180, 181, 185); Relationships (705, 694, 678)].
### The Avengers
Ant-Man is a member of the Avengers, participating in various high-stakes missions alongside other superheroes. His interactions with characters like Clint Barton (Hawkeye) and Bruce Banner (Hulk) highlight his role within the team. Despite being less recognized, Lang’s contributions are vital to the Avengers’ success [Data: Relationships (831, 835, 833)].
This report provides a detailed overview of Ant-Man, supported by multiple data references [Data: Entities (208, 204, 186, 214, 1242); Relationships (705, 694, 678, 831, 835, 833, 455); Sources (372, 467)].
CPU times: user 37.7 ms, sys: 22.7 ms, total: 60.4 ms
Wall time: 23.6 s
2. Who is the most popular Avenger?
Traditional RAG:
GraphRAG — global query:
### Popularity Among the Avengers
Determining the most popular Avenger involves considering various factors such as leadership, technological contributions, physical prowess, and public interactions. Based on the dataset, Tony Stark (Iron Man), Steve Rogers (Captain America), and Bruce Banner (Hulk) emerge as the most prominent figures, each with unique attributes that contribute to their popularity.
#### Tony Stark (Iron Man)
Tony Stark, also known as Iron Man, is a pivotal figure in the Avengers community. His technological innovations, such as the creation of the Iron Man suit and the miniaturized arc reactor, are crucial to the Avengers’ operations. Stark’s leadership and strategic planning are evident in high-stakes missions, including securing the sceptre and combating Ultron. His interactions with other key figures like Thor and Captain America, as well as his influence on global security, underscore his significant role [Data: Reports (50, 69, 80)].
#### Steve Rogers (Captain America)
Steve Rogers, also known as Captain America, is another central figure in the Avengers. His leadership and authoritative role are frequently highlighted through direct interactions with other characters. Rogers is deeply involved in critical missions and operations, preparing for confrontations and strategizing defense efforts. His view of the Avengers as a family and his moral compass are central to the team’s dynamics [Data: Reports (69, 82)].
#### Bruce Banner (Hulk)
Bruce Banner, also known as the Hulk, contributes both his scientific expertise and immense physical power to the Avengers. Despite his reluctance to fight, Banner’s value in high-stakes situations is frequently emphasized. His popularity is also highlighted by his interactions with fans, often referred to as Mr. Hulk and known for taking photos with kids [Data: Reports (31, 80)].
### Conclusion
While all three Avengers — Tony Stark, Steve Rogers, and Bruce Banner — are highly popular and play crucial roles within the team, Tony Stark’s technological innovations and leadership qualities may give him a slight edge in terms of overall popularity. However, the dataset indicates that each of these characters has a significant and unique impact on the Avengers’ success and public perception.
CPU times: user 44.3 ms, sys: 0 ns, total: 44.3 ms
Wall time: 27.5 s
GraphRAG — local query:
# Most Popular Avenger: An Analysis
Determining the most popular Avenger involves examining various factors such as public perception, media representation, and the roles they play within the team. Based on the provided data, several key members stand out due to their significant contributions and public image.
## Key Contenders
### Tony Stark (Iron Man)
Tony Stark, also known as Iron Man, is a central figure in the Avengers. He is a genius inventor and a key member of the team, known for his technical expertise and involvement in high-stakes activities. Stark’s public identity as Iron Man and his role in creating JARVIS and Ultron highlight his importance. His transformation from a weapons manufacturer to a global peacekeeper underscores his dynamic character [Data: Entities (500, 13); Relationships (601, 410, 214, 130, 148)].
### Steve Rogers (Captain America)
Steve Rogers, also known as Captain America, is another pivotal member of the Avengers. He is recognized for his leadership, bravery, and moral integrity. As a super-soldier, he has been involved in numerous critical missions and is highly appreciated by the public. His role in significant events and his leadership qualities make him a central figure in the team [Data: Entities (514, 404, 280); Relationships (601, 410, 214, 130, 148)].
### Thor
Thor, the God of Thunder, is a prominent member of the Avengers known for his god-like strength and heroic deeds. His complex relationship with his brother Loki and his involvement in significant battles, such as the fight against Thanos, highlight his importance. Thor’s mythological roots and his journey of personal growth add depth to his character [Data: Entities (343, 567); Relationships (1185, 410, 411, 214, 272)].
### Bruce Banner (Hulk)
Bruce Banner, also known as the Hulk, is a central figure in the Avengers due to his immense strength and scientific expertise. His dual identity as Banner and the Hulk adds complexity to his character. Banner’s involvement in various missions and his technical insights make him an indispensable member of the team [Data: Entities (347); Relationships (601, 410, 214, 130, 148)].
## Public Perception and Media Representation
The Avengers are celebrated as heroes by many, but they are also viewed as vigilantes by some. This dual perception is influenced by their high-profile missions and the regulatory scrutiny they face under the Sokovia Accords [Data: Entities (250); Relationships (941, 948, 947)]. Despite internal discord and external threats, the Avengers remain symbols of heroism and hope [Data: Entities (250); Relationships (915, 937, 938)].
## Conclusion
While it is challenging to definitively determine the most popular Avenger, Tony Stark (Iron Man) and Steve Rogers (Captain America) are strong contenders due to their significant roles, public image, and media representation. Both characters have left a lasting impact on the team and the world they strive to protect.
Overall, the popularity of an Avenger can be subjective and may vary based on individual preferences and perspectives. However, the contributions and leadership of Tony Stark and Steve Rogers make them standout figures in the Marvel Universe.
CPU times: user 4.81 ms, sys: 22.1 ms, total: 26.9 ms
Wall time: 24 s
3. Which superpowers do Hulk and Captain America have in common?
Traditional RAG:
GraphRAG — global query:
### Common Super Powers of Hulk and Captain America
Hulk and Captain America share several superhuman abilities that set them apart from ordinary humans. These powers include superhuman strength, enhanced durability, and accelerated healing abilities.
#### Superhuman Strength
Both Hulk and Captain America possess superhuman strength, which allows them to perform feats of physical power far beyond the capabilities of a normal human. This extraordinary strength enables them to lift heavy objects, engage in intense combat, and perform other physically demanding tasks with ease [Data: Reports (34, 31, 71, 30, 85, +more)].
#### Enhanced Durability
In addition to their immense strength, Hulk and Captain America have enhanced durability. This makes them highly resistant to physical damage and capable of withstanding extreme conditions and significant impacts that would severely injure or kill a normal human. Their enhanced durability allows them to endure intense battles and harsh environments without sustaining serious injuries [Data: Reports (34, 31, 71, 30, 85, +more)].
#### Accelerated Healing Abilities
Another shared power is their accelerated healing abilities. Both characters can recover from injuries much faster than an average human. This rapid healing process enables them to quickly bounce back from wounds and continue fighting or performing other activities without prolonged downtime [Data: Reports (34, 31, 71, 30, 85, +more)].
### Conclusion
In summary, Hulk and Captain America share the superhuman abilities of strength, durability, and accelerated healing. These powers not only make them formidable opponents in combat but also allow them to endure and recover from extreme physical challenges that would be insurmountable for ordinary humans.
CPU times: user 55 ms, sys: 8.66 ms, total: 63.7 ms
Wall time: 17.4 s
GraphRAG — local query:
# Super Powers of Hulk and Captain America
## Introduction
Hulk and Captain America are two of the most iconic members of the Avengers, each possessing unique abilities that make them formidable heroes. Despite their differences, they share some common superpowers that contribute to their effectiveness in battle and their roles within the team.
## Common Super Powers
### Enhanced Strength
Both Hulk and Captain America possess superhuman strength, although the extent of their strength varies significantly. Hulk’s strength is virtually limitless and increases with his anger, making him one of the strongest beings in the Marvel Universe. Captain America, while not as strong as Hulk, has enhanced strength due to the Super Soldier Serum, allowing him to perform feats far beyond the capabilities of a normal human [Data: Entities (351, 568, 506, 404, 880)].
### Enhanced Durability
Hulk and Captain America both have enhanced durability, enabling them to withstand significant physical damage. Hulk’s skin is nearly impenetrable, and he can endure extreme conditions without sustaining injuries. Captain America’s enhanced durability allows him to survive impacts and injuries that would be fatal to ordinary humans, making him resilient in combat [Data: Entities (351, 568, 506, 404, 880)].
### Accelerated Healing
Both heroes have accelerated healing abilities. Hulk can recover from injuries at an astonishing rate, often healing almost instantaneously. Captain America’s healing is not as rapid as Hulk’s but is still significantly faster than that of a normal human, allowing him to recover from wounds and fatigue more quickly [Data: Entities (351, 568, 506, 404, 880)].
## Unique Abilities
### Hulk
- **Transformation**: Hulk’s most distinctive power is his ability to transform from Bruce Banner into the Hulk, a massive green-skinned being with immense strength and rage [Data: Entities (351, 506, 347)].
- **Limitless Strength**: Hulk’s strength increases with his anger, making him potentially the strongest being in the Marvel Universe [Data: Entities (351, 506, 347)].
### Captain America
- **Peak Human Condition**: The Super Soldier Serum has enhanced all of Captain America’s physical attributes to the peak of human potential, including his agility, reflexes, and endurance [Data: Entities (568, 404, 880)].
- **Strategic Genius**: Captain America is also known for his exceptional leadership and strategic skills, making him an invaluable leader in battle [Data: Entities (568, 404, 880)].
This report summarizes the common and unique superpowers of Hulk and Captain America, supported by data from various sources [Data: Entities (351, 568, 506, 404, 880); Relationships (1306, 1260, 917, 1305, 1313, +more)].
CPU times: user 24.1 ms, sys: 0 ns, total: 24.1 ms
Wall time: 18.1 s
4. Which Avengers live in the same city?
Traditional RAG:
GraphRAG — global query:
### Avengers’ Residences
Based on the available data, the primary focus is on the Avengers’ involvement in managing a significant crisis in New York City. However, specific details about the residences of individual Avengers are not comprehensively covered in the dataset.
### New York City
New York City is the central location where the Extraterrestrial Attack has taken place, involving significant violence and a substantial military presence. The Avengers are actively responding to this crisis, highlighting their critical role in managing the situation [Data: Reports (6)]. This suggests that many Avengers may be based in or around New York City due to their immediate response capabilities.
### Doctor Strange
Doctor Strange is mentioned to have lived in Toronto and has a place in The Village, indicating that he resides in The Village [Data: Reports (101)]. This information does not directly link him to New York City but provides insight into his residential locations.
### Conclusion
While the dataset confirms the Avengers’ active presence in New York City during the crisis, it does not provide specific details on which Avengers live in the same city. The only individual residence mentioned is that of Doctor Strange, who resides in The Village. Further data would be required to accurately determine the residential locations of other Avengers.
CPU times: user 169 ms, sys: 1.25 ms, total: 170 ms
Wall time: 14.8 s
GraphRAG — global query:
# Avengers Living in the Same City
## Overview
The Avengers, Earth’s mightiest heroes, are known for their collective efforts to protect the world from various threats. They are a diverse group of superheroes, each with unique abilities and backgrounds. This report identifies which Avengers are known to live in the same city based on the provided data.
## Avengers and Their Cities
### New York
New York is a significant city for the Avengers, serving as a central hub for many of their activities. Several key members are associated with this city:
- **Tony Stark (Iron Man)**: Stark Tower, a prominent location in New York, serves as a base of operations for Tony Stark and the Avengers [Data: Entities (87); Relationships (210, 129)].
- **Steve Rogers (Captain America)**: Captain America is also closely associated with New York, having been a native of Brooklyn before joining the Avengers [Data: Entities (250); Relationships (1019)].
- **Peter Parker (Spider-Man)**: Spider-Man, another member of the Avengers, is based in New York, where he operates as a local hero [Data: Relationships (1070)].
### Washington, D.C.
Washington, D.C. is another city where Avengers have been known to operate:
- **Sam Wilson (Falcon)**: Sam Wilson, also known as Falcon, is currently missing along with Captain Steve Rogers, but he has been associated with Washington, D.C. [Data: Entities (1216); Relationships (943)].
- **Tony Stark (Iron Man)**: Tony Stark has plans to travel to Washington, D.C., indicating his involvement in activities there [Data: Entities (502)].
### Lagos, Nigeria
Lagos is a city in Nigeria where significant events involving the Avengers have taken place:
- **The Avengers**: The team, including members like Tony Stark and Steve Rogers, has operated in Lagos, causing notable effects [Data: Entities (1151, 1147); Relationships (1076, 945)].
Conclusions
While both traditional RAG and GraphRAG perform similarly when addressing basic inquiries like “Who is Ant-Man?”, the true strength of GraphRAG shines through in more complex scenarios.
For instance, the question “Who is the most popular Avenger?” cannot be answered effectively with a traditionally configured RAG. Although improving the system prompt might lead to better results, it still falls short. In contrast, GraphRAG excels in handling such nuanced queries.
The question “Which superpowers do Hulk and Captain America have in common?” is more complete with GraphRAG than with traditional RAG.
The question “Which Avengers live in the same city?” again cannot be answered with traditional RAG, as it is not capable of understanding the relationship between Avengers and the locations presented. Comparing global and local queries in GraphRAG, despite global query being capable of identifying the relevance of New York City, local query goes deeper into the relationship among nodes, which means it can provide more detail about the locations mentioned in the films.
Although building a GraphRAG solution involves greater complexity, its ability to understand and elaborate on the relationships among files makes it invaluable for answering nuanced questions. Traditional RAG tends to rely on top-ranked files, which can limit the depth of its responses. In contrast, GraphRAG’s sophisticated understanding of interconnected data ensures more comprehensive and insightful answers, proving its worth in situations that demand more than just straightforward responses.
Other works
Recent developments around GraphRAG have led to a variety of solutions that are emerging to improve the quality of RAGs. Among these is the impressive OmniRAG, which intelligently selects the most suitable query method — whether it’s a direct query over CosmosDB’s , a vector search, or an in-memory graph search. This seamless adaptability marks a significant advancement in the field. For those interested in delving deeper into these cutting-edge developments, be sure to explore the comprehensive resources available on GitHub at or their explanatory video .
The future of RAG systems is bright, and these emerging technologies are just the beginning. What do you think about using graphs as RAG? I would be happy to hear your ideas about how to use them to solve real use cases. You can leave comments in the Comments section associated with this article.
Eva Jurado Cortés is on .