Skip to content

Commit

Permalink
GenAI Ecosystem Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jexp committed Apr 4, 2024
1 parent 3c00d32 commit 8bd17fc
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 13 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions modules/genai-ecosystem/nav.adoc
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
** xref:index.adoc[GenAI Ecosystem]
*** Cloud Examples
**** xref:aws-demo.adoc[AWS Demo]
**** xref:microsoft-azure-demo.adoc[Microsoft Azure Demo]
**** xref:google-cloud-demo.adoc[Google Cloud Demo]
**** xref:aws-demo.adoc[AWS Bedrock]
**** xref:microsoft-azure-demo.adoc[Microsoft Azure OpenAI]
**** xref:google-cloud-demo.adoc[Google Cloud Vertex AI]
*** Example Projects
**** xref:rag-demo.adoc[GraphRAG Demo]
**** xref:genai-stack.adoc[GenAI Stack]
**** xref:llm-graph-builder.adoc[LLM Graph Builder]
*** Neo4j GenAI Features
**** xref:vector-search.adoc[Vector Index and Search]
**** xref:apoc-genai.adoc[APOC GenAI]
Expand Down
25 changes: 22 additions & 3 deletions modules/genai-ecosystem/pages/google-cloud-demo.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,35 @@ include::_graphacademy_llm.adoc[]
:page-pagination:
:page-product: google-cloud-demo

////

== Deploying GenAI Applications and APIs with Vertex AI Reasoning Engine


////
== Graph Consumption with Gemini Pro
The xref:llm-graph-builder[LLM Graph Builder] that extracts entities from unstructured text (PDFs, YouTube Transcripts, Wikipedia) can be configured to use VertexAI both as embedding model and Gemnini as LLM for the extraction.
PDFs can be also be loaded from Google Cloud buckets.
It uses the underlying llm-graph-transformer library that we contributed to LangChain.
// TODO image
== SEC Filings GenAI Labs
This example consists of two sample applications that show how to use Neo4j with the generative AI capabilities in Google Cloud Vertex AI. We explore how to leverage Google generative AI to build and consume a knowledge graph in Neo4j.
* assetmanager - Parses data from the SEC containing quarterly filings of asset managers. We build a graph containing assets managers and the securities they hold. A chatbot that queries the knowledge graph is included as well.
* resume - Extracts entities like jobs and skills from a collection of resumes, then builds a graphs showing what talents individuals share. A chatbot that queries the knowledge graph is included as well.
== Installation
=== Installation
The Demo is available on GitHub: https://github.com/neo4j-partners/neo4j-generative-ai-google-cloud
== Relevant Links
=== Relevant Links
[cols="1,4"]
|===
| icon:github[] Code Repository | https://github.com/neo4j-partners/neo4j-generative-ai-google-cloud[GitHub]
Expand All @@ -27,7 +46,7 @@ The Demo is available on GitHub: https://github.com/neo4j-partners/neo4j-generat
| Press Release | https://neo4j.com/press-releases/neo4j-google-cloud-vertex-ai[Link]
|===
== Videos & Tutorials
=== Videos & Tutorials
++++
<iframe width="640" height="480" src="https://www.youtube.com/embed/UGWVMfo5Pew" frameborder="0" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
Expand Down
81 changes: 81 additions & 0 deletions modules/genai-ecosystem/pages/llm-graph-builder.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
= LLM Graph Builder - Construct Knowledge Graphs from Unstructured Text (PDF, YouTube, Webpages)
include::_graphacademy_llm.adoc[]
:slug: llm-graph-builder
:author: Michael Hunger, Tomaz Bratanic, Persistent
:category: genai-ecosystem
:tags:
:neo4j-versions: 5.x
:page-pagination:
:page-product: llm-graph-builder
:imagesdir: https://dev.assets.neo4j.com/wp-content/uploads/2024/

image::llm-graph-builder.png[width=600, align=center]

The LLM Graph Builder is a demo application for turning unstructured text into a knowledge graph, it provides a magical text to graph experience.

It uses ML models (LLM, Diffbot) to transform PDFs, web pages, and YouTube videos into a graph of entities and their relationships.

The frontend is a React Application and the backend a Python FastAPI.
It uses the https://python.langchain.com/docs/use_cases/graph/constructing[llm-graph-transformer module^] that we contributed to LangChain.


== Functionality Includes

1. Connect to a Neo4j Aura instance
2. Provide your PDF files, Youtube URLs, Wikipedia Keywords or S3/GCS buckets
3. Construct Graph with LLM / Diffbot
4. Visualize Knowledge Graph in App
5. Chat with GraphRAG
6. Open Neo4j Bloom for further Exploration
7. Use the constructed knowledge graph in your applications

image::llm-graph-builder-viz.png[width=600, align=center]

== How it works

1. Uploaded Sources are stored as `Document` nodes in the graph
2. Each document (type) is loaded with the LangChain Loaders
3. The content is split into Chunks
4. Chunks are stored in the graph and connected to the Document and to each other for advanced RAG patterns
5. Highly similar Chunks are connected with a `SIMILAR` relationship to form a kNN Graph
6. Embeddings are computed and stored in the Chunks and Vector index
7. Using the llm-graph-transformer or diffbot-graph-transformer entities and relationships are extracted from the text
8. Entities are stored in the graph and connected to the originating Chunks


// TODO architecture diagram

== Relevant Links
[cols="1,4"]
|===
| OpenAI | https://llm-graph-builder-openai.neo4jlabs.com/
| Gemini | https://llm-graph-builder-gemini.neo4jlabs.com/
| icon:user[] Authors | Michael Hunger, Tomaz Bratanic, Persistent
| icon:comments[] Community Support | https://community.neo4j.com/c/neo4j-graph-platform/genai/214[Neo4j Online Community^]
| icon:github[] Code Repository | https://github.com/neo4j-labs/llm-graph-builder[GitHub^]
| icon:github[] Issues | https://github.com/neo4j-labs/llm-graph-builder/issues[GitHub Issues^]
// | icon:book[] Documentation |
|===


== Installation

The Demo is available online, [configured for OpenAI GPT^] and for https://llm-graph-builder-gemini.neo4jlabs.com[Google Gemini on Vertex AI^]

You can also run it locally, by cloning the https://github.com/neo4j-labs/llm-graph-builder[repository] and following the instructions in the README.md file.

It is using Docker for packaging frontend and backend, and you can run `docker-compose up` to start the whole application.

////
== Videos & Tutorials
Installation:
++++
<iframe width="320" height="180" src="https://www.youtube.com/embed/WcLFHFfLczU" frameborder="0" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
++++
== Highlighted Articles
// link:https://medium.com/neo4j/....[article^]
////
27 changes: 20 additions & 7 deletions modules/genai-ecosystem/pages/vector-search.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ The index is designed to work with embeddings, such as those generated by machin

* Create a vector index with a specified number of dimensions and similarity function (euclidean, cosine)
* Query vector index with embedding and top-k, returning nodes and similarity score
* Functions to compute text vector embeddings with OpenAI, AWS Bedrock, Google Vertex AI, and other ML platforms

NOTE: The maximum dimensions supported in the index is *2048* as of Neo4j 5.17, i.e. some embedding models like Llama2 or OpenAI `text-embedding-3-large` configured with large dimensions, will not work.
* Procedures to compute text vector embeddings with OpenAI, AWS Bedrock, Google Vertex AI, and other ML platforms
* Vector similarity functions to compute cosine angle and euclidean distance between vectors

== Usage

Expand All @@ -33,26 +32,39 @@ OPTIONS {indexConfig: {
`vector.similarity_function`: 'cosine'
}};
// set embedding as parameter
MATCH (a:Abstract {id: $id})
CALL db.create.setNodeVectorProperty(a, 'embedding', $embedding);
// use a genai function to compute the embedding
MATCH (a:Abstract {id: $id})
WITH a, genai.vector.encode(a.text, "OpenAI", { token: $token }) AS embedding
CALL db.create.setNodeVectorProperty(n, 'embedding', embedding);
// query vector index for similar abstracts
MATCH (title:Title)<--(:Paper)-->(abstract:Abstract)
WHERE toLower(title.text) = 'efficient and robust approximate nearest neighbor search using
hierarchical navigable small world graphs'
WHERE title.text CONTAINS = 'hierarchical navigable small world graph'
CALL db.index.vector.queryNodes('abstract-embeddings', 10, abstract.embedding)
YIELD node AS similarAbstract, score
MATCH (similarAbstract)<--(:Paper)-->(similarTitle:Title)
RETURN similarTitle.text AS title, score;
// use cosine similarity for exact nearest neighbor search
// pre-filter vector search
MATCH (venue:Venue)<--(:Paper)-->(abstract:Abstract)
WHERE venue.name CONTAINS 'NETWORK'
WITH abstract, paper,
vector.similarity.cosine(abstract.embedding, $embedding) AS score
WHERE score > 0.9
RETURN paper.title AS title, abstract.text, score
ORDER BY score DESC LIMIT 10;
----

== Documentation
Expand All @@ -65,7 +77,8 @@ RETURN similarTitle.text AS title, score;
| icon:github[] Repository | https://github.com/neo4j/neo4j[GitHub]
| icon:github[] Issues | https://github.com/neo4j/neo4j/issues
| icon:book[] Documentation | https://neo4j.com/docs/cypher-manual/current/indexes/semantic-indexes/vector-indexes/[Vector Index and Search^]
| icon:book[] Documentation | https://neo4j.com/docs/cypher-manual/current/genai-integrations/[GenAI Embedding Functions^]
| icon:book[] Documentation | https://neo4j.com/docs/cypher-manual/current/genai-integrations/[GenAI Embedding Procedures^]
| icon:book[] Documentation | https://neo4j.com/docs/cypher-manual/current/functions/vector/[Vector Similarity Functions^]
|===


Expand Down

0 comments on commit 8bd17fc

Please sign in to comment.