Three Ways Graphs Power AI

Susannah Plaisted
Salesforce Architects

--

Image showing the brain as a collection of nodes and lines
Credit: iStockPhoto

If you’re like me, you might not have thought very deeply about graphs in quite awhile. But graphs should be back on your radar because of the way they can be used to enhance machine learning. Read on to learn what capabilities graphs bring to the field of AI.

Why use graphs?

Every graph from the most basic to the more complex is made up of two things. Nodes (also known as vertices or points) and edges (or lines). The node is one of the data points or objects on the graph and the edge is the connection between it and another data point or object.

The two elements of a graph: node and edges
The two building blocks of a graph: node and edges

Graphs have been around since the 18th century, when Swiss mathematician Leonard Euler solved the Seven Bridges of Königsberg problem using one of the earliest known examples of graph theory. So why are they such a big deal right now when it comes to AI? Let’s take three examples:

1. Knowledge graphs for storing relationships

A knowledge graph, also known as a semantic network, represents a network of real-world entities — i.e. objects, events, situations, or concepts — and illustrates the relationship between them. This information is usually stored in a graph database and visualized as a graph structure, prompting the term knowledge “graph.” — IBM

Said simply, a knowledge graph represents the meaning of relationships between two objects. In a knowledge graph, the nodes represent entities (like people places, or events) and the edges represent the relationship between those entities. What makes knowledge graphs extra special is that they use a third element, often referred to as a predicate or an edge label, that describes the nature of the relationship.

Let’s take an example. If I were trying to represent that “Susannah works at Salesforce” in my knowledge graph there would be a node for me, and a node for Salesforce. They would be connected by an edge with the property of works at.

A simple example of representing a relationship on a knowledge graph
A simple example of representing a relationship on a knowledge graph

This type of graph provides a semantic structure to data. And having an efficient way for machines to ingest and model semantics, or the meaning of a words, is incredibly important to getting good responses from AI.

Complex knowledge graphs can be ingested by an AI application through natural language processing and then can be used as a really fast way to deliver responses to prompts in a generative AI use case or event to enhance predictive AI models like recommendation engines.

For our next example of how graphs can power AI, let’s focus on Data Graphs.

2. Data graphs for storing and retrieving at AI scale

So far we’ve been focusing graphs are really good at storing complex relationships. But graphs can also be an extremely efficient way to retrieve data, especially when you need to run real-time query on extremely large data volumes. Which makes Graphs the perfect tool to use in Data Cloud.

In Data Cloud there’s a concept called a Data Graph. A Data Graph is an object that stores the data lakehouse objects as nodes and the relationships between those objects as edges. From the Data Cloud UI, you could take several Data Model Objects (DMOs) that contain the Unified Individual, their purchase history, and their browsing history and generate a new Data Graph that takes the data from all three DMOs and transforms the hierarchical relationships between these relationships into a single flattened Data Graph record that contains both the metadata structure and its related data stored as a JSON object.

A screeb showing the Data Graph object in Data Cloud
The Data Graph object in Data Cloud

The Data Graph can be used for a graphical representation, but the real power is that this Data Graph is an additional “relationship” layer that sits on top of our data lakehouse. We can improve query processing time because we’ve offloaded some of the computations that would need to happen if we were to query the database directly. This is incredibly important when it comes to AI use cases where users will expect real-time responses that depend on querying across huge sets of data.

For the third and final example let’s discuss how to ground a prompt with a graph.

3. Graphs for better generative AI responses

Let’s stay with our Salesforce Data Graph for a moment. Data Cloud and Prompt Studio are both built on Salesforce, and when they are used together, they can help improve responses generated through the Einstein Generative AI Trust Layer. In coming releases, you will be able to take a Data Graph from Data Cloud and use it in Prompt Studio.

In practice, you will write your prompt in Prompt Studio, then select a Data Graph (represented as denormalized JSON) to be sent to the LLM as additional context. The LLM will then take the prompt and the data graph we sent to generate a better response, using a process called retrieval augmented generation or RAG.

Because our data graph is a denormalized JSON object we are able to send lots of related data from across multiple objects in data cloud along with our prompt. This is going to allow the LLM give a better response that takes into account a customer’s purchase history, maybe their browsing data or even an organization’s knowledge base even though they aren’t a part of the original prompt and the LLM has never been trained with any of the data graph data.

Conclusion

I hope these three examples have helped illustrate why you should care about graphs when it comes to AI and Salesforce and how different types of graphs can be used to do some pretty cool things in machine learning. Salesforce will be leveraging the techniques you just read about as it builds out its AI capabilities.

In fact one of the newest AI pilot features, Einstein Search Answers uses data graphs and retrieval augmented generation. And next year, you’ll be able to use Data Cloud’s data graphs to enhance your prompts. To explore more upcoming product innovations visit the Salesforce Roadmap Explorer on architect.salesforce.com.

References

--

--

Susannah Plaisted
Salesforce Architects

Lead Evangelist, Architect Relations at Salesforce. Words, thoughts and opinions are my own.