Graph RAG: Bring the Power of Graphs to Generative AI

September 10, 2024 | 5 minute read
Text Size 100%:

AI and generative AI are transforming the way technology works. Vast amounts of data can be analyzed and understood in seconds. Human language can be used to ask questions about data. Tedious work can be automated. 

Generative AI can answer questions in human language on a wide range of topics, from news to writing code. To do so, it depends on Large Language Models (LLMs) that are trained on available data. But how about data the LLM has not been trained on, such as your own business data? How can we use the power of generative AI on such data? We have the answer – Graph RAG. And Oracle has made harnessing the power of Graph RAG much easier. 

RAG and Graph RAG

Retrieval Augmented Generation (RAG or Vector RAG) can enhance the user query to an LLM (the prompt) by searching business data and adding relevant information to the user query. A user query in human language can be converted to a vector and used to search business data in a database. The user query enhanced with results from the vector search in the database (the enhanced prompt) can be input to the LLM which can then output useful results in human language even though it was not trained on that data.  
Graph RAG adds a new dimension to enhancing the prompt by adding information on how entities in a user query are connected to other data entities (a graph). Graphs capture information on how data is related, which is difficult to capture with other data models. Some examples of the type of information a graph can capture are:
•    Connections in a social media network 
•    Flow of money in a financial network
•    Paths in a supply chain
and so on.

Graph RAG in Action

Consider this example:  a streaming company called MovieStream wants to make movie recommendations to increase customer usage of their service. An LLM can find movies of a specific genre, or with a specific plot, or from a specific era. But for Adriana, a target customer, the LLM does not have Adriana’s prior movie-watching history, or Adriana’s social network in the context of movie watching:  whom has she watched movies with, what types of movies has she watched with the same set of friends, what types of movies has she watched with her family, and so on. MovieStream does have this information in its own proprietary business data, and it’s extremely valuable for making better, more targeted movie recommendations. Also, this information is best represented as a graph. This practical application of Graph RAG in making targeted movie recommendations is just one of the many inspiring ways Graph RAG can enhance AI use cases.

MovieStream graph of Adriana's social network's movie watching history

Graphs are powerful as they help capture and navigate relationships in data, which in this example is the relationship between customers and movies and between customers when they watch movies together. Instead of a generic recommendation using demographic information, MovieStream can make more informed recommendations based on the movie-watching preferences of a customer’s social network. 

Graph RAG Made Easy

How can such a graph be created? Typically, this has been difficult and cumbersome.  Organizations first identify a specialized graph database and then move data to this silo-ed database. Once deployed, they may have additional challenges, like dealing with incomplete security and governance features or keeping data up to date. By contrast, none of this is necessary with Oracle Database. 
In Oracle Database 23ai, you can create an Operational Property Graph from your existing Oracle tables. Using tables and columns in the database that already have implicit relationships, Operational Property Graph lets you make these relationships in the data explicit with just a simple SQL statement. The new no-code modeling support of Operational Property Graph in Autonomous Database’s Graph Studio makes this even easier. There is no code to write – you can point and click to identify the tables that contain the data for your graph and then click on ’create graph.’ The relationships in data are automatically derived and made explicit during this graph creation process.

Additional Applications of Graphs in GenAI

In addition to combining Operational Property Graphs and RAG, as we’ve just described, there are several other impactful uses of graphs when developing applications with generative AI:   

Multi-modal Connections in Data

Graphs also make it easy to connect different types of data. For example, consider law enforcement tracking down a potential bad actor.  Person A could have been tracked in a video clip from a CCTV camera, and an audio clip exchanging a few words with Person B. Person B may be associated with a crime report document. Searching through text, images, and videos would be non-trivial for pure vector search. In a graph, however, these different modalities can be linked together, enabling developers to connect and blend multiple data types in AI applications

Knowledge Graph for Improved Information Retrieval

A hot topic within generative AI research is using an LLM to create a knowledge graph from documents and then using a knowledge graph to improve the quality of an LLM output.
Knowledge graphs help capture relationships that relate to concepts and entities of the human world.   For example, “Python is a popular language for Data Scientists” can be a relationship in a knowledge graph. Or the fact that “Data Science, Statistical Analysis, LLMs, and NLP are sub-topics of AI/ML” can be a set of relationships, as described here. Business facts can be leveraged to define relationships in data so that an LLM returns results based on these business facts and the structure of the relationships between them, making it easy for developers to build AI applications that can be more accurate and relevant to the business.

Conclusion

Oracle continues to build cutting-edge innovations directly into Autonomous Database as generative AI technology continues to advance, so you don’t need to move your data elsewhere to gain AI capabilities – You  can quickly and easily take advantage of new insights and analytics. Oracle Graph offers a unique set of capabilities that support operational property graphs and RDF knowledge graphs along with all other modern data types, including vector, spatial, and JSON, all within a single database. Let Oracle Graph exploit business context in your data by analyzing complex relationships in data for generative AI-driven development.

Melliyal Annamalai

Melli Annamalai is a distinguished product manager at Oracle.  Starting from her career as a developer, she has extensive experience in working with different types of data in the database, including multimedia data, data in Apache Hadoop platforms, streaming data, property graphs, and RDF knowledge graphs.  Her current focus area is graph database and analytics, in particular on ways to make it easy for developers to use graphs in any application.


Previous Post

Oracle Database and Google Cloud Services accelerate application development and cloud migrations with the general availability of Oracle Database@Google Cloud

Kambiz Aghili | 7 min read

Next Post


Announcing New Oracle Autonomous Database Data Studio AI Capabilities

Mike Matthews | 6 min read