4 min read

Google (PaLM2) Gen AI Bot with Neo4J and BigQuery

Google (PaLM2) Gen AI Bot with Neo4J and BigQuery
I have long been a fan of graph databases, and Neo4j is one of the leading graph database management systems available today. For those who may be unfamiliar with graph databases, they are a type of database that stores data in the form of nodes and relationships. Nodes represent entities, such as people, places, or things, while relationships represent the connections between entities.

In today's data-driven world, it is more important than ever for organizations to be able to make sense of their data. Graph databases are well-suited for this task, as they can easily model complex relationships between data points. This makes them ideal for a wide range of use cases, including:

  • E-commerce: Graph databases can be used to store data about products, customers, and orders. This makes it possible to quickly and easily find products that are similar to a product that a customer is interested in, or to find customers who have bought similar products in the past.
  • Log analysis: Graph databases can be used to store data about website traffic, server logs, and other types of logs. This makes it possible to identify patterns in the data, such as which pages are most popular or which users are most active.
  • Fraud detection: Graph databases can be used to store data about transactions, customers, and other types of data. This makes it possible to identify patterns that suggest fraud, such as multiple transactions from the same IP address or multiple transactions for the same product in a short period of time.
In this article, I will highlight the integration between Google's Generative AI (Gen AI) and Neo4j. This integration allows users to import existing BigQuery tables into Neo4j and visualize the data. The results can then be written back into GCP and used to design a Q&A bot using PaLM2.

I will explore how to use PaLM2 to make sense of relationships discovered by Neo4j's Graph Data Science. I will assume that you have already uploaded the table into Neo4j. To start, I will leverage the Movie Database example, which is available as part of the sample documents. This example contains 171 nodes and 253 relationships (So its complex!).

At a high level, the visualization looks like this:

While you can filter the nodes by giving some commands, I thought why not use Google Vertex AI (PaLM2 for Chat) to upload the output code script and then answer some questions.

This is the raw table (Code) format that I am going to use in my Vertex Gen AI Studio:

I then logged into my Gen AI Studio and worked my way to Language Model

I then provided the below context

And then I started asking more questions ‌
Amazing! The code reads it and provides the perfect answer. Here is a visual comparison
Here is another question that I asked:
And here is the visual confirmation!
And lastly, I asked a bit more tough question to see if this can make sense of it and it did!
And now with the click of a button you can open this in Collab, as i have done here and embed this chatbot and create your own application!


Conclusion

The idea that I want to share with you with this example is democratization of information. In the past, only data scientists and engineers had access to the power of graph databases and large language models. But with the integration of Neo4J, BigQuery, and Google Vertex AI (PaLM2), this technology is now accessible to business users who can use it to make better decisions.

I believe this gives us a glimpse into what the future of large language models looks like. In the future, large language models will be able to access and process information from a variety of sources, including graph databases, to provide users with insights that were previously impossible. This will empower users to make better decisions and solve problems more effectively.

I hope you found this article helpful. If you have any questions, please feel free to contact me.