diff --git a/modules/genai-ecosystem/images/graphrag-image-simple.png b/modules/genai-ecosystem/images/graphrag-image-simple.png new file mode 100644 index 00000000..3725e1e9 Binary files /dev/null and b/modules/genai-ecosystem/images/graphrag-image-simple.png differ diff --git a/modules/genai-ecosystem/nav.adoc b/modules/genai-ecosystem/nav.adoc index 70ef9a22..fb45b0a5 100644 --- a/modules/genai-ecosystem/nav.adoc +++ b/modules/genai-ecosystem/nav.adoc @@ -1,31 +1,21 @@ -** xref:index.adoc[GenAI Ecosystem] -*** Example Projects -**** xref:llm-graph-builder.adoc[LLM Graph Builder] -***** xref:llm-graph-builder-features.adoc[Features] -***** xref:llm-graph-builder-deployment.adoc[Deployment] +** xref:index.adoc[GraphRAG Dev Guide] + +*** GraphRAG Examples **** xref:ai-for-customer-experiences.adoc[GraphRAG for Customer Experience] -**** xref:rag-demo.adoc[GraphRAG Demo] -**** xref:neoconverse.adoc[NeoConverse] -**** xref:genai-stack.adoc[GenAI Stack] -*** Neo4j GenAI Features +**** https://neo4j.com/blog/developer/graphrag-in-action/[Agentic GraphRAG for Commercial Contract Q&A^] +**** https://neo4j.com/labs/genai-ecosystem/aws-demo[GraphRAG with AWS Bedrock - Getting Started^] +**** https://github.com/neo4j-product-examples/neo4j-aws-ai-examples[GraphRAG on AWS with Unstructured/Structured/Mixed Data^] +**** https://neo4j.com/labs/genai-ecosystem/microsoft-azure-demo[GraphRAG with Microsoft Azure OpenAI^] +**** https://neo4j.com/labs/genai-ecosystem/google-cloud-demo[GraphRAG with Google Vertex AI^] + +*** Neo4j GenAI Product Integrations +**** xref:graphrag-python.adoc[GraphRAG Python Package] +**** https://python.langchain.com/docs/integrations/providers/neo4j[LangChain Neo4j (Vendor Supported Package)^] **** xref:vector-search.adoc[Vector Index and Search] -**** xref:apoc-genai.adoc[APOC GenAI] -*** Cloud Examples -**** xref:aws-demo.adoc[AWS Bedrock] -**** xref:microsoft-azure-demo.adoc[Microsoft Azure OpenAI] -**** xref:google-cloud-demo.adoc[Google Cloud Vertex AI] -*** xref:genai-frameworks.adoc[GenAI Frameworks] -**** xref:langchain.adoc[LangChain] -**** xref:langchain-js.adoc[LangChainJS] -**** xref:llamaindex.adoc[LlamaIndex] -// **** link:xxx[Documentation] -**** xref:spring-ai.adoc[SpringAI] -// **** link:xxx[Documentation] -**** xref:langchain4j.adoc[LangChain4j] -// **** link:xxx[Documentation] -**** xref:haystack.adoc[Haystack] -// **** link:xxx[Documentation] -**** xref:semantic-kernel.adoc[Semantic Kernel] -// **** link:xxx[Documentation] -**** xref:dspy.adoc[DSPy] -// **** link:xxx[Documentation] + +*** GraphRAG Ecosystem Tools +**** https://neo4j.com/labs/genai-ecosystem/llm-graph-builder[LLM Graph Builder^] +**** https://neo4j.com/labs/genai-ecosystem/neoconverse[NeoConverse^] +**** https://neo4j.com/labs/genai-ecosystem/apoc-genai[APOC Extended for GenAI^] + +*** https://neo4j.com/labs/genai-ecosystem/genai-frameworks[GenAI Frameworks^] diff --git a/modules/genai-ecosystem/pages/_developer_survey.adoc b/modules/genai-ecosystem/pages/_developer_survey.adoc new file mode 100644 index 00000000..0cc31dd1 --- /dev/null +++ b/modules/genai-ecosystem/pages/_developer_survey.adoc @@ -0,0 +1,7 @@ +// Developer survey +:page-ad-icon: ~ +:page-ad-title: Neo4j Developer Survey +:page-ad-description: Your input matters! Share your Feedback +:page-ad-underline-role: button +:page-ad-underline: Start Here +:page-ad-link: https://neo4j.typeform.com/to/E6yOZ2Py?utm_source=GA&utm_medium=blurb&utm_campaign=survey diff --git a/modules/genai-ecosystem/pages/agent-neo.adoc b/modules/genai-ecosystem/pages/agent-neo.adoc deleted file mode 100644 index ca85afab..00000000 --- a/modules/genai-ecosystem/pages/agent-neo.adoc +++ /dev/null @@ -1,121 +0,0 @@ -= Agent Neo a Graph Powered Technical Document Chatbot -// :toc: -// :toc-placement: auto -:imagesdir: https://dev.assets.neo4j.com/wp-content/uploads/2024/ -// :sectnums: -:page-pagination: -:page-product: agent-neo - -== Introduction - -Agent Neo is a Graph Retrieval-Augmentation Generation (Graph-RAG) chat application that leverages the Neo4j Label Property Graph to manage and query data. -Developed initially using a high-quality dataset of Neo4j documentation, the application utilizes metadata enrichment and post-processing to enhance RAG response quality. - - -== How It Works - -The workflow for Agent Neo is outlined as follows: - -. **Document Upload and Storage**: Documents are uploaded and stored as `Document` nodes within the graph. -. **Chunk Processing**: Documents are segmented into smaller chunks, then processed and stored as nodes, linked to their respective documents. -. **Topic Extraction and Clustering**: Topics are extracted using NLP post-processing, encoded, and linked to text chunks to form clusters. -. **Similarity and Graph Structuring**: Text embeddings are utilized to identify similar text chunks, which are interconnected using "SIMILAR_TO" relationships to further structure the graph via the Leiden algorithm. -. **Metadata Integration and Feedback Loop**: Session metadata and user feedback are integrated into the graph, enhancing data richness for future queries and analyses. - -// image::agent-neo-structure.png[Graph Structure Example, width=600, align="center"] - -== Key enhancements - -* Capturing session and conversation metadata along with their associated questions and responses, linking them back to relevant entries. -* Extracting topics using NLP techniques, encoding these into the graph, and associating them with corresponding text blocks to create a semantic hierarchy. -* Clustering topics and encoding similarity features within the graph, involving generating text embeddings for topics, conducting k-nearest neighbors analyses, and creating "SIMILAR_TO" relationships. -* Setting "SIMILAR_TO" relationships as undirected and aggregating similarity scores to apply the Leiden algorithm, subsequently forming Topic Groups that expand the semantic topic hierarchy. -* Injecting session UUIDs generated on the frontend, integrating these with LangSmith LLM logging, and writing back LangSmith metadata statistics into the graph. -* Capturing user response feedback through the UI and incorporating this into the graph to potentially inform response ranking and analyze application satisfaction. - -== Why Graph RAG? - -Agent Neo utilizes Graph-RAG technology to offer significant advantages: - -* *Completeness of Responses*: Combines classical vector similarity searches with graph traversals to capture a broader context around text similarities beyond simple metric comparisons. -* *Explainability & Observability*: Enhances the transparency and explainability of operations by incorporating vectors within a graph structure, moving away from the "black box" nature of traditional models. -* *Rapid Iteration and Integration*: Facilitates quick iterations and seamless integration of diverse data sources through Neo4j’s Label Property Graph, supported by in-platform feature engineering capabilities. - -// image::agent-neo.png[Agent Neo Architecture, width=600, align="center"] - -== Installation - -=== Prerequisites - -* Docker installed on your machine -* Python 3.8 or higher -* Node.js 12 or higher - -=== Setup Guide - -To set up Agent Neo, execute the following steps: - -[source,bash] ----- -# Clone the Agent Neo repository: -git clone https://github.com/neo4j-labs/agent-neo.git -cd agent-neo - -# Launch the application using Docker Compose -docker-compose up ----- - -Visit `http://localhost:8000` in your web browser to start using Agent Neo. Review the Dockerfile and associated services for production deployment details. - -== Relevant Links - -[cols="1,4"] -|=== -| Online | https://chatbot.agent-neo-chat.com/[React Front End^] https://agent-neo.streamlit.app/[Older Streamlit Front End^] -| icon:user[] Authors | Dan Bukowski, Alex Gilmore, Alex Fournier, Nathan Smith, Morgan Senechal, Roni Das, Eric Monk, Kumar Subbiah Shunmugathai, Michael Hunger -| 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/agent-neo[GitHub^] -| icon:github[] Issues | https://github.com/neo4j-labs/agent-neo/issues[GitHub Issues^] -// | icon:book[] Documentation | -|=== - -== Further Resources - -* *Graph Data Models for RAG Applications*: https://medium.com/neo4j/graph-data-models-for-rag-applications-d59c29bb55cc -* *Topic Extraction with Neo4j Graph Data Science for Better Semantic Search*: https://medium.com/@nsmith_piano/topic-extraction-with-neo4j-graph-data-science-for-better-semantic-search-c5b7f56c7715 - -//// - -== Contributors and Contact -Agent Neo is a collaborative effort. If you are interested in contributing or have questions, please contact the core team: - -* **Dan Bukowski** (Architect/PM) - `dan.bukowski@neo4j.com` -* **Alex Gilmore** (Architect) - `alex.gilmore@neo4j.com` -* **Alex Fournier** (Architect/PM) - `alex.fournier@neo4j.com` -* **Nathan Smith** (Graph Data Science/Database) - `nathan.smith@neo4j.com` -* **Morgan Senechal** (Frontend) - `morgan.senechal@neo4j.com` -* **Roni Das** (Frontend) - `roni.das@neo4j.com` -* **Eric Monk** (Technical Guidance) - `eric.monk@neo4j.com` -* **Kumar Subbiah Shunmugathai** (Technical Guidance) - `kumar.subbiah@neo4j.com` -* **Michael Hunger** (PM) - `michael.hunger@neo4j.com` -//// - -== Raising Issues and Feature Requests - -To report bugs or suggest features: - -* Visit our GitHub Issues page: link:https://github.com/neo4j-labs/agent-neo/issues[GitHub Issues] -* For immediate support, especially for urgent issues, please use the `urgent` tag when creating a new issue. - -== Change Log / Feature Development - -=== Version 1.1 - *2024-06-01* - -- Integrated Langchain metadata statistics and exposed via Neodash. -- Implemented rating feedback and semantic topic clustering. -- Expanded testing protocols. -- Enhanced GraphReader functionality for combined traversal and vector search. -- Implementing frontend feature using bloom vis sdk to enhance observability - -=== Version 1.0 - *2024-01-01* -- Initial release: basic document upload, chunk processing, and initial graph structure setup. diff --git a/modules/genai-ecosystem/pages/apoc-genai.adoc b/modules/genai-ecosystem/pages/apoc-genai.adoc deleted file mode 100644 index a70f0934..00000000 --- a/modules/genai-ecosystem/pages/apoc-genai.adoc +++ /dev/null @@ -1,101 +0,0 @@ -= APOC GenAI Procedures -include::_graphacademy_llm.adoc[] -:slug: apoc-genai -:author: -:category: genai-ecosystem -:tags: embeddings, chat, completion, image generation, genai, query generation, schema explanation -:neo4j-versions: 5.11+ -:page-pagination: -:page-product: apoc-genai - -The APOC Extended procedure library integrates with various AI/ML platforms to provide a set of useful utilities for quickly demonstrate GenAI features. -The library includes procedures for generating texts, images, and vector embedding. -It also allows the generation and execution of Cypher queries from natural language as well as schema explanation. - -APOC Extended integrates with - -* https://neo4j.com/labs/apoc/5/ml/openai/[(Azure) OpenAI^], -* https://neo4j.com/labs/apoc/5/ml/bedrock/[AWS Bedrock^], -* https://neo4j.com/labs/apoc/5/ml/vertexai/[Google Vertex AI^], -* https://neo4j.com/labs/apoc/5/ml/watsonai/[IBM Watson AI^] -* and other https://neo4j.com/labs/apoc/5/ml/openai/#openai_compatible_provider[ML platforms that have OpenAI compatible APIs^]. - -== Installation - -APOC extended is available as a plugin for Neo4j. To install APOC, follow the instructions in the APOC Manual. -In most installation you can download the https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases[appropriate release^] and place the JAR file in the `plugins` directory of your Neo4j installation. - -In https://sandbox.neo4j.com[Neo4j Sandbox^], APOC is already installed and you can start using the procedures right away. - -NOTE: APOC Extended is not available in the Neo4j Aura Cloud Service. - -== Usage - -Here is a quick example: - -[source,cypher] ----- -// generate embedding -CALL apoc.ml.openai.embedding(['Knowledge Graphs work well with LLMs'], $apiKey, {}) yield index, text, embedding; - -// generate text -CALL apoc.ml.openai.completion('What color is the sky? Answer in one word: ', $apiKey, {config}) yield value; - -/* -{ created=1684248202, model="text-davinci-003", id="cmpl-7GqBWwX49yMJljdmnLkWxYettZoOy", - usage={completion_tokens=2, prompt_tokens=12, total_tokens=14}, - choices=[{finish_reason="stop", index=0, text="Blue", logprobs=null}], object="text_completion"} -*/ - -CALL apoc.ml.query("What movies did Tom Hanks play in?", {apiKey: $apiKey}) yield value, query -RETURN *; - - -CALL apoc.ml.schema({apiKey: $apiKey}); -/* -The graph database schema represents a system where users can follow other users and review movies. -Users (:Person) can either follow other users (:Person) or review movies (:Movie). -The relationships allow users to express their preferences and opinions about movies. -This schema can be compared to social media platforms where users can follow each other and leave reviews or ratings for movies they have watched. -It can also be related to movie recommendation systems where user preferences and reviews play a crucial role in generating personalized recommendations. -*/ ----- - -Most of the procedures take besides your input the configuration for API keys or tokens as well as the model name. - -The API keys can also be configured in `apoc.conf` to make the functionality available to all your users, make sure to protect they keys with rate and budget limits. - -== Functionality Includes - -* Generate vector embeddings -* Text completion -* Chat completion with multiple messages having roles for system, assistant and user -* Image generation -* Cypher query generation from natural language -* Schema explanation - -== Documentation - -== Relevant Links -[cols="1,4"] -|=== -| icon:user[] Authors | Neo4j Labs contributors, esp. https://github.com/vga91[Giuseppe Villani^] -| icon:comments[] Community Support | https://community.neo4j.com/[Neo4j Online Community^] -| icon:github[] Repository | https://github.com/neo4j-contrib/neo4j-apoc-procedures[GitHub] -| icon:github[] Issues | https://github.com/neo4j-contrib/neo4j-apoc-procedures/issues -| icon:gift[] Releases | https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases -| icon:book[] Documentation | https://neo4j.com/labs/apoc/5/ml/ -|=== - - -//// -== Videos & Tutorials - -++++ - -++++ - -== Highlighted Articles - -* https://medium.com/neo4j/building-lightweight-rag-applications-using-neo4j-91661cf258bb[Building Lightweight RAG Applications using Neo4j^] -//// \ No newline at end of file diff --git a/modules/genai-ecosystem/pages/aws-demo.adoc b/modules/genai-ecosystem/pages/aws-demo.adoc deleted file mode 100644 index 9505bd85..00000000 --- a/modules/genai-ecosystem/pages/aws-demo.adoc +++ /dev/null @@ -1,38 +0,0 @@ -= AWS Demo -include::_graphacademy_llm.adoc[] -:slug: aws-demo -:author: Ben Lackey -:category: genai-ecosystem -:tags: rag, demo, retrieval augmented generation, chatbot, edgar, sec filings, aws, bedrock -:neo4j-versions: 5.x -:page-pagination: -:page-product: aws-demo - -This is a sample notebook and web application which shows how Amazon Bedrock and Titan can be used with Neo4j. It shows how to leverage generative AI to build and consume a knowledge graph in Neo4j. - -The dataset we're using is from the SEC's EDGAR system. - -The dataflow in this demo consists of two parts: - -* Ingestion - we read the EDGAR files with Bedrock, extracting entities and relationships from them which is then ingested into a Neo4j database deployed from AWS Marketplace. -* Consumption - A user inputs natural language into a chat UI. Bedrock converts that to Neo4j Cypher which is run against the database. This flow allows non technical users to query the database. - -== Installation - -The Demo is available on GitHub: https://github.com/neo4j-partners/neo4j-generative-ai-aws - -== Relevant Links -[cols="1,4"] -|=== -| icon:github[] Code Repository | https://github.com/neo4j-partners/neo4j-generative-ai-aws[GitHub] -| APN Blog Post | https://aws.amazon.com/blogs/apn/leveraging-neo4j-and-amazon-bedrock-for-an-explainable-secure-and-connected-generative-ai-solution[Link] -| Demo Video | https://www.youtube.com/watch?v=nV3-KKEZnD4&list=PLG3nTnYVz3nya8Me9-Xj9vEuLYIOk03ba&index=11&t=14s[Link] -| Press Release | https://neo4j.com/press-releases/neo4j-aws-bedrock-integration[Link] -| Slides | https://docs.google.com/presentation/d/1pnJn1GV7tm6Gr-K-0bEB5TlkPRoDbqLTKkKjWdr3eZs/edit?usp=sharing[Link] -|=== - -== Videos & Tutorials - -++++ - -++++ diff --git a/modules/genai-ecosystem/pages/dspy.adoc b/modules/genai-ecosystem/pages/dspy.adoc deleted file mode 100644 index 01089207..00000000 --- a/modules/genai-ecosystem/pages/dspy.adoc +++ /dev/null @@ -1,46 +0,0 @@ -= DSPy Neo4j Integration -:slug: dspy -:author: Tomaz Bratanic -:category: labs -:tags: dspy, rag, vector search, neo4j -:neo4j-versions: 5.x -:page-pagination: -:page-product: dspy - - -DSPy is a framework for algorithmically optimizing LM prompts and weights, especially when LMs are used one or more times within a pipeline. - -The Neo4j integration allows for vector search. - -Here is an overview of the https://dspy-docs.vercel.app/api/retrieval_model_clients/Neo4jRM[DSPy Integrations^]. - -== Installation - -[source,shell] ----- -pip install dspy neo4j ----- -== Functionality Includes - -* `Neo4jRM` - is a typical retriever component which can be used to query vector store index and find related Documents. - -[source,python] ----- -from dspy.retrieve.neo4j_rm import Neo4jRM -import os - -os.environ["NEO4J_URI"] = 'bolt://localhost:7687' -os.environ["NEO4J_USERNAME"] = 'neo4j' -os.environ["NEO4J_PASSWORD"] = 'password' -os.environ["OPENAI_API_KEY"] = 'sk-' - -retriever_model = Neo4jRM( - index_name="vector", - text_node_property="text" -) - -results = retriever_model("Explore the significance of quantum computing", k=3) - -for passage in results: - print("Document:", passage, "\n") ----- \ No newline at end of file diff --git a/modules/genai-ecosystem/pages/genai-frameworks.adoc b/modules/genai-ecosystem/pages/genai-frameworks.adoc deleted file mode 100644 index 5b0d3851..00000000 --- a/modules/genai-ecosystem/pages/genai-frameworks.adoc +++ /dev/null @@ -1,43 +0,0 @@ -= GenAI Frameworks -include::_graphacademy_llm.adoc[] -:imagesdir: https://s3.amazonaws.com/dev.assets.neo4j.com/wp-content/uploads -:slug: genai-frameworks -:author: Michael Hunger, Tomaz Bratanic, Oskar Hane -:category: labs -:tags: llm, genai, generative ai, large language models, integrations, rag, vector search, retrieval augmented generation, llamaindex, langchain, haystack, frameworks -:neo4j-versions: 5.X -:page-pagination: -:page-product: GenAI Frameworks - -While current foundation models (language, image, speech, embeddings) are available through APIs and can be used just with a http request or a few lines of code, the devil is as always in the details. It is not just about a single API call but full applications, workflows and architectures. - -In the last years a number of really powerful open-source orchestration libraries have been developed, many with a large contributor community and a lot of momentum. -Even the large cloud providers and AI companies contributed and are using these libraries as in this fast moving world it is hard to keep up otherwise. - -Those libraries cover a number of aspects: - -- LLM usage, including Prompt and Output -- Embedding generation -- Vector and database integration -- RAG workflows -- Agentic workflows -- Monitoring, Observability and Deployment - -== GenAI Frameworks - -Neo4j and our community have contributed integrations to many of these frameworks. You can find overviews of these integrations in the pages of this section, as well as code examples, tutorials and more. - -* xref:langchain.adoc[LangChain (Python)] -* xref:langchain-js.adoc[LangChainJS] -* xref:llamaindex.adoc[LLamaIndex] -* xref:spring-ai.adoc[Spring AI] -* xref:langchain4j.adoc[LangChain4j] -* xref:haystack.adoc[Haystack] -* xref:semantic-kernel.adoc[Semantic Kernel] -* xref:dspy.adoc[DSPy] - -== GraphAcademy Courses - -If you want to learn how LLMs and Knowledge Graphs combine to improve GenAI applications, check out the https://graphacademy.neo4j.com/categories/llms/?ref=genai-docs[Neo4j & LLM courses on GraphAcademy^]. - -image::https://cdn.graphacademy.neo4j.com/assets/img/courses/banners/llm-fundamentals.png[link=https://graphacademy.neo4j.com/categories/llms/?ref=genai-docs] diff --git a/modules/genai-ecosystem/pages/genai-stack.adoc b/modules/genai-ecosystem/pages/genai-stack.adoc deleted file mode 100644 index 0a3ee842..00000000 --- a/modules/genai-ecosystem/pages/genai-stack.adoc +++ /dev/null @@ -1,91 +0,0 @@ -= GenAI Stack -include::_graphacademy_llm.adoc[] -:slug: genai-stack -:author: Michael Hunger, Tomaz Bratanic, Oskar Hane, Jim Clar, Harrison Chase, Michael Chiang -:category: labs -:tags: docker, langchain, ollama, neo4j, vector index, vector search, chatbot, rag, streamlit, pdf, stackoverflow -:neo4j-versions: 5.x -:page-pagination: -:page-product: genai-stack - -image::https://dist.neo4j.com/wp-content/uploads/20231005063102/import-embed-data-stack-overflow.png[width=800] - -The GenAI Stack is a collaboration between Docker, Neo4j, LangChain and Ollama launched at DockerCon 2023. - -== Installation - -On MacOS you have to install and start https://ollama.ai/[Ollama] first, then you can use the GenAI Stack. - -[source,shell] ----- -git clone https://github.com/docker/genai-stack -cd genai-stack - -# optionally copy env.example to .env and add your OpenAI/Bedrock/Neo4j credentials for remote models -docker compose up ----- - -== Functionality Includes - -* Docker Setup with local or remote LLMs, Neo4j and LangChain demo applications - -* Pull Ollama Models and sentence transformer as needed -* Import Stackoverflow Questions and Answers for a certain tag, e.g. `langchain` -* Create Knowledge Graph and vector embeddings for questions and answers - -image::https://dist.neo4j.com/wp-content/uploads/20231005063228/query-imported-data.png[] - -* Streamlit Chat App with vector search and GraphRAG (vector + graph) answer generation -* Creating "Support Tickets" for unanswered questions taking good questions from StackOverflow and the actual question into account -* PDF chat with loading PDFs, chunking, vector indexing and search to generate answers -* Python Backend and Svelte Front-End Chat App with vector search and GraphRAG (vector + graph) answer generation - -image::https://dist.neo4j.com/wp-content/uploads/20231005063244/input-answer-sources.png[] - -== Documentation - -A detailed walkthrough of the GenAI Stack is available at https://neo4j.com/developer-blog/genai-app-how-to-build/. - -== Relevant Links -[cols="1,4"] -|=== -| icon:user[] Authors | https://github.com/jexp[Michael Hunger^], https://github.com/tomasojo[Tomaz Bratanic^], https://github.com/oskarhane[Oskar Hane^] and many contributors -| icon:comments[] Community Support | https://community.neo4j.com/[Neo4j Online Community^] -| icon:github[] Repository | https://github.com/docker/genai-stack[GitHub] -| icon:github[] Issues | https://github.com/docker/genai-stack/issues -// | icon:book[] Documentation | https://github.com/docker/genai-stack -|=== - -== Videos & Tutorials - -++++ - -++++ - -++++ - -++++ - -++++ - -++++ - -++++ - -++++ - -++++ - -++++ - -++++ - -++++ - -== Highlighted Articles - -* https://neo4j.com/emil/introducing-genai-stack-developers/[Introducing the GenAI Stack - Emil Eifrem^] -* https://www.docker.com/blog/introducing-a-new-genai-stack/[Introducing a New GenAI Stack - Docker^] -* https://collabnix.com/getting-started-with-genai-stack-powered-with-docker-langchain-neo4j-and-ollama/[Getting Started with GenAI Stack powered with Docker, LangChain, Neo4j and Ollama - Collabnix^] - -* https://medium.com/@yu-joshua/fast-track-to-mastery-neo4j-genai-stack-for-efficient-llm-applications-87acb0db2cef[Fast Track to Mastery: Neo4j GenAI Stack for Efficient LLM Applications^] \ No newline at end of file diff --git a/modules/genai-ecosystem/pages/google-cloud-demo.adoc b/modules/genai-ecosystem/pages/google-cloud-demo.adoc deleted file mode 100644 index b445beab..00000000 --- a/modules/genai-ecosystem/pages/google-cloud-demo.adoc +++ /dev/null @@ -1,49 +0,0 @@ -= Google Cloud Vertex AI -include::_graphacademy_llm.adoc[] -:slug: google-cloud-demo -:author: Ben Lackey, Michael Hunger -:category: genai-ecosystem -:tags: rag, demo, retrieval augmented generation, chatbot, google, vertexai, gemini, langchain, reasoning-engine -:neo4j-versions: 5.x -:page-pagination: -:page-product: google-cloud-demo -//:imagesdir: https://dev.assets.neo4j.com/wp-content/uploads/2024/ - -== Google Cloud Generative AI Demos - -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 - -The Demo is available on GitHub: https://github.com/neo4j-partners/neo4j-generative-ai-google-cloud - -=== Relevant Links - -[cols="1,4"] -|=== -| icon:github[] Code Repository | https://github.com/neo4j-partners/neo4j-generative-ai-google-cloud[GitHub] -| Blog Post | https://cloud.google.com/blog/topics/partners/build-intelligent-apps-with-neo4j-and-google-generative-ai[Link] -| Demo Video | https://www.youtube.com/watch?v=UGWVMfo5Pew[Link] -| Slides | https://docs.google.com/presentation/d/1vIXaZCWX5fN5m6y50Z7nM6RlTSJR7vErUrfXlWR0BLY/edit?usp=sharing[Link] -| Press Release | https://neo4j.com/press-releases/neo4j-google-cloud-vertex-ai[Link] -|=== - -=== Videos & Tutorials - -++++ - -++++ - -== Knowledge Graph Generation with Gemini Pro - -The xref:llm-graph-builder.adoc[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 - -// The Demo is available https://llm-graph-builder-gemini.neo4jlabs.com[online with with Google Gemini on Vertex AI^]. diff --git a/modules/genai-ecosystem/pages/google-cloud-genai-integrations.adoc b/modules/genai-ecosystem/pages/google-cloud-genai-integrations.adoc deleted file mode 100644 index 68869591..00000000 --- a/modules/genai-ecosystem/pages/google-cloud-genai-integrations.adoc +++ /dev/null @@ -1,40 +0,0 @@ -= Google Cloud GenAI Integrations -include::_graphacademy_llm.adoc[] -:slug: google-cloud-genai-integrations -:author: Ben Lackey, Michael Hunger -:category: genai-ecosystem -:tags: rag, demo, retrieval augmented generation, chatbot, google, vertexai, gemini, langchain, reasoning-engine -:neo4j-versions: 5.x -:page-pagination: -:page-product: google-cloud-demo -//:imagesdir: https://dev.assets.neo4j.com/wp-content/uploads/2024/ - -== Function Calling with Gemini - -// TODO - -== Quering Neo4j via Vertex AI Extensions - -// TODO - -== Deploying GenAI Applications and APIs with Vertex AI Reasoning Engine - -GenAI developers, familiar with orchestration tools and architectures often face challenges when deploying their work to production. -Google's https://cloud.google.com/vertex-ai/generative-ai/docs/reasoning-engine/overview[Vertex AI Reasoning Engine Runtime^](preview) now offers an easy way to deploy, scale, and monitor GenAI applications and APIs without in-depth knowledge of containers or cloud configurations. - -Compatible with various orchestration frameworks, including xref:langchain.adoc[LangChain], this solution allows developers to use the https://cloud.google.com/vertex-ai/docs/python-sdk/use-vertex-ai-python-sdk[Vertex AI Python SDK^] for setup, testing, deployment. - -It works like this: - -- Create a Python class for your GenAI app class to store environment info and static data in the constructor. -- Initialize your orchestration framework in a `set_up` method at startup. -- Process user queries with a `query` method, returning text responses. -- Deploy your GenAI API with `llm_extension.ReasoningEngine.create`, including class instance and requirements. - -Our new integrations with Google Cloud, combined with our extensive LangChain integrations, allow you to seamlessly incorporate Neo4j knowledge graphs into your GenAI stack. -You can use LangChain and other orchestration tools to deploy RAG architectures, like GraphRAG, with Reasoning Engine Runtime. - -You can see below an example of GraphRAG on a Company News Knowledge Graph using LangChain, Neo4j and Gemini. - -image::https://dev.assets.neo4j.com/wp-content/uploads/2024/reasoning-engine-graphrag.png[] - diff --git a/modules/genai-ecosystem/pages/graphrag-python.adoc b/modules/genai-ecosystem/pages/graphrag-python.adoc new file mode 100644 index 00000000..fff3bb50 --- /dev/null +++ b/modules/genai-ecosystem/pages/graphrag-python.adoc @@ -0,0 +1,239 @@ += Neo4j GraphRAG Python Package +include::_graphacademy_llm.adoc[] +:slug: graphrag-python +:author: +:category: genai-ecosystem +:tags: graphrag, knowledgegraph, embedding, vectorsearch, neo4j, python +:neo4j-versions: 5.23+ +:page-pagination: +:page-product: neo4j + + +The Neo4j GraphRAG package is a comprehensive Python library that allows building GenAI applications. +It supports knowledge graph creation through a pipeline that extracts entities from unstructured text, generates embeddings, and creates a graph in Neo4j. +The package also provides a number of retrievers, for graph search, vector search and integration with vector databases. + +== Functionality Includes + +* Knowledge Graph Construction Pipeline +* Neo4j Vector Retriever +* Vector Cypher Retriever +* Vector Database Retriever + +image::https://cdn.graphacademy.neo4j.com/assets/img/courses/banners/genai-workshop-graphrag.png[width=800,link="https://graphacademy.neo4j.com/courses/genai-workshop-graphrag/"] + +== Usage - Examples for a BioMedical Knowledge Graph + +First Knowledge Graph Construction using the SimpleKGPipeline + +image::https://dist.neo4j.com/wp-content/uploads/20241015075828/simplekgpipeline-1.png[] + +Setup of Neo4j connection, schema and foundation models (LLM, Embeddings) and extraction prompt template. + +[source,python] +---- +# Neo4j Driver +import neo4j + +neo4j_driver = neo4j.GraphDatabase.driver(NEO4J_URI, + auth=(NEO4J_USERNAME, NEO4J_PASSWORD)) + +# LLM and Embedding Model +from neo4j_graphrag.llm import OpenAILLM +from neo4j_graphrag.embeddings.openai import OpenAIEmbeddings + +llm=OpenAILLM( + model_name="gpt-4o-mini", + model_params={ + "response_format": {"type": "json_object"}, # use json_object formatting for best results + "temperature": 0 # turning temperature down for more deterministic results + } +) + +# Graph Schema Setup +basic_node_labels = ["Object", "Entity", "Group", "Person", "Organization", "Place"] + +academic_node_labels = ["ArticleOrPaper", "PublicationOrJournal"] + +medical_node_labels = ["Anatomy", "BiologicalProcess", "Cell", "CellularComponent", + "CellType", "Condition", "Disease", "Drug", + "EffectOrPhenotype", "Exposure", "GeneOrProtein", "Molecule", + "MolecularFunction", "Pathway"] + +node_labels = basic_node_labels + academic_node_labels + medical_node_labels + +# define relationship types +rel_types = ["ACTIVATES", "AFFECTS", "ASSESSES", "ASSOCIATED_WITH", "AUTHORED", + "BIOMARKER_FOR", …] + +#create text embedder +embedder = OpenAIEmbeddings() + +# define prompt template +prompt_template = ''' +You are a medical researcher tasks with extracting information from papers +and structuring it in a property graph to inform further medical and research Q&A. + +Extract the entities (nodes) and specify their type from the following Input text. +Also extract the relationships between these nodes. the relationship direction goes from the start node to the end node. + + +Return result as JSON using the following format: +{{"nodes": [ {{"id": "0", "label": "the type of entity", "properties": {{"name": "name of entity" }} }}], + "relationships": [{{"type": "TYPE_OF_RELATIONSHIP", "start_node_id": "0", "end_node_id": "1", "properties": {{"details": "Description of the relationship"}} }}] }} + +... + +Use only fhe following nodes and relationships: +{schema} + +Assign a unique ID (string) to each node, and reuse it to define relationships. +Do respect the source and target node types for relationship and the relationship direction. + +Do not return any additional information other than the JSON in it. + +Examples: +{examples} + +Input text: + +{text} +''' +---- + +Knowledge Graph Pipeline Setup and Execution with example PDFs + +[source,python] +---- +# Knowledge Graph Builder +from neo4j_graphrag.experimental.components.text_splitters.fixed_size_splitter import FixedSizeSplitter +from neo4j_graphrag.experimental.pipeline.kg_builder import SimpleKGPipeline + +kg_builder_pdf = SimpleKGPipeline( + llm=ex_llm, + driver=driver, + text_splitter=FixedSizeSplitter(chunk_size=500, chunk_overlap=100), + embedder=embedder, + entities=node_labels, + relations=rel_types, + prompt_template=prompt_template, + from_pdf=True +) + +pdf_file_paths = ['truncated-pdfs/biomolecules-11-00928-v2-trunc.pdf', + 'truncated-pdfs/GAP-between-patients-and-clinicians_2023_Best-Practice-trunc.pdf', + 'truncated-pdfs/pgpm-13-39-trunc.pdf'] + +for path in pdf_file_paths: + print(f"Processing : {path}") + pdf_result = await kg_builder_pdf.run_async(file_path=path) + print(f"Result: {pdf_result}") +---- + +image::https://dist.neo4j.com/wp-content/uploads/20241015075652/document-chunk-entity.png[width=800] + +Then running the GraphRAG Search with the VectorCypher Retriever. + +[source,python] +---- +from neo4j_graphrag.indexes import create_vector_index + +create_vector_index(driver, name="text_embeddings", label="Chunk", + embedding_property="embedding", dimensions=1536, similarity_fn="cosine") + +# Vector Retriever +from neo4j_graphrag.retrievers import VectorRetriever + +vector_retriever = VectorRetriever( + driver, + index_name="text_embeddings", + embedder=embedder, + return_properties=["text"], +) + +# GraphRAG Vector Cypher Retriever +from neo4j_graphrag.retrievers import VectorCypherRetriever + +graph_retriever = VectorCypherRetriever( + driver, + index_name="text_embeddings", + embedder=embedder, + retrieval_query=""" +//1) Go out 2-3 hops in the entity graph and get relationships +WITH node AS chunk +MATCH (chunk)<-[:FROM_CHUNK]-(entity)-[relList:!FROM_CHUNK]-{1,2}(nb) +UNWIND relList AS rel + +//2) collect relationships and text chunks +WITH collect(DISTINCT chunk) AS chunks, collect(DISTINCT rel) AS rels + +//3) format and return context +RETURN apoc.text.join([c in chunks | c.text], '\n') + + apoc.text.join([r in rels | + startNode(r).name+' - '+type(r)+' '+r.details+' -> '+endNode(r).name], + '\n') AS info +""" +) + +llm = LLM(model_name="gpt-4o", model_params={"temperature": 0.0}) + +rag_template = RagTemplate(template='''Answer the Question using the following Context. Only respond with information mentioned in the Context. Do not inject any speculative information not mentioned. + +# Question: +{query_text} + +# Context: +{context} + +# Answer: +''', expected_inputs=['query_text', 'context']) + +vector_rag = GraphRAG(llm=llm, retriever=vector_retriever, prompt_template=rag_template) + +graph_rag = GraphRAG(llm=llm, retriever=graph_retriever, prompt_template=rag_template) + +q = "Can you summarize systemic lupus erythematosus (SLE)? including common effects, biomarkers, and treatments? Provide in detailed list format." + +vector_rag.search(q, retriever_config={'top_k':5}).answer +graph_rag.search(q, retriever_config={'top_k':5}).answer +---- + +image::https://dist.neo4j.com/wp-content/uploads/20241128072906/Bildschirmfoto-2024-11-19-um-17.31.45.png[] + +== Documentation + +[cols="1,4"] +|=== +| icon:book[] Documentation | https://neo4j.com/docs/neo4j-graphrag-python/current/ +| icon:book[] Guides | https://neo4j.com/docs/neo4j-graphrag-python/current/user_guide_rag.html[RAG & GraphRAG^] +| icon:book[] Guides | https://neo4j.com/docs/neo4j-graphrag-python/current/user_guide_kg_builder.html[Guide Knowledge Graph Builder^] + +|=== + +== Relevant Links + +[cols="1,4"] +|=== +| icon:user[] Authors | Neo4j Engineering +| icon:github[] Repository | https://github.com/neo4j/neo4j-graphrag-python[GitHub] +| icon:github[] Issues | https://github.com/neo4j/neo4j-graphrag-python/issues +|=== + + +== Videos & Tutorials + +++++ + +++++ + +++++ + +++++ + +== Highlighted Articles + +* https://neo4j.com/blog/graphrag-python-package/[GraphRAG Python Package: Accelerating GenAI With Knowledge Graphs^] +* https://neo4j.com/developer-blog/get-started-graphrag-python-package/[Getting Started With the Neo4j GraphRAG Python Package^] +* https://neo4j.com/developer-blog/graph-traversal-graphrag-python-package/[Vector Search With Graph Traversal the Using Neo4j GraphRAG Package^] +* https://neo4j.com/developer-blog/hybrid-retrieval-graphrag-python-package/[Hybrid Retrieval Using the Neo4j GraphRAG Package for Python^] +* https://neo4j.com/developer-blog/enhancing-hybrid-retrieval-graphrag-python-package/[Enhancing Hybrid Retrieval With Graph Traversal: Neo4j GraphRAG Python^] \ No newline at end of file diff --git a/modules/genai-ecosystem/pages/haystack.adoc b/modules/genai-ecosystem/pages/haystack.adoc deleted file mode 100644 index 0410e781..00000000 --- a/modules/genai-ecosystem/pages/haystack.adoc +++ /dev/null @@ -1,71 +0,0 @@ -= Haystack Neo4j Integration -:slug: haystack -:author: -:category: genai-ecosystem -:tags: haystack, integration, llm, neo4j, vector index -:neo4j-versions: 5.x -:page-pagination: -:page-product: haystack - - -An integration of Neo4j graph database with Haystack v2.0 by deepset. In Neo4j Vector search index is being used for storing document embeddings and dense retrievals. - -The library allows using Neo4j as a DocumentStore, and implements the required Protocol methods. You can start working with the implementation by importing it from neo4_haystack package. - -== Installation - -[source,python] ----- -# pip install neo4j-haystack -from neo4j_haystack import Neo4jDocumentStore - -document_store = Neo4jDocumentStore( - url="bolt://localhost:7687", - username="neo4j", - password="passw0rd", - database="neo4j", - embedding_dim=384, - embedding_field="embedding", - index="document-embeddings", # The name of the Vector Index in Neo4j - node_label="Document", # Providing a label to Neo4j nodes which store Documents -) ----- - -== Functionality Includes - -* `Neo4jEmbeddingRetriever` - is a typical retriever component which can be used to query vector store index and find related Documents. The component uses Neo4jDocumentStore to query embeddings. -* `Neo4jDynamicDocumentRetriever` is also a retriever component in a sense that it can be used to query Documents in Neo4j. However it is decoupled from Neo4jDocumentStore and allows to run arbitrary Cypher query to extract documents. Practically it is possible to query Neo4j same way Neo4jDocumentStore does, including vector search. - -== Relevant Links -[cols="1,4"] -|=== -| icon:user[] Authors | https://github.com/prosto[Sergey Bondarenco^] -| icon:comments[] Community Support | https://community.neo4j.com/[Neo4j Online Community^] -| icon:github[] Repository | https://github.com/prosto/neo4j-haystack[GitHub] -| icon:github[] Issues | https://github.com/prosto/neo4j-haystack/issues -| icon:book[] Documentation | https://haystack.deepset.ai/integrations/neo4j-document-store -| icon:book[] Example Notebook | https://github.com/prosto/neo4j-haystack-playground -|=== - - -== Videos & Tutorials - -Online Meetup / Livestream with Sergey Bondarenco and Andreas Kollegger - -Neo4j & Haystack Part 1: Knowledge Graphs for RAG: - -++++ - -++++ - -Neo4j & Haystack Part 2: How the Integration Works: - -++++ - -++++ - -//// -== Highlighted Articles - -// link:https://medium.com/neo4j/....[article^] -//// diff --git a/modules/genai-ecosystem/pages/index.adoc b/modules/genai-ecosystem/pages/index.adoc index 27f770a2..8c3cae0c 100644 --- a/modules/genai-ecosystem/pages/index.adoc +++ b/modules/genai-ecosystem/pages/index.adoc @@ -1,4 +1,4 @@ -= GenAI Ecosystem += GraphRAG Developer Guide include::_graphacademy_llm.adoc[] :imagesdir: https://s3.amazonaws.com/dev.assets.neo4j.com/wp-content/uploads :slug: genai-ecosystem @@ -9,20 +9,17 @@ include::_graphacademy_llm.adoc[] :page-pagination: :page-product: GenAI Ecosystem -image::https://dist.neo4j.com/wp-content/uploads/20231030151119/genai-art-diagram-1.svg[width=800] +image::graphrag-image-simple.png[width=800, align=center] +Graph databases provide unmatched data organization, flexibility, and standardization, making it easy to write diverse queries and answer more questions. +https://neo4j.com/blog/genai/what-is-graphrag[GraphRAG (retrieval-augmented generation with graphs)^] extends these benefits to AI, enabling developers to build more accurate, agile, and extensible GenAI apps and agentic systems. Use these resources to get started today! -Knowledge graphs bring more accurate responses, rich context, and explainability to each generative AI model interaction. -By combining knowledge graphs with native vector search, you get the best of both worlds with Graph RAG (Retrieval Augmented Generation). +== How to Get Started -Language models also can be used to extract entities and their relationships from unstructured text to build up and enrich knowledge graphs. - -== How to get started - -1. For an high level overview, have a look at https://neo4j.com/generativeai/[neo4j.com/genai^] -2. Use the xref:llm-graph-builder.adoc[LLM-Knowledge Graph Builder] to turn your own documents into a knowledge graph +1. For a high level overview, have a look at https://neo4j.com/generativeai/[neo4j.com/genai^] +2. Use the https://neo4j.com/labs/genai-ecosystem/llm-graph-builder[LLM-Knowledge Graph Builder^] to turn your own documents into a knowledge graph or see the example projects below for building graphs from mixed structured & unstructured data. 3. If you want to learn more take one of the https://graphacademy.neo4j.com/categories/llms/?ref=genai-docs[GenAI GraphAcademy courses^] -4. Pick your xref:genai-frameworks.adoc[GenAI framework of choice] and start building your own GenAI applications with Neo4j +4. Pick your https://neo4j.com/labs/genai-ecosystem/genai-frameworks[GenAI framework of choice^] and start building your own GenAI applications with Neo4j == GraphAcademy Courses @@ -30,70 +27,57 @@ If you want to learn how LLMs and Knowledge Graphs combine to improve GenAI appl image::https://cdn.graphacademy.neo4j.com/assets/img/courses/banners/llm-fundamentals.png[link=https://graphacademy.neo4j.com/categories/llms/?ref=genai-docs] -== GenAI Ecosystem - -The Neo4j GenAI Ecosystem is a collection of tools and integrations that make it easy to use LLMs with Neo4j. - -=== GraphRAG - -GraphRAG combines an ingestion process that extracts entities and relationships from unstructured text and further uses graph algorithms for enrichment and summarization. -The retrieval step then uses the knowledge graph in combination with vector search to navigate to more relevant information than just the initial text chunks. - -* https://neo4j.com/blog/graphrag-manifesto/[The GraphRAG Manifesto] -* https://dev.neo4j.com/dlai-kg[DeepLearning AI Knowledge Graph Course^] -* http://discord.gg/graphrag[GraphRAG Discord^] -// * https://huggingface.co/graphrag[GraphRAG HuggingFace Paper Collection^] -* https://dev.neo4j.com/free-kg-book[(free) Knowledge Graph Book^] -* https://neo4j.com/developer-blog/global-graphrag-neo4j-langchain/[Implementing GraphRAG with Neo4j, GDS and LangChain] -* https://microsoft.github.io/graphrag/[Microsoft's GraphRAG project] +== Example Projects & Use Case Applications +Explore these projects to see how GraphRAG is applied in GenAI & agent workflows, various use cases, and integrations with specific cloud service providers. -=== GraphRAG Ecosystem Tools +* xref:ai-for-customer-experiences.adoc[GraphRAG for Customer Experience] +* https://neo4j.com/blog/developer/graphrag-in-action/[Agentic GraphRAG for Commercial Contract Q&A] +* https://neo4j.com/labs/genai-ecosystem/aws-demo[GraphRAG with AWS Bedrock - Getting Started^] +* https://github.com/neo4j-product-examples/neo4j-aws-ai-examples[GraphRAG on AWS with Unstructured/Structured/Mixed Data^] +* https://neo4j.com/labs/genai-ecosystem/microsoft-azure-demo[GraphRAG with Microsoft Azure OpenAI^] +* https://neo4j.com/labs/genai-ecosystem/google-cloud-demo[GraphRAG with Google Vertex AI^] -In Neo4j Labs we built a number of tools, to demonstrate the power of combining graphs with LLMs. All these tools are open source, you can use and contribute to them or learn and build your own. -* xref:llm-graph-builder.adoc[LLM Knowledge Graph Builder] -* xref:neoconverse.adoc[NeoConverse multi-dataset query, chat, visualization] -* xref:rag-demo.adoc[GraphRAG (Retrieval Augmented Generation) Demo] -* xref:genai-stack.adoc[GenAI Stack (with Docker, Ollama, Neo4j, and LangChain)] +== Neo4j GenAI Product Features -=== Cloud Examples +Neo4j has a number of features & product supported tools to make it easier to build GenAI applications and integrate LLMs with knowledge graphs. -Neo4j has worked with the main cloud providers to create GenAI integrations and examples on their platforms. +* xref:graphrag-python.adoc[GraphRAG Python Package] +* https://python.langchain.com/docs/integrations/providers/neo4j[`langchain-neo4j` (vendor supported package)] +* xref:vector-search.adoc[Vector Index & Search in Neo4j] -* xref:aws-demo.adoc[AWS Demo] -* xref:microsoft-azure-demo.adoc[Microsoft Azure Demo] -* xref:google-cloud-demo.adoc[Google Cloud Demo] -=== Neo4j GenAI Features +== GraphRAG Ecosystem Tools -Neo4j added a number of features to make it easier to build GenAI applications and integrate LLMs with knowledge graphs. +In Neo4j Labs we built a number of tools to demonstrate the power of combining graphs with LLMs. These tools are open source, you can use and contribute to them or learn and build your own. -* xref:vector-search.adoc[Vector Index & Search] -* xref:apoc-genai.adoc[APOC GenAI Procedures] +* https://neo4j.com/labs/genai-ecosystem/llm-graph-builder[LLM Knowledge Graph Builder^] +* https://neo4j.com/labs/genai-ecosystem/neoconverse[NeoConverse multi-dataset query, chat, visualization^] +* https://neo4j.com/labs/genai-ecosystem/apoc-genai[APOC GenAI Procedures^] -=== GenAI Frameworks -Neo4j and our community have contributed integrations to many of these frameworks. -You can find overviews of these integrations in the pages of this section, as well as code examples, tutorials and more. +== GenAI Frameworks -* xref:langchain.adoc[LangChain (Python)] -* xref:langchain-js.adoc[LangChainJS] -* xref:llamaindex.adoc[LLamaIndex] -* xref:spring-ai.adoc[Spring AI] -* xref:langchain4j.adoc[LangChain4j] -* xref:haystack.adoc[Haystack] -* xref:semantic-kernel.adoc[Semantic Kernel] -* xref:dspy.adoc[DSPy] +Neo4j and our community have contributed integrations to many GenAI development frameworks. +You can find overviews of these integrations https://neo4j.com/labs/genai-ecosystem/genai-frameworks[here^], as well as code examples, tutorials and more. Popular frameworks include: -== Highlighted Articles +* https://neo4j.com/labs/genai-ecosystem/langchain[LangChain (Python)^] +* https://neo4j.com/labs/genai-ecosystem/langchain-js[LangChainJS^] +* https://neo4j.com/labs/genai-ecosystem/langchain4j[LangChain4j^] +* https://neo4j.com/labs/genai-ecosystem/llamaindex[LLamaIndex^] +* https://neo4j.com/labs/genai-ecosystem/spring-ai[Spring AI^] +* https://neo4j.com/labs/genai-ecosystem/semantic-kernel[Semantic Kernel^] +* https://neo4j.com/labs/genai-ecosystem/haystack[Haystack^] +* https://neo4j.com/labs/genai-ecosystem/dspy[DSPy^] -* https://neo4j.com/developer-blog/tagged/llm/[Neo4j Developer Blog: Large Language Models^] -* https://bratanic-tomaz.medium.com/[Tomaz Bratanic's Medium Blog^] -* https://medium.com/@yu-joshua[Joshua Yu's Medium Blog^] +== Additional Resources -== Videos & Tutorials +* https://neo4j.com/blog/graphrag-manifesto[The GraphRAG Manifesto^] +* https://neo4j.com/blog/genai/what-is-graphrag[What is GraphRAG?^] +* https://dev.neo4j.com/dlai-kg[DeepLearning AI Knowledge Graph Course^] +* http://discord.gg/graphrag[GraphRAG Discord^] +* https://dev.neo4j.com/free-kg-book[(free) Knowledge Graph Book^] -- https://neo4j.com/blog/unifying-llm-knowledge-graph/[Unifying Large Language Models and Knowledge Graphs Use-Case and Integrations] ++++ ++++ diff --git a/modules/genai-ecosystem/pages/langchain-js.adoc b/modules/genai-ecosystem/pages/langchain-js.adoc deleted file mode 100644 index a968786f..00000000 --- a/modules/genai-ecosystem/pages/langchain-js.adoc +++ /dev/null @@ -1,172 +0,0 @@ -= LangchainJS -include::_graphacademy_llm.adoc[] -:slug: langchain-js -:author: -:category: genai-ecosystem -:tags: langchain, langchain js, javascript, typescript, neo4j, vector, index -:neo4j-versions: 5.x -:page-pagination: -:page-product: langchain-js - -image::https://dist.neo4j.com/wp-content/uploads/20230615211357/1AH05dvGA_7db_EMySc9AAw.png[width=800] - -https://js.langchain.com/docs/get_started/introduction[LangChain.js^] is a JavaScript/TypeScript implementation of the LangChain library. -It uses similar concepts, with Prompts, Chains, Transformers, Document Loaders, Agents, and more. - -Here is an overview of the https://js.langchain.com/docs/use_cases/graph/quickstart[Graph Integrations^]. - -The Neo4j Integration makes the xref:vector-search.adoc[Neo4j Vector] index as well as Cypher generation and execution available in the LangChain.js library. - -Learn how to build a chatbot in TypeScript using LangChain.js with our new https://graphacademy.neo4j.com/courses/llm-chatbot-typescript/[GraphAcademy course^]. - -image::https://cdn.graphacademy.neo4j.com/assets/img/courses/banners/llm-chatbot-typescript.png[width=800,link="https://graphacademy.neo4j.com/courses/llm-chatbot-typescript/"] - -== Installation - -[source,shell] ----- -npm install @langchain/openai neo4j-driver @langchain/community ----- - -== Functionality Includes - -=== Neo4jVector - -The Neo4j Vector integration supports a number of operations - -* create vector from langchain documents -* query vector -* query vector with additional graph retrieval Cypher query -* construct vector instance from existing graph data -* hybrid search - -// todo include -[source,javascript] ----- -import { OpenAIEmbeddings } from "@langchain/openai"; -import { Neo4jVectorStore } from "@langchain/community/vectorstores/neo4j_vector"; - -// Configuration object for Neo4j connection and other related settings -const config = { - url: "bolt://localhost:7687", // URL for the Neo4j instance - username: "neo4j", // Username for Neo4j authentication - password: "pleaseletmein", // Password for Neo4j authentication - indexName: "vector", // Name of the vector index - keywordIndexName: "keyword", // Name of the keyword index if using hybrid search - searchType: "vector" as const, // Type of search (e.g., vector, hybrid) - nodeLabel: "Chunk", // Label for the nodes in the graph - textNodeProperty: "text", // Property of the node containing text - embeddingNodeProperty: "embedding", // Property of the node containing embedding -}; - -const documents = [ - { pageContent: "what's this", metadata: { a: 2 } }, - { pageContent: "Cat drinks milk", metadata: { a: 1 } }, -]; - -const neo4jVectorIndex = await Neo4jVectorStore.fromDocuments( - documents, - new OpenAIEmbeddings(), - config -); - -const results = await neo4jVectorIndex.similaritySearch("water", 1); - -console.log(results); - -/* - [ Document { pageContent: 'Cat drinks milk', metadata: { a: 1 } } ] -*/ - -await neo4jVectorIndex.close(); ----- - -==== Hybrid Search - -Hybrid search combines vector search with fulltext search with re-ranking and de-duplication of the results. - -=== Neo4j Graph - -The Neo4j Graph integration is a wrapper for the Neo4j Python driver. -It allows querying and updating the Neo4j databsae in a simplified manner from LangChain. -Many integrations allow to use the Neo4j Graph as a source of data for LangChain. - - -[source,javascript] ----- -import { Neo4jGraph } from "@langchain/community/graphs/neo4j_graph"; - -const graph = await Neo4jGraph.initialize({ NEO4J_URL, NEO4J_USERNAME, NEO4J_PASSWORD }); - -QUERY = """ -"MATCH (m:Movie)-[:IN_GENRE]->(:Genre {name:$genre}) -RETURN m.title, m.plot -ORDER BY m.imdbRating DESC LIMIT 5" -""" - -await graph.query(QUERY, genre="action") ----- - -=== CypherQAChain - -The CypherQAChain is a LangChain component that allows you to interact with a Neo4j graph database in natural language. -Using an LLM and the graph schema it translates the user question into a Cypher query, executes it against the graph and uses the returned context information and the original question with a second LLM to generate a natural language response. - -[source,javascript] ----- -import { Neo4jGraph } from "@langchain/community/graphs/neo4j_graph"; -import { OpenAI } from "@langchain/openai"; -import { GraphCypherQAChain } from "langchain/chains/graph_qa/cypher"; - -const graph = await Neo4jGraph.initialize({ NEO4J_URL, NEO4J_USERNAME, NEO4J_PASSWORD }); -const model = new OpenAI({ temperature: 0 }); - -// Populate the database with two nodes and a relationship -await graph.query(` - CREATE (a:Actor {name:'Bruce Willis'}) - -[:ACTED_IN]->(:Movie {title: 'Pulp Fiction'}) -`); - -await graph.refreshSchema(); - -const chain = GraphCypherQAChain.fromLLM({ llm: model, graph }); - -const res = await chain.run("Who acted in Pulp Fiction?"); -// Bruce Willis acted in Pulp Fiction. ----- - -=== Knowledge Graph Construction - -Creating a Knowledge Graph from unstructured data like PDF documents used to be a complex and time-consuming task that required training and using dedicated, large NLP models. - -The https://js.langchain.com/docs/use_cases/graph/construction[Graph Transformers^] are tools that allows you to extract structured data from unstructured documents and transform it into a Knowledge Graph. - -== Documentation - -* https://js.langchain.com/docs/modules/data_connection/experimental/graph_databases/neo4j[Neo4jGraph^] -* https://js.langchain.com/docs/modules/chains/additional/cypher_chain[GraphCypherQAChain^] -* https://js.langchain.com/docs/integrations/vectorstores/neo4jvector[Neo4j Vector^] - -== Relevant Links -[cols="1,4"] -|=== -| icon:user[] Authors | https://github.com/easwee[Anej Gorkič^], https://github.com/tomasonjo[Tomaz Bratanic^] and https://github.com/oskarhane[Oskar Hane^] -| icon:comments[] Community Support | https://community.neo4j.com/[Neo4j Online Community^] -| icon:github[] Data Repository | https://github.com/langchain-ai/langchainjs[GitHub] -| icon:github[] Issues | https://github.com/langchain-ai/langchainjs/issues -| icon:book[] Documentation | https://js.langchain.com/docs/use_cases/graph/quickstart -| icon:book[] Documentation | https://js.langchain.com/docs/modules/data_connection/experimental/graph_databases/neo4j -|=== - -== Videos & Tutorials - -++++ - -++++ - -//// -== Highlighted Articles - -link:https://medium.com/neo4j/....[article^] - -//// diff --git a/modules/genai-ecosystem/pages/langchain.adoc b/modules/genai-ecosystem/pages/langchain.adoc deleted file mode 100644 index 98b23b7f..00000000 --- a/modules/genai-ecosystem/pages/langchain.adoc +++ /dev/null @@ -1,364 +0,0 @@ -= LangChain Neo4j Integration -include::_graphacademy_llm.adoc[] -:slug: langchain -:author: Tomaz Bratanic -:category: labs -:tags: langchain, rag, vector search, , neo4j -:neo4j-versions: 5.x -:page-pagination: -:page-product: langchain - -image::https://dist.neo4j.com/wp-content/uploads/20230615211357/1AH05dvGA_7db_EMySc9AAw.png[width=800] - -LangChain is a vast library for GenAI orchestration, it supports numerous LLMs, vector stores, document loaders and agents. -It manages templates, composes components into chains and supports monitoring and observability. - -The broad and deep Neo4j integration allows for vector search, cypher generation and database querying and knowledge graph construction. - -Here is an overview of the https://python.langchain.com/docs/use_cases/graph/quickstart[Graph Integrations^]. - -* https://towardsdatascience.com/integrating-neo4j-into-the-langchain-ecosystem-df0e988344d2[Integrating Neo4j into the LangChain Ecosystem^] - -NOTE: When upgrading to LangChain 0.1.0+ make sure to read this article: https://medium.com/neo4j/langchain-v0-1-updating-graphacademy-neo4j-llm-courses-689e7c4eff3e[Updating GraphAcademy Neo4j & LLM Courses to Langchain v0.1^]. - -image::https://cdn.graphacademy.neo4j.com/assets/img/courses/banners/llm-chatbot-python.png[width=800,link="https://graphacademy.neo4j.com/courses/llm-chatbot-python/"] - -== Installation - -[source,shell] ----- -pip install langchain langchain-community -# pip install langchain-openai tiktoken -# pip install neo4j ----- -== Functionality Includes - -=== Neo4jVector - -The Neo4j Vector integration supports a number of operations - -* create vector from langchain documents -* query vector -* query vector with additional graph retrieval Cypher query -* construct vector instance from existing graph data -* hybrid search -* metadata filtering - -// todo include -[source,python] ----- -from langchain.docstore.document import Document -from langchain.text_splitter import CharacterTextSplitter -from langchain_community.document_loaders import TextLoader -from langchain_community.vectorstores import Neo4jVector -from langchain_openai import OpenAIEmbeddings - -loader = TextLoader("../../modules/state_of_the_union.txt") - -documents = loader.load() -text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0) -docs = text_splitter.split_documents(documents) - -embeddings = OpenAIEmbeddings() - -# The Neo4jVector Module will connect to Neo4j and create a vector index if needed. - -db = Neo4jVector.from_documents( - docs, OpenAIEmbeddings(), url=url, username=username, password=password -) - -query = "What did the president say about Ketanji Brown Jackson" -docs_with_score = db.similarity_search_with_score(query, k=2) ----- - -* link:https://neo4j.com/developer-blog/langchain-library-full-support-neo4j-vector-index/[LangChain Library Adds Full Support for Neo4j Vector Index^][] -* https://neo4j.com/developer-blog/neo4j-langchain-vector-index-implementation/[Neo4j LangChain Vector Index Implementation^] -* https://blog.langchain.dev/neo4j-x-langchain-new-vector-index/[Neo4j x LangChain: New Vector Index^] - -==== Hybrid Search - -Hybrid search combines vector search with fulltext search with re-ranking and de-duplication of the results. - -// todo include -[source,python] ----- -from langchain.docstore.document import Document -from langchain.text_splitter import CharacterTextSplitter -from langchain_community.document_loaders import TextLoader -from langchain_community.vectorstores import Neo4jVector -from langchain_openai import OpenAIEmbeddings - -loader = TextLoader("../../modules/state_of_the_union.txt") - -documents = loader.load() -text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0) -docs = text_splitter.split_documents(documents) - -embeddings = OpenAIEmbeddings() - -# The Neo4jVector Module will connect to Neo4j and create a vector index if needed. - -db = Neo4jVector.from_documents( - docs, OpenAIEmbeddings(), url=url, username=username, password=password, - search_type: 'hybrid' -) - -query = "What did the president say about Ketanji Brown Jackson" -docs_with_score = db.similarity_search_with_score(query, k=2) ----- - -==== Metadata filtering - -Metadata filtering enhances vector search by allowing searches to be refined based on specific node properties. -This integrated approach ensures more precise and relevant search results by leveraging both the vector similarities and the contextual attributes of the nodes. - -[source,python] ----- -db = Neo4jVector.from_documents( - docs, - OpenAIEmbeddings(), - url=url, username=username, password=password -) - -query = "What did the president say about Ketanji Brown Jackson" -filter = {"name": {"$eq": "adam"}} - -docs = db.similarity_search(query, filter=filter) ----- - -=== Neo4j Graph - -The Neo4j Graph integration is a wrapper for the Neo4j Python driver. -It allows querying and updating the Neo4j database in a simplified manner from LangChain. -Many integrations allow you to use the Neo4j Graph as a source of data for LangChain. - - -[source,python] ----- -from langchain_community.graphs import Neo4jGraph - -graph = Neo4jGraph(url=NEO4J_URI, username=NEO4J_USERNAME, password=NEO4J_PASSWORD) - -QUERY = """ -"MATCH (m:Movie)-[:IN_GENRE]->(:Genre {name:$genre}) -RETURN m.title, m.plot -ORDER BY m.imdbRating DESC LIMIT 5" -""" - -graph.query(QUERY, genre="action") ----- - -=== CypherQAChain - -The CypherQAChain is a LangChain component that allows you to interact with a Neo4j graph database in natural language. -Using an LLM and the graph schema it translates the user question into a Cypher query, executes it against the graph and uses the returned context information and the original question with a second LLM to generate a natural language response. - -// todo include -[source,python] ----- -# pip install --upgrade --quiet langchain -# pip install --upgrade --quiet langchain-openai - -from langchain.chains import GraphCypherQAChain -from langchain_community.graphs import Neo4jGraph -from langchain_openai import ChatOpenAI - -graph = Neo4jGraph(url=NEO4J_URI, username=NEO4J_USERNAME, password=NEO4J_PASSWORD) - -# Insert some movie data -graph.query( - """ -MERGE (m:Movie {title:"Top Gun"}) -WITH m -UNWIND ["Tom Cruise", "Val Kilmer", "Anthony Edwards", "Meg Ryan"] AS actor -MERGE (a:Actor {name:actor}) -MERGE (a)-[:ACTED_IN]->(m) -""" -) - -chain = GraphCypherQAChain.from_llm( - ChatOpenAI(temperature=0), graph=graph, verbose=True -) - -chain.run("Who played in Top Gun?") ----- - -=== Advanced RAG Strategies - -Besides the basic RAG strategy, the Neo4j Integration in LangChain supports advanced RAG strategies that allow for more complex retrieval strategies. -These are also available as LangChain Templates. - -* *regular rag* - direct vector search -* *parent - child retriever* that links embedded chunks representing specific concepts to parent documents -* *hypothetical questions* - generate questions from the document chunks and vector index those to have better matching candidates for user questions -* *summary* - index summaries of the documents not the whole document - -* https://blog.langchain.dev/implementing-advanced-retrieval-rag-strategies-with-neo4j/[Implementing Advanced Retrieval RAG Strategies with Neo4j^] - -* https://python.langchain.com/docs/templates/neo4j-advanced-rag - -[source,shell] ----- -pip install -U "langchain-cli[serve]" - -langchain app new my-app --package neo4j-advanced-rag - -# update server.py to add the neo4j-advanced-rag template as an endpoint -cat < server.py -from fastapi import FastAPI -from langserve import add_routes - -from neo4j_advanced_rag import chain as neo4j_advanced_chain - -app = FastAPI() - -# Add this -add_routes(app, neo4j_advanced_chain, path="/neo4j-advanced-rag") - - -if __name__ == "__main__": - import uvicorn - - uvicorn.run(app, host="0.0.0.0", port=8000) -EOF - -langchain serve ----- - -image::https://lh7-us.googleusercontent.com/jfDNiPa5ccefX6h0HiVzJbqnlgAZgfPda90truHSfbwSs3JkfxZ-xbA9mZE8y2fNf_3n5cgVhbdhN0ryuMoK2JNbMgTe1OLJMA6CQRhWBxzdKRLVurUFDndT7ki4vMh-cdv3SAn040HTpab9XkzGj5Q[] - -=== LangChain Templates - -https://blog.langchain.dev/langchain-templates/[Langchain Templates^] are a set of preconfigured chains and components that can be used to build GenAI workflows and applications. -You can test them interactively on the LangChain Playground and run them with https://github.com/langchain-ai/langserve[LangServe^] to run as REST APIs, they also integrate with [LangSmith] for monitoring and observability. - -By creating an application from templates, their source code is added to your application and you can modify them to fit your needs. - -==== List of Templates - -This https://python.langchain.com/docs/templates/neo4j-cypher[Cypher template] allows you to interact with a Neo4j graph database in natural language, using an OpenAI LLM. - -It transforms a natural language question into a Cypher query (used to fetch data from Neo4j databases), executes the query, and provides a natural language response based on the query results. - -The https://python.langchain.com/docs/templates/neo4j-cypher-ft[Cypher-FT Template^] additionally utilizes a full-text index for efficient mapping of text values to database entries, thereby enhancing the generation of accurate Cypher statements. - -The https://python.langchain.com/docs/templates/neo4j-cypher-memory[Cypher Memory Template^] also features a conversational memory module that stores the dialogue history in the Neo4j graph database. The conversation memory is uniquely maintained for each user session, ensuring personalized interactions. - -The https://python.langchain.com/docs/templates/neo4j-generation[Neo4j generation Template^] pairs LLM-based knowledge graph extraction using OpenAI functions, with Neo4j AuraDB, a fully managed cloud graph database. - -This https://python.langchain.com/docs/templates/neo4j-vector-memory[Neo4j Vector Memory Template^] allows you to integrate an LLM with a vector-based retrieval system using Neo4j as the vector store. Additionally, it uses the graph capabilities of the Neo4j database to store and retrieve the dialogue history of a specific user's session. Having the dialogue history stored as a graph allows for seamless conversational flows but also gives you the ability to analyze user behavior and text chunk retrieval through graph analytics. - -The https://python.langchain.com/docs/templates/neo4j-parent[Parent-Child Retriever Template^] allows you to balance precise embeddings and context retention by splitting documents into smaller chunks and retrieving their original or larger text information. - -Using a Neo4j vector index, the package queries child nodes using vector similarity search and retrieves the corresponding parent's text. - -The https://python.langchain.com/docs/templates/neo4j-semantic-layer[Neo4j Semantic Layer Template^] is designed to implement an agent capable of interacting with a graph database like Neo4j through a semantic layer using OpenAI function calling. The semantic layer equips the agent with a suite of robust tools, allowing it to interact with the graph databas based on the user's intent. - -=== Semantic Layer - -A semantic layer on top of a (graph) database doesn't rely on automatic query generation but offers a number of APIs and tools to give the LLM access to the database and it's structures. - -Unlike automatically generated queries, these tools are safe to use as they are implemented using correct queries and interactions and only take parameters from the LLM. - -Many cloud (llm) providers offer similar integrations either via function calling (OpenAI, Anthropic) or extensions (Google Vertex AI, AWS Bedrock). - -Examples for such tools or functions include: - -* retrieve entities with certain names -* retrieve the neighbors of a node -* retrieve a shortest path between two nodes - -* https://towardsdatascience.com/enhancing-interaction-between-language-models-and-graph-databases-via-a-semantic-layer-0a78ad3eba49[ Enhancing Interaction Between Language Models and Graph Databases via a Semantic Layer^] - - -=== Conversational Memory - -Storing the conversation, i.e. the flow of questions and answers of user sessions in a graph allows you to analyze the conversation history and use it to improve the user experience. - -You can index embeddings for and link questions and answers back to the retrieved chunks and entities in the graph and use user feedback to re-rank those inputs for future similar questions. - -=== Knowledge Graph Construction - -Creating a Knowledge Graph from unstructured data like PDF documents used to be a complex and time-consuming task that required training and using dedicated, large NLP models. - -The https://python.langchain.com/docs/use_cases/graph/constructing[Graph Transformers^] are tools that allows you to extract structured data from unstructured documents and transform it into a Knowledge Graph. - -NOTE: You can see a practical application, code and demo for extracting knowledge graphs from PDFs, YouTube transcripts, wikpedia articles and more with the xref:llm-graph-builder.adoc[LLM Graph Builder]. - -image:: - -* https://python.langchain.com/docs/use_cases/graph/integrations/diffbot_graphtransformer[Diffbot Graph Transformer^] -* https://python.langchain.com/docs/use_cases/graph/constructing#llm-graph-transformer[LLM Graph Transformer^] - -* https://neo4j.com/developer-blog/knowledge-graph-based-chatbot-with-gpt-3-and-neo4j/[Knowledge Graph-based Chatbot with GPT-3 and Neo4j^] -* https://blog.langchain.dev/constructing-knowledge-graphs-from-text-using-openai-functions/[Constructing Knowledge Graphs from Text using OpenAI Functions^] -* https://neo4j.com/developer-blog/enhance-rag-knowledge-graph/[Enhancing the Accuracy of RAG Applications With Knowledge Graphs^] -* https://www.youtube.com/watch?v=ViHV16ly-qs[Video: Going Meta Ep 25 - LLMs for Automated KG Construction^] - -== Documentation - -* https://python.langchain.com/docs/integrations/providers/neo4j/[Neo4j Integrations^] -* https://python.langchain.com/docs/use_cases/graph/graph_cypher_qa[Graph Cypher QA Chain^] -* https://python.langchain.com/docs/integrations/vectorstores/neo4jvector[Neo4j Vector^] -* https://python.langchain.com/docs/use_cases/graph/constructing[Graph Transformers^] - -== Starter Kit - -This https://github.com/neo4j-examples/langchain-starter-kit/blob/main/app/vector_chain.py[starter-kit] demonstrates how to run a FastAPI server using LangChain to answer queries on data stored in a Neo4j instance. The single endpoint can be used to retrieve answers using either a https://python.langchain.com/v0.1/docs/integrations/vectorstores/neo4jvector/[Vector index chain], https://python.langchain.com/v0.1/docs/integrations/graphs/neo4j_cypher/[GraphCypherQA Chain], or a composite answer of both. The https://github.com/neo4j-examples/langchain-starter-kit/tree/langserve[langserve] branch contains an example of the same service, using https://python.langchain.com/v0.1/docs/langserve/[LangServe] - -See this https://neo4j.com/developer-blog/langchain-neo4j-starter-kit/[Developer Blog Article] for additional details and instructions on working with the Starter Kit. - -== Relevant Links -[cols="1,4"] -|=== -| icon:user[] Authors | https://github.com/tomasonjo[Tomaz Bratanic^] -| icon:comments[] Community Support | https://community.neo4j.com/[Neo4j Online Community^] -| icon:github[] Data Repository | https://github.com/langchain-ai/langchain[GitHub] -| icon:github[] Issues | https://github.com/langchain-ai/langchain/issues -| icon:book[] Documentation | https://python.langchain.com/docs/integrations/providers/neo4j/[Neo4j Integrations^] -| icon:book[] Documentation | https://python.langchain.com/docs/use_cases/graph/quickstart[Graph Overview Docs^] -| icon:github[] Starter Kit |https://github.com/neo4j-examples/langchain-starter-kit[LangChain Starter Kit^] -| icon:code[] Juypter | https://github.com/tomasonjo/blogs/tree/master/llm[Jupyter Notebooks^] -|=== - -== Videos & Tutorials - -++++ - -++++ - -++++ - -++++ - -++++ - -++++ - -++++ - -++++ - -++++ - -++++ - -++++ - -++++ - -* https://docs.google.com/presentation/d/1J4h4oGXORtiz1nhHfSF-UtvtlqkfHByD0v2MOwKXBwY/edit#slide=id.g265aec74fa4_0_353[Slides from the video^] - - -== Highlighted Articles - -* https://graphstuff.fm/episodes/genai-solutions-with-langchain-lance-martin-on-llms-agents-evals-and-more[Podcast: GenAI solutions with LangChain: Lance Martin on LLMs, agents, evals, and more!^] -* https://blog.langchain.dev/using-a-knowledge-graph-to-implement-a-devops-rag-application/[Using a Knowledge Graph to Implement a DevOps RAG Application^] -* https://neo4j.com/developer-blog/unstructured-knowledge-graph-neo4j-langchain/[Unstructured Knowledge Graph with Neo4j and LangChain^] -* https://neo4j.com/developer-blog/langchain-cypher-search-tips-tricks/[LangChain Cypher Search Tips & Tricks^] -* https://medium.com/neo4j/langchain-neo4j-starter-kit-02054212d8ef[LangChain Neo4j Starter Kit] -* https://medium.com/neo4j/langchain-v0-1-updating-graphacademy-neo4j-llm-courses-689e7c4eff3e[Updating GraphAcademy Neo4j & LLM Courses to Langchain v0.1^] -* https://neo4j.com/developer-blog/why-vector-search-didnt-work-rag/[Why Vector Search Didn’t Work for Your RAG Solution?^] -* https://blog.langchain.dev/constructing-knowledge-graphs-from-text-using-openai-functions/[Constructing Knowledge Graphs from Text using OpenAI Functions^] -* https://blog.langchain.dev/using-a-knowledge-graph-to-implement-a-devops-rag-application/[Using a Knowledge Graph to Implement a DevOps RAG Application^] -* https://medium.com/neo4j/json-based-agents-with-ollama-langchain-9cf9ab3c84ef[JSON-based Agents with Ollama & LangChain^] diff --git a/modules/genai-ecosystem/pages/langchain4j.adoc b/modules/genai-ecosystem/pages/langchain4j.adoc deleted file mode 100644 index 5aefaaab..00000000 --- a/modules/genai-ecosystem/pages/langchain4j.adoc +++ /dev/null @@ -1,65 +0,0 @@ -= Langchain4j -include::_graphacademy_llm.adoc[] -:slug: langchain4j -:author: Giuseppe Villani -:category: genai-ecosystem -:tags: langchain, langchain4j, java, neo4j, vector, index -:neo4j-versions: 5.x -:page-pagination: -:page-product: langchain4j - -image::https://avatars.githubusercontent.com/u/132277850?v=4[width=400] - -https://github.com/langchain4j[Langchain4j^] is a Java implementation of the langchain library. -It uses similar concepts, with Prompts, Chains, Transformers, Document Loaders, Agents, and more. - -The Neo4j Integration makes the xref:vector-search.adoc[Neo4j Vector] index available in the Langchain4j library. - -// https://github.com/langchain4j/langchain4j/tree/main/langchain4j-neo4j - -== Installation - -.pom.xml -[source,xml] ----- -include::https://github.com/langchain4j/langchain4j-examples/raw/main/neo4j-example/pom.xml[lines=19..23] ----- - -== Functionality Includes - -* Create vector index -* Populate nodes and vector index from documents -* Query vector index - -== Documentation - -An example is avalable at: https://github.com/langchain4j/langchain4j-examples/tree/main/neo4j-example - -[source,java] ----- -include::https://github.com/langchain4j/langchain4j-examples/raw/main/neo4j-example/src/main/java/Neo4jEmbeddingStoreExample.java[] ----- - -== Relevant Links -[cols="1,4"] -|=== -| icon:user[] Authors | https://github.com/vga91[Giuseppe Villani from Neo4j Partner Larus^] -| icon:comments[] Community Support | https://community.neo4j.com/[Neo4j Online Community^] -| icon:github[] Data Repository | https://github.com/langchain4j/langchain4j/[GitHub] -| icon:github[] Issues | https://github.com/langchain4j/langchain4j/issues -// | icon:book[] Documentation | -|=== - -//// - -== Videos & Tutorials - -Installation: -++++ - -++++ - -== Highlighted Articles - -// link:https://medium.com/neo4j/....[article^] -//// diff --git a/modules/genai-ecosystem/pages/llamaindex.adoc b/modules/genai-ecosystem/pages/llamaindex.adoc deleted file mode 100644 index 8c97c190..00000000 --- a/modules/genai-ecosystem/pages/llamaindex.adoc +++ /dev/null @@ -1,381 +0,0 @@ -= LlamaIndex -:slug: llamaindex -:author: Michael Hunger, Tomaz Bratanic -:category: labs -:tags: llama index, llm, framework, python, vector, cypher generation -:neo4j-versions: 5.x -:page-pagination: -:page-product: llamaindex - -// image::todo.png[width=800] - -LlamaIndex is a popular LLM orchestration framework with a clean architecture and a focus on data structures and models. -It integrates many LLMs as well as vector stores and other indexes and contains tooling for document loading (loader hub) and advanced RAG patterns. - -LlamaIndex provides a lot of detailed examples for GenAI application development in their https://blog.llamaindex.ai/[blogs^] and https://docs.llamaindex.ai[documentation^]. - -The Neo4j integration covers both the vector store as well as query generation from natural language and knowledge graph construction. - -== Functionality Includes - -=== Neo4jVector - -The Neo4j Vector integration supports a number of operations - -* create vector from langchain documents -* query vector -* query vector with additional graph retrieval Cypher query -* construct vector instance from existing graph data -* hybrid search -* metadata filtering - -[source,python] ----- -%pip install llama-index-llms-openai -%pip install llama-index-vector-stores-neo4jvector -%pip install llama-index-embeddings-openai -%pip install neo4j - -import os -import openai -from llama_index.vector_stores.neo4jvector import Neo4jVectorStore -from llama_index.core import VectorStoreIndex, SimpleDirectoryReader - -os.environ["OPENAI_API_KEY"] = "OPENAI_API_KEY" -openai.api_key = os.environ["OPENAI_API_KEY"] -username = "neo4j" -password = "pleaseletmein" -url = "bolt://localhost:7687" -embed_dim = 1536 - -neo4j_vector = Neo4jVectorStore(username, password, url, embed_dim) -# load documents -documents = SimpleDirectoryReader("./data/paul_graham").load_data() -from llama_index.core import StorageContext - -storage_context = StorageContext.from_defaults(vector_store=neo4j_vector) -index = VectorStoreIndex.from_documents( - documents, storage_context=storage_context -) - -query_engine = index.as_query_engine() -response = query_engine.query("What happened at interleaf?") ----- - -==== Hybrid search - -Hybrid search combines vector search with fulltext search with re-ranking and de-duplication of the results. - -[source,python] ----- -neo4j_vector_hybrid = Neo4jVectorStore( - username, password, url, embed_dim, hybrid_search=True -) - -storage_context = StorageContext.from_defaults( - vector_store=neo4j_vector_hybrid -) -index = VectorStoreIndex.from_documents( - documents, storage_context=storage_context -) -query_engine = index.as_query_engine() -response = query_engine.query("What happened at interleaf?") ----- - -==== Metadata filtering - -Metadata filtering enhances vector search by allowing searches to be refined based on specific node properties. -This integrated approach ensures more precise and relevant search results by leveraging both the vector similarities and the contextual attributes of the nodes. - -[source,python] ----- -from llama_index.core.vector_stores import ( - MetadataFilter, - MetadataFilters, - FilterOperator, -) - -filters = MetadataFilters( - filters=[ - MetadataFilter( - key="theme", operator=FilterOperator.EQ, value="Fiction" - ), - ] -) - -retriever = index.as_retriever(filters=filters) -retriever.retrieve("What is inception about?") ----- - -=== Neo4jPropertyGraphStore - -The Neo4j Property Graph Store integration is a wrapper for the Neo4j Python driver. -It allows querying and updating the Neo4j database in a simplified manner from LlamaIndex. -Many integrations allow you to use the Neo4j Property Graph Store as a source of data for LlamaIndex. - -==== Property graph index - -Knowledge graph index can be used to extract graph representation of information from text and use it to construct a knowledge graph. -The graph information can then be retrieved in a RAG application for more accurate responses. - -[source,python] ----- -%pip install llama-index llama-index-graph-stores-neo4j - -from llama_index.core import SimpleDirectoryReader -from llama_index.core import PropertyGraphIndex -from llama_index.embeddings.openai import OpenAIEmbedding -from llama_index.llms.openai import OpenAI -from llama_index.core.indices.property_graph import SchemaLLMPathExtractor - -from llama_index.graph_stores.neo4j import Neo4jPropertyGraphStore - -documents = SimpleDirectoryReader("./data/paul_graham/").load_data() -graph_store = Neo4jPropertyGraphStore( - username="neo4j", - password="password", - url="bolt://localhost:7687", -) -# Extract graph from documents -index = PropertyGraphIndex.from_documents( - documents, - embed_model=OpenAIEmbedding(model_name="text-embedding-3-small"), - kg_extractors=[ - SchemaLLMPathExtractor( - llm=OpenAI(model="gpt-3.5-turbo", temperature=0.0) - ) - ], - property_graph_store=graph_store, - show_progress=True, -) - -# Define retriever -retriever = index.as_retriever( - include_text=False, # include source text in returned nodes, default True -) -results = retriever.retrieve("What happened at Interleaf and Viaweb?") -for record in results: - print(record.text) - -# Question answering -query_engine = index.as_query_engine(include_text=True) -response = query_engine.query("What happened at Interleaf and Viaweb?") -print(str(response)) ----- - -==== Property Graph constructing modules - -LlamaIndex features multiple graph construction modules. -Property graph construction in LlamaIndex works by performing a series of `kg_extractors` on each text chunk, and attaching entities and relations as metadata to each llama-index node. -You can use as many as you like here, and they will all get applied. -Learn more about them in the https://docs.llamaindex.ai/en/latest/module_guides/indexing/lpg_index_guide/#construction[documentation^]. - -Here is an example of graph construction using a predefined schema. - -[source,python] ----- -%pip install llama-index llama-index-graph-stores-neo4j - -from typing import Literal -from llama_index.core import SimpleDirectoryReader -from llama_index.core import PropertyGraphIndex -from llama_index.embeddings.openai import OpenAIEmbedding -from llama_index.llms.openai import OpenAI -from llama_index.core.indices.property_graph import SchemaLLMPathExtractor - -from llama_index.graph_stores.neo4j import Neo4jPropertyGraphStore - -# best practice to use upper-case -entities = Literal["PERSON", "PLACE", "ORGANIZATION"] -relations = Literal["HAS", "PART_OF", "WORKED_ON", "WORKED_WITH", "WORKED_AT"] - -# define which entities can have which relations -validation_schema = { - "PERSON": ["HAS", "PART_OF", "WORKED_ON", "WORKED_WITH", "WORKED_AT"], - "PLACE": ["HAS", "PART_OF", "WORKED_AT"], - "ORGANIZATION": ["HAS", "PART_OF", "WORKED_WITH"], -} - -kg_extractor = SchemaLLMPathExtractor( - llm=OpenAI(model="gpt-3.5-turbo", temperature=0.0), - possible_entities=entities, - possible_relations=relations, - kg_validation_schema=validation_schema, - # if false, allows for values outside of the schema - # useful for using the schema as a suggestion - strict=True, -) -graph_store = Neo4jPropertyGraphStore( - username="neo4j", - password="password", - url="bolt://localhost:7687", -) -documents = SimpleDirectoryReader("./data/paul_graham/").load_data() -index = PropertyGraphIndex.from_documents( - documents, - kg_extractors=[kg_extractor], - embed_model=OpenAIEmbedding(model_name="text-embedding-3-small"), - property_graph_store=graph_store, - show_progress=True, -) ----- - -==== Property graph querying modules - -Labeled property graphs can be queried in several ways to retrieve nodes and paths. -And in LlamaIndex, you can combine several node retrieval methods at once! -Learn more about which ones are available in the https://docs.llamaindex.ai/en/latest/module_guides/indexing/lpg_index_guide/#retrieval-and-querying[documentation^]. - -You can also define a custom graph retriever as shown below. - -[source,python] ----- -from llama_index.core.retrievers import ( - CustomPGRetriever, - VectorContextRetriever, - TextToCypherRetriever, -) -from llama_index.core.query_engine import RetrieverQueryEngine -from llama_index.core.graph_stores import PropertyGraphStore -from llama_index.core.vector_stores.types import VectorStore -from llama_index.core.embeddings import BaseEmbedding -from llama_index.core.prompts import PromptTemplate -from llama_index.core.llms import LLM -from llama_index.postprocessor.cohere_rerank import CohereRerank - - -from typing import Optional, Any, Union - - -class MyCustomRetriever(CustomPGRetriever): - """Custom retriever with cohere reranking.""" - - def init( - self, - ## vector context retriever params - embed_model: Optional[BaseEmbedding] = None, - vector_store: Optional[VectorStore] = None, - similarity_top_k: int = 4, - path_depth: int = 1, - ## text-to-cypher params - llm: Optional[LLM] = None, - text_to_cypher_template: Optional[Union[PromptTemplate, str]] = None, - ## cohere reranker params - cohere_api_key: Optional[str] = None, - cohere_top_n: int = 2, - **kwargs: Any, - ) -> None: - """Uses any kwargs passed in from class constructor.""" - - self.vector_retriever = VectorContextRetriever( - self.graph_store, - include_text=self.include_text, - embed_model=embed_model, - vector_store=vector_store, - similarity_top_k=similarity_top_k, - path_depth=path_depth, - ) - - self.cypher_retriever = TextToCypherRetriever( - self.graph_store, - llm=llm, - text_to_cypher_template=text_to_cypher_template - ## NOTE: you can attach other parameters here if you'd like - ) - - self.reranker = CohereRerank( - api_key=cohere_api_key, top_n=cohere_top_n - ) - - def custom_retrieve(self, query_str: str) -> str: - """Define custom retriever with reranking. - - Could return `str`, `TextNode`, `NodeWithScore`, or a list of those. - """ - nodes_1 = self.vector_retriever.retrieve(query_str) - nodes_2 = self.cypher_retriever.retrieve(query_str) - reranked_nodes = self.reranker.postprocess_nodes( - nodes_1 + nodes_2, query_str=query_str - ) - - ## TMP: please change - final_text = "\n\n".join( - [n.get_content(metadata_mode="llm") for n in reranked_nodes] - ) - - return final_text - -custom_sub_retriever = MyCustomRetriever( - index.property_graph_store, - include_text=True, - vector_store=index.vector_store, - cohere_api_key="...", -) - -query_engine = RetrieverQueryEngine.from_args( - index.as_retriever(sub_retrievers=[custom_sub_retriever]), llm=llm -) - -response = query_engine.query("Did the author like programming?") -print(str(response)) ----- - -== Documentation - -* https://docs.llamaindex.ai/en/latest/module_guides/indexing/lpg_index_guide/[Property Graph Index^] -* https://docs.llamaindex.ai/en/stable/examples/property_graph/property_graph_custom_retriever/[Custom retriever example^] -* https://github.com/run-llama/llama_parse/blob/main/examples/knowledge_graphs/kg_agent.ipynb[Knowledge graph agent with LlamaParse^] -* https://docs.llamaindex.ai/en/stable/examples/vector_stores/Neo4jVectorDemo.html[Neo4jVectorDemo^] - -* https://llamahub.ai/l/readers/llama-index-readers-graphdb-cypher[Cypher Loader^] -* https://llamahub.ai/l/graph_stores/llama-index-graph-stores-neo4j[Neo4j Graph Store^] -* https://llamahub.ai/l/tools/llama-index-tools-neo4j[Neo4j Schema Query Builder^] - -=== Neo4j Query Engine Pack - -This https://llamahub.ai/l/tools/llama-index-tools-neo4j[Neo4j Query Engine LlamaPack^] creates a Neo4j query engine, and executes its query function. This pack offers the option of creating multiple types of query engines, namely: - -* Knowledge graph vector-based entity retrieval (default if no query engine type option is provided) -* Knowledge graph keyword-based entity retrieval -* Knowledge graph hybrid entity retrieval -* Raw vector index retrieval -* Custom combo query engine (vector similarity + KG entity retrieval) -* KnowledgeGraphQueryEngine -* KnowledgeGraphRAGRetriever - - -== Relevant Links -[cols="1,4"] -|=== -| icon:user[] Authors | https://github.com/tomasonjo[Tomaz Bratanic^], https://github.com/jexp[Michael Hunger^] -| icon:comments[] Community Support | https://community.neo4j.com/[Neo4j Online Community^] -| icon:github[] Repository | https://github.com/run-llama/llama-hub/tree/main/llama_hub/tools/neo4j_db[GitHub Neo4jDB^] https://github.com/run-llama/llama-hub/tree/main/llama_hub/llama_packs/neo4j_query_engine[GitHub Neo4j Llama Pack^] -| icon:book[] Documentation | https://docs.llamaindex.ai/en/stable/examples/index_structs/knowledge_graph/Neo4jKGIndexDemo.html -| icon:github[] Starter Kit | https://neo4j.com/labs/genai-ecosystem/llamaindex/[LlamaIndex Starter Kit^] -| icon:book[] Notebook | https://github.com/run-llama/llama-hub/blob/main/llama_hub/llama_packs/neo4j_query_engine/llama_packs_neo4j.ipynb[Llama Pack Notebook^] -|=== - -== Videos & Tutorials - - -* https://graphstuff.fm/episodes/llamaindex-and-more-building-llm-tech-with-jerry-liu[GraphStuff.fm Podcast: LlamaIndex and More: Building LLM Tech with Jerry Liu^] - -++++ - -++++ - -++++ - -++++ - -== Highlighted Articles - -* https://www.llamaindex.ai/blog/introducing-the-property-graph-index-a-powerful-new-way-to-build-knowledge-graphs-with-llms[Property graph index introduction^] - -* https://blog.llamaindex.ai/multimodal-rag-pipeline-with-llamaindex-and-neo4j-a2c542eb0206[Multimodal RAG Pipeline with LlamaIndex and Neo4j^] - -* https://blog.llamaindex.ai/enriching-llamaindex-models-from-graphql-and-graph-databases-bcaecec262d7[Enriching LlamaIndex Models from GraphQL and Graph Databases^] - -* https://levelup.gitconnected.com/a-simpler-way-to-query-neo4j-knowledge-graphs-99c0a8bbf1d7[A Simpler Way to Query Neo4j Knowledge Graphs^] - -* https://medium.com/@yu-joshua/using-llamaparse-for-knowledge-graph-creation-from-documents-3bd1e1849754[Using LlamaParse for Knowledge Graph Creation from Documents^] diff --git a/modules/genai-ecosystem/pages/llm-graph-builder-deployment.adoc b/modules/genai-ecosystem/pages/llm-graph-builder-deployment.adoc deleted file mode 100644 index a8eebed9..00000000 --- a/modules/genai-ecosystem/pages/llm-graph-builder-deployment.adoc +++ /dev/null @@ -1,216 +0,0 @@ -= Documentation for local deployments -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/ - -== Prerequisites - -You will need to have a Neo4j Database V5.18 or later with https://neo4j.com/docs/apoc/current/installation/[APOC installed^] to use this Knowledge Graph Builder. -You can use any https://neo4j.com/aura/[Neo4j Aura database^] (including the free tier database). Neo4j Aura automatically includes APOC and run on the latest Neo4j version, making it a great choice to get started quickly. - -You can also use the free trial in https://sandbox.neo4j.com[Neo4j Sandbox^], which also includes Graph Data Science. -If want to use https://neo4j.com/product/developer-tools/#desktop[Neo4j Desktop^] instead, you need to configure your `NEO4J_URI=bolt://host.docker.internal` to allow the Docker container to access the network running on your computer. - -== Docker-compose - -By default only OpenAI and Diffbot are enabled since Gemini requires extra GCP configurations. - -In your root folder, create a .env file with your OPENAI and DIFFBOT keys (if you want to use both): - -[source,env] ----- -OPENAI_API_KEY="your-openai-key" -DIFFBOT_API_KEY="your-diffbot-key" ----- - -if you only want OpenAI: - -[source,env] ----- -LLM_MODELS="gpt-3.5,gpt-4o" -OPENAI_API_KEY="your-openai-key" ----- - -if you only want Diffbot: - -[source,env] ----- -LLM_MODELS="diffbot" -DIFFBOT_API_KEY="your-diffbot-key" ----- - -You can then run Docker Compose to build and start all components: - -[source,bash] ----- -docker-compose up --build ----- - -=== Configuring LLM Models - -You can configure the following LLM models besides the ones supported out of the box: - -* OpenAI GPT 3.5 and 4o (default) -* VertexAI (Gemini 1.0) (default) -* VertexAI (Gemini 1.5) -* Diffbot -* Bedrock models -* Anthropic -* OpenAI API compatible models like Ollama, Groq, Fireworks - -To achieve that you need to set a number of environment variables: - -In your `.env` file, add the following lines. You can of course also add other model configurations from these providers or any OpenAI API compatible provider. - -[source,env] ----- -LLM_MODEL_CONFIG_azure_ai_gpt_35="gpt-35,https://.openai.azure.com/,," -LLM_MODEL_CONFIG_anthropic_claude_35_sonnet="claude-3-5-sonnet-20240620," -LLM_MODEL_CONFIG_fireworks_llama_v3_70b="accounts/fireworks/models/llama-v3-70b-instruct," -LLM_MODEL_CONFIG_bedrock_claude_35_sonnet="anthropic.claude-3-sonnet-20240229-v1:0,," -LLM_MODEL_CONFIG_ollama_llama3="llama3,http://host.docker.internal:11434" -LLM_MODEL_CONFIG_fireworks_qwen_72b="accounts/fireworks/models/qwen2-72b-instruct," - -# Optional Frontend config -LLM_MODELS="diffbot,gpt-3.5,gpt-4o,azure_ai_gpt_35,azure_ai_gpt_4o,groq_llama3_70b,anthropic_claude_35_sonnet,fireworks_llama_v3_70b,bedrock_claude_35_sonnet,ollama_llama3,fireworks_qwen_72b" ----- - -In your `docker-compose.yml` you need to pass the variables through: - -[source,yaml] ----- -- LLM_MODEL_CONFIG_anthropic_claude_35_sonnet=${LLM_MODEL_CONFIG_anthropic_claude_35_sonnet-} -- LLM_MODEL_CONFIG_fireworks_llama_v3_70b=${LLM_MODEL_CONFIG_fireworks_llama_v3_70b-} -- LLM_MODEL_CONFIG_azure_ai_gpt_4o=${LLM_MODEL_CONFIG_azure_ai_gpt_4o-} -- LLM_MODEL_CONFIG_azure_ai_gpt_35=${LLM_MODEL_CONFIG_azure_ai_gpt_35-} -- LLM_MODEL_CONFIG_groq_llama3_70b=${LLM_MODEL_CONFIG_groq_llama3_70b-} -- LLM_MODEL_CONFIG_bedrock_claude_3_5_sonnet=${LLM_MODEL_CONFIG_bedrock_claude_3_5_sonnet-} -- LLM_MODEL_CONFIG_fireworks_qwen_72b=${LLM_MODEL_CONFIG_fireworks_qwen_72b-} -- LLM_MODEL_CONFIG_ollama_llama3=${LLM_MODEL_CONFIG_ollama_llama3-} ----- - -=== Additional configs - -By default, the input sources will be: Local files, Youtube, Wikipedia and AWS S3. -This is the default config applied if you do not overwrite it in your .env file: - -[source,env] ----- -REACT_APP_SOURCES="local,youtube,wiki,s3" ----- - -If however you want the Google GCS integration, add `gcs` and your Google client ID: - -[source,env] ----- -REACT_APP_SOURCES="local,youtube,wiki,s3,gcs" -GOOGLE_CLIENT_ID="xxxx" ----- - -The `REACT_APP_SOURCES` should be a comma-separated list of the sources you want to enable. -You can of course combine all (local, youtube, wikipedia, s3 and gcs) or remove any you don't want or need. - -[#dev-deployment] -== Development (Separate Frontend and Backend) - -Alternatively, you can run the backend and frontend separately: - -- For the frontend: -1. Create the frontend/.env file by copy/pasting the frontend/example.env. -2. Change values as needed -3. Run: - -[source,bash] ----- -cd frontend -yarn -yarn run dev ----- - -- For the backend: -1. Create the backend/.env file by copy/pasting the backend/example.env. -2. Change values as needed -3. Run: - -[source,bash] ----- -cd backend -python -m venv envName -source envName/bin/activate -pip install -r requirements.txt -uvicorn score:app --reload ----- - -== ENV - -=== Processing Configuration - -[options="header",cols="m,a,m,a"] -|=== -| Env Variable Name | Mandatory/Optional | Default Value | Description -| IS_EMBEDDING | Optional | true | Flag to enable text embedding for chunks -| ENTITY_EMBEDDING | Optional | false | Flag to enable entity embedding (id and description) -| KNN_MIN_SCORE | Optional | 0.94 | Minimum score for KNN algorithm for connecting similar Chunks -| NUMBER_OF_CHUNKS_TO_COMBINE | Optional | 6 | Number of chunks to combine when extracting entities -| UPDATE_GRAPH_CHUNKS_PROCESSED | Optional | 20 | Number of chunks processed before writing to the database and updating progress -| ENV | Optional | DEV | Environment variable for the app -| TIME_PER_CHUNK | Optional | 4 | Time per chunk for processing -| CHUNK_SIZE | Optional | 5242880 | Size of each chunk for processing -|=== - -=== Front-End Configuration - -[options="header",cols="m,a,m,a"] -|=== -| Env Variable Name | Mandatory/Optional | Default Value | Description -| BACKEND_API_URL | Optional | http://localhost:8000 | URL for backend API -| REACT_APP_SOURCES | Optional | local,youtube,wiki,s3 | List of input sources that will be available -| BLOOM_URL | Optional | https://workspace-preview.neo4j.io/workspace/explore?connectURL=\{CONNECT_URL}&search=Show+me+a+graph | URL for Bloom visualization -|=== - - -=== GCP Cloud Integration - -[options="header",cols="m,a,m,a"] -|=== -| Env Variable Name | Mandatory/Optional | Default Value | Description -| GEMINI_ENABLED | Optional | False | Flag to enable Gemini -| GCP_LOG_METRICS_ENABLED | Optional | False | Flag to enable Google Cloud logs -| GOOGLE_CLIENT_ID | Optional | | Client ID for Google authentication for GCS upload -| GCS_FILE_CACHE | Optional | False | If set to True, will save the files to process into GCS. If set to False, will save the files locally -|=== - -=== LLM Model Configuration - -[options="header",cols="m,a,m,a"] -|=== -| Env Variable Name | Mandatory/Optional | Default Value | Description -| LLM_MODELS | Optional | diffbot,gpt-3.5,gpt-4o | Models available for selection on the frontend, used for entities extraction and Q&A Chatbot (other models: `gemini-1.0-pro, gemini-1.5-pro`) -| OPENAI_API_KEY | Optional | sk-... | API key for OpenAI (if enabled) -| DIFFBOT_API_KEY | Optional | | API key for Diffbot (if enabled) -| EMBEDDING_MODEL | Optional | all-MiniLM-L6-v2 | Model for generating the text embedding (all-MiniLM-L6-v2 , openai , vertexai) -| GROQ_API_KEY | Optional | | API key for Groq -| GEMINI_ENABLED | Optional | False | Flag to enable Gemini -| LLM_MODEL_CONFIG_=",,," | Optional | | Configuration for additional LLM models -|=== - - -=== LangChain and Neo4j Configuration - -[options="header",cols="m,a,m,a"] -|=== -| Env Variable Name | Mandatory/Optional | Default Value | Description -| NEO4J_URI | Optional | neo4j://database:7687 | URI for Neo4j database for the backend to connect to -| NEO4J_USERNAME | Optional | neo4j | Username for Neo4j database for the backend to connect to -| NEO4J_PASSWORD | Optional | password | Password for Neo4j database for the backend to connect to -| LANGCHAIN_API_KEY | Optional | | API key for LangSmith -| LANGCHAIN_PROJECT | Optional | | Project for LangSmith -| LANGCHAIN_TRACING_V2 | Optional | false | Flag to enable LangSmith tracing -| LANGCHAIN_ENDPOINT | Optional | https://api.smith.langchain.com | Endpoint for LangSmith API -|=== diff --git a/modules/genai-ecosystem/pages/llm-graph-builder-features.adoc b/modules/genai-ecosystem/pages/llm-graph-builder-features.adoc deleted file mode 100644 index 3ab41882..00000000 --- a/modules/genai-ecosystem/pages/llm-graph-builder-features.adoc +++ /dev/null @@ -1,152 +0,0 @@ -= Features documentation -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/ - -== Sources - -=== Local file upload - -You can drag & drop files into the first input zone on the left. The application will store the uploaded sources as Document nodes in the graph using LangChain Loaders (PDFLoader and Unstructured Loader). - -|=== -| File Type | Supported Extensions - -| Microsoft Office | .docx, .pptx, .xls -| PDF | .pdf -| Images | .jpeg, .jpg, .png, .svg -| Text | .html, .txt, .md -|=== - -=== Web Links - -The second input zone handles web links. - -* YouTube transcripts -* Wikipedia pages -* Web Pages - -The application will parse and store the uploaded YouTube videos (transcript) as a Document nodes in the graph using YouTube parsers. - -For Wikipedia links we use the Wikipedia Loader. For example, you can provide `https://en.wikipedia.org/wiki/Neo4j` and it will load the Neo4j Wikipedia page. - -For web pages, we use the Unstructured Loader. For example, you can provide articles from `https://theguardian.com/` and it will load the article content. - -== Cloud Storage - -=== AWS S3 - -This AWS S3 integration allows you to connect to an S3 bucket and load the files from there. You will need to provide your AWS credentials and the bucket name. - -=== Google Cloud Storage - -This Google Cloud Storage integration allows you to connect to a GCS bucket and load the files from there. You will have provide your GCS bucket name and optionally a folder an follow an auth flow to give the application access to the bucket. - -== LLM Models - -The application uses ML models to transform PDFs, web pages, and YouTube video transcripts into a knowledge graph of entities and their relationships. ENV variables can be set to configure/enable/disable specific models. - -The following models are configured (but only the first 3 are available in the publicly hosted version) - -* OpenAI GPT 3.5 and 4o -* VertexAI (Gemini 1.0), -* Diffbot -* Bedrock, -* Anthropic -* OpenAI API compatible models like Ollama, Groq, Fireworks - -The selected LLM model will both be used for processing the newly uploaded files and for powering the chatbot. Please note that the models have different capabilities, so they will work not equally well especially for extraction. - -== Graph Enhancements - -=== Graph Schema - -image::llm-graph-builder-taxonomy.png[width=600, align=center] - -If you want to use a pre-defined or your own graph schema, you can do so in the Graph Enhancements popup. This is also shown the first time you construct a graph and the state of the model configuration is listed below the connection information. - -You can either: -* select a pre-defined schema from the dropdown on top, -* use your own by entering the node labels and relationships, -* fetch the existing schema from an existing Neo4j database (`Use Existing Schema`), -* or copy/paste a text or schema description (also works with RDF ontologies or Cypher/GQL schema) and ask the LLM to analyze it and come up with a suggested schema (`Get Schema From Text`). - -=== Delete Disconnected Nodes - -When extracting entities, it can happen that after the extraction a number of nodes are only connected to text chunks but not to other entities. -Which results to disconnected entities in the entity graph. - -While they can hold relevant information for question answering they might affect your downstream usage. So in this view you can select which of the entities that are only connected to text chunks should be deleted. - -//// -=== Merging Duplicate Entities - -While the prompt instructs the LLM to extract unique identifier for entities, across chunks and documents the same entity can end up with different spellings as duplicate in the graph. - -Here we use a mixture of entity embedding, edit distance and substring containment to generate a list of potentially duplicate entities that can be merged. - -You can select which sets of entities should be merged and exclude certain entities from the merge. -//// - -== Visualization - -You can visualize the _lexical_, the _entity_ graph or the full _knowledge_ graph of your extracted documents. - -=== Graph Visualization - -You have 2 options - either per document with the magifying glass icon at the end of the table or for all selected documents with the "Preview Graph" button. - -The graph visualization will show for the relevant files in a pop-up and you can filter for the type of graph you wanto to see: - -- Lexical Graph - the document and chunk nodes and their relationships -- Entity Graph - the entity nodes and their relationships -- Full Graph - all nodes and relationships - -=== Explore in Neo4j Bloom - -With the button "Explore in Neo4j Bloom" you can open the constructed knowledge graph in Neo4j Workspace for further visual exploration, querying and analysis. - -In Bloom/Explore you can run low code pattern based queries (or use the co-pilot) to fetch data from the graph and succesfully expand. If you are running against a GDS enabled instance, you can also run graph algorithms and visualize the results. -You can also interactively edit and add to the graph. - -In Neo4j Data Importer you can additionally import structured data from CSV files and connect it to your extracted knowledge graph. - -In Neo4j Query you can write Cypher queries (or use the co-pilot) to pull tabular and graph data from your database. - -== Chatbot - -=== How it works - -When the user asks a question, we use the configured RAG mode to answer it with the data from the graph of extracted documents. That can mean the question is turned into an embedding or a graph query or a more advanced RAG approach. - -We also summarize the chat history and use it as an element to enrich the context. - -=== Features - -- *Select RAG Mode* you can select vector-only or GraphRAG (vector+graph) modes -- *Chat with selected documents:* Will use the selected documents only for RAG, uses pre-filtering to achieve that -- *Details:* Will open a Retrieval information pop-up showing details on how the RAG agent collected and used sources (documents), chunks, and entities. Also provides information on the model used and the token consumption. -- *Clear chat:* Will delete the current session's chat history. -- *Expand view:* Will open the chatbot interface in a fullscreen mode. -- *Copy:* Will copy the content of the response to the clipboard. -- *Text-To-Speech:* Will read out loud the content of the response. - -=== GraphRAG - -For GraphRAG we use the Neo4j Vector Index (and a fulltext index for hybrid search) with a Retrieval Query to find the most relevant chunks and entities connected to these and then follow the entity relationships up to a depth of 2 hops. - -=== Vectory Only RAG - -For Vector only RAG we only use the vector and fulltext index (hybrid) search results and don't include additional information from the entity graph. - -=== Answer Generation - -The various inputs and determined sources (the question, vector results, entities (name + description), relationship pairs, chat history) are all sent to the selected LLM model as context information in a custom prompt, asking to provide and format a response to the question asked based on the elements and context provided. - -Of course, there is more magic to the prompt such as formatting, asking to cite sources, not speculating if the answer is not known, etc. The full prompt and instructions can be found in the https://github.com/neo4j-labs/llm-graph-builder[GitHub repository^]. diff --git a/modules/genai-ecosystem/pages/llm-graph-builder.adoc b/modules/genai-ecosystem/pages/llm-graph-builder.adoc deleted file mode 100644 index 0a4cca36..00000000 --- a/modules/genai-ecosystem/pages/llm-graph-builder.adoc +++ /dev/null @@ -1,122 +0,0 @@ -= Neo4j LLM Knowledge Graph Builder - Extract Nodes and Relationships from Unstructured Text + -(PDF, Documents, 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] -image::https://dist.neo4j.com/wp-content/uploads/20240618104511/build-kg-genai-e1718732751482.png[width=800, align=center,link="https://llm-graph-builder.neo4jlabs.com/",window="_blank"] - -The Neo4j LLM Knowledge Graph Builder is an https://llm-graph-builder.neo4jlabs.com/[online application^] for turning unstructured text into a knowledge graph, it provides a magical text to graph experience. - -It uses ML models (LLM - OpenAI, Gemini, Llama3, Diffbot, Claude, Qwen) to transform PDFs, documents, images, web pages, and YouTube video transcripts. -The extraction turns them into a lexical graph of documents and chunks (with embeddings) and an entity graph with nodes and their relationships, which are both stored in your Neo4j database. -You can configure the extraction schema and apply clean-up operations after the extraction. - -Afterwards you can use different RAG approaches (GraphRAG, Vector, Text2Cypher) to ask questions of your data and see how the extracted data is used to construct the answers. - -[NOTE] -==== -* best results for files with long-form text in English -* less well suited for tabular data like Excel or CSV or images/diagrams/slides -* higher quality data extraction if you configure the graph schema for nodes and relationship types -==== - -The front-end is a React Application and the back-end a Python FastAPI application running on Google Cloud Run, but you can deploy it locally using docker compose. -It uses the https://python.langchain.com/docs/use_cases/graph/constructing[llm-graph-transformer module^] that Neo4j contributed to LangChain and other langchain integrations (e.g. for GraphRAG search). - -All Features are documented in detail here: xref::llm-graph-builder-features.adoc[] - -Here is a quick demo: - -++++ - -++++ - -== Step by Step Instructions - -1. Open the https://llm-graph-builder.neo4jlabs.com/[LLM-Knowledge Graph Builder^] -2. Connect to a https://console.neo4j.io[Neo4j (Aura)^] instance -3. Provide your PDFs, Documents, URLs or S3/GCS buckets -4. Construct Graph with the selected LLM -5. Visualize Knowledge Graph in App -6. Chat with your data using GraphRAG -7. Open Neo4j Bloom for further visual exploration -8. Use the constructed knowledge graph in your applications - -image::llm-graph-builder-viz.png[width=600, align=center] - -[NOTE] -==== -* Login, or create an account at https://console.neo4j.io -* Under Instances, create a new AuraDB Free Database -* Downloads the credentials file -* Wait until the instance is running -* Drop the credentials file on the connect dialog for the LLM Graph Builder -==== - -== 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 and relationships are stored in the graph and connected to the originating Chunks - -// TODO architecture diagram -image::https://dist.neo4j.com/wp-content/uploads/20240618104514/retrieval-information-e1718732797663.png[width=800, align=center] - -== Relevant Links -[cols="1,4"] -|=== -| Online Application | https://llm-graph-builder.neo4jlabs.com/ -| icon:user[] Authors | Michael Hunger, Tomaz Bratanic, Niels De Jong, Morgan Senechal, Persistent Team -| icon:comments[] Community Support | https://community.neo4j.com/c/neo4j-graph-platform/genai/214[Neo4j Online Community^] -| icon:github[] 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[] LangChain | https://python.langchain.com/v0.1/docs/use_cases/graph/constructing/[LangChain KG Construction Module^] -|=== - - -== Installation - -The https://llm-graph-builder.neo4jlabs.com[LLM Knowledge Graph Builder Application^] is available online. - -You can also run it locally, by cloning the https://github.com/neo4j-labs/llm-graph-builder[GitHub repository] and following the instructions in the README.md file. - -It is using Docker for packaging front-end and back-end, and you can run `docker-compose up` to start the whole application. - -Local deployment and configuration details are available in the xref::llm-graph-builder-deployment.adoc[] - - -== Videos & Tutorials - -image::https://cdn.graphacademy.neo4j.com/assets/img/courses/banners/llm-knowledge-graph-construction.png[width=800,link="https://graphacademy.neo4j.com/courses/llm-knowledge-graph-construction/"] - -=== Detailed Walk-Through - -++++ - -++++ - -=== Livestream LLM-Knowledge Graph Builder - -++++ - -++++ - -//// - -== Highlighted Articles - -// link:https://medium.com/neo4j/....[article^] -//// diff --git a/modules/genai-ecosystem/pages/microsoft-azure-demo.adoc b/modules/genai-ecosystem/pages/microsoft-azure-demo.adoc deleted file mode 100644 index 3f623806..00000000 --- a/modules/genai-ecosystem/pages/microsoft-azure-demo.adoc +++ /dev/null @@ -1,33 +0,0 @@ -= Microsoft Azure Demo -include::_graphacademy_llm.adoc[] -:slug: microsoft-azure-demo -:author: Ben Lackey -:category: genai-ecosystem -:tags: rag, demo, retrieval augmented generation, chatbot, edgar, sec filings, azure, openai -:neo4j-versions: 5.x -:page-pagination: -:page-product: microsoft-azure-demo - -This is a sample notebook and web application which shows how Azure OpenAI can be used with Neo4j. We will explore how to leverage Azure OpenAI LLMs to build and consume a knowledge graph in Neo4j. - -This notebook parses data from a public corpus of Medical Case Sheet using Azure OpenAI's gpt-4-32k model. The model is prompted to recognise and extract entities and relationships. - -We then use the gpt-4-32k model and prompt it to convert questions in English to Cypher - Neo4j's query language for data retrieval. - -== Installation - -The Demo is available on GitHub: https://github.com/neo4j-partners/neo4j-generative-ai-azure - -== Relevant Links -[cols="1,4"] -|=== -| icon:github[] Code Repository | https://github.com/neo4j-partners/neo4j-generative-ai-azure[GitHub] -| Demo Video | https://www.youtube.com/watch?v=3PO-erAP6R4&list=PLG3nTnYVz3nya8Me9-Xj9vEuLYIOk03ba[Link] -| Slides | https://docs.google.com/presentation/d/16KtVfpRoQWoUTY9UAK7fDBm-ZTCG7NrT0VCSa5brmLY/edit?usp=sharing[Link] -|=== - -== Videos & Tutorials - -++++ - -++++ diff --git a/modules/genai-ecosystem/pages/neoconverse.adoc b/modules/genai-ecosystem/pages/neoconverse.adoc deleted file mode 100644 index 58ebd265..00000000 --- a/modules/genai-ecosystem/pages/neoconverse.adoc +++ /dev/null @@ -1,164 +0,0 @@ -= NeoConverse - Graph Database Search with Natural Language -include::_graphacademy_llm.adoc[] -:slug: neoconverse -:author: Kumar SS, Eric Monk -:category: genai-ecosystem -:tags: -:neo4j-versions: 5.x -:page-pagination: -:page-product: neoconverse -:imagesdir: https://dev.assets.neo4j.com/wp-content/uploads/2024/ - -image::neoconverse-latest.gif[width=800, align=center] - -NeoConverse is an application to demonstrate natural language database search with GenAI. -It makes existing graph databases available to non-technical users, allowing them to issue natural language questions. -Using the graph database schema, question-statement examples, and fine-tuning, the natural language question is translated by an LLM to a graph query (Cypher). -Which is then validated and executed against the database. - -The query results are sent with the user question to the LLM to generate a natural language answer. -Alterantively the LLM can be configured to generate the data an configuration to render the results of the query as a chart for visual representation. - -image::neoconverse-chart.png[width=800, align=center] - -== Functionality Includes - -* Experiment with different cloud providers' GenAl models: Currently supported are GCP and OpenAI, with AWS Bedrock coming soon. -* Connect your own neo4j databases as agents in NeoConverse and interact with them in plain English: - - Configure schema information as context for the large language model (LLM). - - Optionally add a few-shot examples to provide in-context learning to the LLM. - - Save the conversation in a configured database for future analysis: - . Evaluate the LLM responses. - . Rank the responses and use them to improve future LLM interactions - . Prompt engineering adjustments. -* Generate chart visualizations from natural language questions. -* Interact with predefined agents from different domains: - - Chat with these agents. - - Explore the data model of the predefined agent datasets. - - Loaded with sample questions to get you started. - -=== Configuring Agents - -NeoConverse includes with selection of *predefined conversational agents*, each backed by Neo4J database, -To explore and converse with Neo4j database using these agents, user can select any agent from the `Explore Predefined Agent` section. -Upon selection, users can engage with the chosen agent through the chat interface displayed on the right side of the screen. -This enables users to interact directly with the database graoh, faciltating an interactive exploration of the knowledge graph. - -Users have the flexibility to `*add your own local agents*` that are backed by your organizations neo4j database, and start interacting with your database knowledge graphs. - -Below is the quick visual guide to `ADD`, `DELETE`, `EDIT` agents, and interact with your own database - -// image::add-agent[width=800, align=center] -// image::https://kumarss.blob.core.windows.net/neoconverse-resources/add-agent.gif?sp=r&st=2024-04-10T19:12:09Z&se=2026-04-11T03:12:09Z&spr=https&sv=2022-11-02&sr=b&sig=EYn4U%2B1AVCteCs1Va%2FxSAfDLPl%2FytHBjRZd%2Bji%2Bc058%3D[] -++++ - -++++ - -[WARNING] -==== -When integrating your own agents, be aware that these agents are stored in the client's browser storage and not on a server. This means that all interactions, including API calls and result processing, happen on the client side and do not reach our servers. Consequently, if the browser’s local storage is cleared for reasons such as browsing data cleanup, selection of "cookies and other site data", or when local storage capacity is exceeded, all custom agents will be permanently lost. -==== - -[IMPORTANT] -==== -We are considering future updates to enhance user experience. These updates may include capabilities for the export/import of agents and the persistence of user-defined agent configurations within the user’s own database. Such features aim to provide a more unified and simplified experience across different users and sessions. -==== - -=== Generating Chart Visualizations - -NeoConverse empowers users to create chart visualizations directly from the chat interface. By switching between the text input and a chart icon within the chat window, users can seamlessly transition their queries into visual representations. Here's how it works: Users pose their question in plain English, which is then transformed into a Cypher query for execution in the Neo4J database. Following this, the query results are passed to a Large Language Model (LLM), which generates chart metadata based on the data. The LLM intelligently selects the most appropriate chart type for the data at hand and returns the corresponding chart metadata. This metadata is then used to render the chart, enabling users to visualize and interpret the data insights more effectively and in an easily consumable manner. - -Looking ahead, NeoConverse is considering the expansion of its visualization capabilities to include graph visualizations. This development will be contingent upon the interest and feedback from NeoConverse users, potentially broadening the scope of interactive data exploration. -// TODO add a gif for chart generation - -== How NeoConverse Works: Overcoming LLM Limitations - -Large Language Models (LLMs) are trained on massive public datasets, making them adept at tasks based on that knowledge. However, their usefulness in enterprise settings is limited because: - -* Their knowledge is confined to the training data. -* Updating their knowledge with internal data can be challenging. -* Information may be outdated. - -*NeoConverse leverages Retrieval-Augmented Generation (RAG) to address these issues.* RAG provides LLMs with additional context retrieved from internal data sources hosted in Neo4j graph databases. - -Here's the step-by-step process of how NeoConverse works: - -1. *User Asks a Question:* The user asks a natural language question about their enterprise data stored in Neo4j. -2. *Context for LLM:* NeoConverse provides the LLM with context relevant to the question: - * Schema information about the data stored in the Neo4j database. - * A few relevant examples from the data to guide the LLM. -3. *LLM Generates Cypher Query:* Based on the question and context, the LLM generates a Cypher query, the query language for Neo4j. -4. *Query Refinement and Execution:* NeoConverse cleans, formats, and executes the Cypher query on the Neo4j database. -5. *Data Retrieval:* Relevant data is retrieved from the Neo4j database based on the executed query. -6. *LLM Answer Generation:* Finally, the LLM uses the retrieved data and the original question to generate an accurate and relevant answer that's grounded in the user's specific data. - -By leveraging internal data, NeoConverse empowers LLMs to provide more accurate and relevant answers to user queries within an enterprise setting. - -image::neoconverse-arch.png[width=600, align=center] -// image::https://kumarss.blob.core.windows.net/neoconverse-resources/neoconverse-arch.png?sp=r&st=2024-04-10T19:08:45Z&se=2026-04-09T03:08:45Z&spr=https&sv=2022-11-02&sr=b&sig=vE8JahnRHRgNO8xEZzQejX0ACMQdQ9kr6FzeIKs0ILw%3D[] - -== Available predefined datasets -* *Enron Email Corpus Dataset*: The subset of publicly available enron email corpus data has been anonymized and ingested in neo4j database, the ingested dataset contains about 500K email messages, The dataset facilitates an in-depth exploration of email communication both within enron leadership internally and with external parties, providing means to analyse anomolies and email leakages. In addition to email communcation metadata, this dataset also enriched with entities and watch terms extracted from email subject & body. -* *Patient Journey Dataset* : The patient journey dataset encapsulates the healthcare experiences of 1 million patients, detailing 41 million encounters that span doctor visits, diagnoses, treatments, and allergies, among other medical events. With 11 million prescriptions, 26 million observations, 9 million condition-specific observations, 200 unique conditions, and 500K allergy encounters, this rich dataset offers a comprehensive view of individual health narratives. It's a crucial resource for analyzing treatment patterns, patient outcomes, and drug efficacy, providing insights that can enhance healthcare delivery and personalize patient care strategies. -* *Retail Dataset* : This retail dataset leverages a knowledge graph built from a public Amazon electronics dataset containing product information, reviews, and user purchase and review history. To extract deeper insights, Neo4j GDS graph algorithms have been applied to calculate similarity scores between users and products, considering not only product features and user demographics but also how users interact with the products. -* *Business Intelligence*: Its a Knowledge graph of Software Applications with supported business processes, deployed instances, software vulnerability reports, -and data concepts that provides impact analysis for vulnerabilities as well as impact analysis for application changes and data traceability -// TODO Add details on Business resilience and retail dataset - -== Enhancing NeoConverse - -NeoConverse relies on Large Language Models (LLMs) cypher generation capabilities, while LLMs have shown improvements in generating Cypher queries, yet inconsistencies persist. NeoConverse is designed to identify these inconsistencies, providing users with effective ways to navigate or bypass them, rather than confronting them with raw errors. This approach ensures a smoother user experience. - -In future NeoConverse can be enhanced to mitigate these inconsistencies by: - -- *Fine-Tuning LLMs*: Finetune LLMs for cypher generation for more accurate and consistent Cypher queries. -- *Developing a Semantic Layer*: To deepen LLMs' contextual understanding, improving result accuracy. -- *Incorporating Domain-Specific Nomenclature*: To increase the relevance and precision of queries. -- *Leveraging Historical Conversations*: Using past interactions to provide richer context and more relevant examples to LLMs. - -These initiatives aim to address current challenges and improve the reliability of LLM-generated Cypher queries in NeoConverse. - - -== Relevant Links -[cols="1,4"] -|=== -| Online | https://neoconverse.graphapp.io/ -| icon:user[] Authors | Kumar SS, Eric Monk -| 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/neoconverse[GitHub^] -| icon:github[] Issues | https://github.com/neo4j-labs/neoconverse/issues[GitHub Issues^] -// | icon:book[] Documentation | -|=== - - -== Installation - -The Demo is available online, https://neoconverse.graphapp.io - -You can also run it locally, by cloning the https://github.com/neo4j-labs/neoconverse[repository] and following the instructions in the README.md file. - -== Highlighted Articles - -* link:https://medium.com/@kumarss20/from-code-to-conversation-unleashing-the-potential-of-neo4j-with-llm-powered-conversational-0fd243337e9d[From code to conversation^] -* link:https://medium.com/@kumarss20/text-to-chart-generation-e654720b15a0[Text to chart generation^] - - -// == Videos & Tutorials - -// TODO Dan Bukowski workshops and articles - -// image::https://cdn.graphacademy.neo4j.com/assets/img/courses/banners/llm-knowledge-graph-construction.png[width=800,link="https://graphacademy.neo4j.com/courses/llm-knowledge-graph-construction/"] - - -//// -++++ - -++++ -//// - -//// - -== Highlighted Articles - -// link:https://medium.com/neo4j/....[article^] -//// diff --git a/modules/genai-ecosystem/pages/rag-demo.adoc b/modules/genai-ecosystem/pages/rag-demo.adoc deleted file mode 100644 index 2388b42b..00000000 --- a/modules/genai-ecosystem/pages/rag-demo.adoc +++ /dev/null @@ -1,52 +0,0 @@ -= RAG (Retrieval Augmented Generation) Demo -include::_graphacademy_llm.adoc[] -:slug: rag-demo -:author: Andreas Kolleger, Jennifer Reif, Jason Koo, Alison Cosette -:category: genai-ecosystem -:tags: rag, demo, retrieval augmented generation, chatbot, edgar, sec filings -:neo4j-versions: 5.x -:page-pagination: -:page-product: rag-demo - -image::https://res.cloudinary.com/dk0tizgdn/image/upload/v1707842287/rag-demo-short_vwezew.gif[width=600, align=center] - - -The RAG Demo uses a knowledge graph of the SEC filings with additional company information with the Neo4j vector index and LangChain to provide a retrieval augmented generation (RAG) chatbot. - -The chatbot can answer questions about the SEC filings and provide additional information about the companies. - - -== Installation - -The Demo is available online under: https://dev.neo4j.com/rag-demo - -//// -== Functionality Includes - -== Documentation -//// - -== Relevant Links -[cols="1,4"] -|=== -| icon:user[] Authors | https://github.com/jmhreif[Jennifer Reif^], https://github.com/akollegger[Andreas Kollegger^] https://github.com/jalakoo/[Jason Koo^], https://github.com/alisoncossette[Alison Cosette^] -| icon:comments[] Community Support | https://community.neo4j.com/[Neo4j Online Community^] -| icon:github[] Code Repository | https://github.com/neo4j-examples/rag-demo[GitHub] -| icon:github[] Data Preparation Repository | https://github.com/neo4j-product-examples/data-prep-sec-edgar/[GitHub] -| icon:github[] Issues | https://github.com/neo4j-product-examples/data-prep-sec-edgar/issues -// | icon:book[] Documentation | -|=== - -//// - -== Videos & Tutorials - -Installation: -++++ - -++++ - -== Highlighted Articles - -// link:https://medium.com/neo4j/....[article^] -//// diff --git a/modules/genai-ecosystem/pages/semantic-kernel.adoc b/modules/genai-ecosystem/pages/semantic-kernel.adoc deleted file mode 100644 index 0ffeb199..00000000 --- a/modules/genai-ecosystem/pages/semantic-kernel.adoc +++ /dev/null @@ -1,86 +0,0 @@ -= Semantic Kernel Neo4j Integration (preview) -:slug: semantic-kernel -:author: -:category: genai-ecosystem -:tags: semantic-kernel, integration, llm, neo4j, vector index -:neo4j-versions: 5.x -:page-pagination: -:page-product: semantic-kernel - - -An integration of Neo4j graph database with Microsoft's https://github.com/microsoft/semantic-kernel[Semantic Kernel^], -through Microsoft https://microsoft.github.io/kernel-memory/[Kernel Memory^]. Neo4j's vector search index is used for storing document embeddings and dense retrievals. - -The library allows using Neo4j as an IMemoryDb. It provides a simple way to store and retrieve data from Neo4j. - -== Installation - -Hello world example: - -[source,csharp] ----- -# dotnet add package Neo4j.KernelMemory.Core -# dotnet add package Neo4j.Driver - -using Microsoft.KernelMemory; -using Neo4j.KernelMemory.MemoryStorage; -using Neo4j.Driver; - -var env = System.Environment.GetEnvironmentVariables(); - -var neo4jConfig = new Neo4jConfig -{ - Uri = env["NEO4J_URI"], - Username = env["NEO4J_USERNAME"], - Password = env["NEO4J_PASSWORD"] -}; - -var kernelMemory = new KernelMemoryBuilder() - .WithOpenAIDefaults(env["OPENAI_API_KEY"]) - .WithNeo4j(neo4jConfig) - .Build(); - -// First, provide some text to the Kernel Memory, which will be indexed and stored in Neo4j -await kernelMemory.ImportTextAsync(""" -The "Hello, World!" program, often attributed to Brian Kernighan's work in the 1970s, serves as the quintessential introduction to programming languages, demonstrating basic syntax with a simple output function. Originating as a test phrase in Bell Laboratories for the B programming language, it has evolved into a universal starter program for beginners in coding, symbolizing the initiation into software development. Its simplicity makes it an ideal tool for education and system testing, illustrating the minimal requirements to execute a program across various computing environments. As a cultural staple in the tech community, "Hello, World!" represents both a rite of passage for new programmers and the universal joy of creating with code. This tradition showcases the evolution of programming languages and the shared beginnings of developers worldwide. -""", - documentId: "HelloWorld"); - -// Now ask a question -var question = "Who wrote the first Hello World?"; - -var answer = await kernelMemory.AskAsync(question); - -Console.WriteLine($"Question: {question}\n\nAnswer: {answer.Result}"); - ----- - -== Functionality Includes - -* `Neo4jMemory` - implementation of `IMemoryDb`. -* `WithNeo4j` - extension to the KernelMemoryBuilder. -* Integation with Semantic Kernel -* Develop in serverless, deploy as server - -== Relevant Links -[cols="1,4"] -|=== -| icon:user[] Authors | https://github.com/akollegger[Andreas Kollegger^] -| icon:comments[] Community Support | https://community.neo4j.com/[Neo4j Online Community^] -| icon:github[] Integration | https://github.com/neo4j-labs/Neo4j.KernelMemory.MemoryStorage[GitHub] -| icon:github[] Issues | https://github.com/neo4j-labs/Neo4j.KernelMemory.MemoryStorage/issues -| icon:book[] Documentation | https://github.com/neo4j-labs/Neo4j.KernelMemory.MemoryStorage -| icon:github[] Starter Kit | https://github.com/neo4j-examples/semantic-kernel-starter-kit[Sematic Kernel Starter Kit] -| icon:github[] Examples | https://github.com/neo4j-labs/Neo4j.KernelMemory.MemoryStorage/tree/main/examples[GithHub] -|=== - - -== Videos & Tutorials - - - -//// -== Highlighted Articles - -// link:https://medium.com/neo4j/....[article^] -//// diff --git a/modules/genai-ecosystem/pages/spring-ai.adoc b/modules/genai-ecosystem/pages/spring-ai.adoc deleted file mode 100644 index bab3607f..00000000 --- a/modules/genai-ecosystem/pages/spring-ai.adoc +++ /dev/null @@ -1,80 +0,0 @@ -= Spring AI -:slug: spring-ai -:author: Gerrit Meier, Michael Simons, Jennifer Reif -:category: labs -:tags: spring, neo4j, vector index, vector search -:neo4j-versions: 5.x -:page-pagination: -:page-product: spring-ai - -// image::todo.png[width=800] - -The https://docs.spring.io/spring-ai/reference/index.html[Spring AI^] project aims to be something like LangChain for the Java world. - -Combining Spring AI with Spring Data Neo4j makes it possible to build on existing domain models, turn them into a graph, and enrich them with vector embeddings. - -== Installation - -If you are using the https://start.spring.io/[Spring Initializr^], you can add the Spring AI model of your choosing and `Neo4j Vector Database` as dependencies to your project, and it will pull in all the related pieces. - -If you add the dependencies manually, Spring AI is not yet a general release library, so you will need to add the dependencies, as well as the snapshot and milestone repositories to your `pom.xml` file, as outlined in the https://docs.spring.io/spring-ai/reference/getting-started.html#repositories[Getting Started documentation^]. - -The next piece you will need to add is the configuration for the Neo4j Vector Database, which also needs to be accompanied by custom driver and embedding client configuration. Probably the simplest approach is to create Spring Beans for each of these components in the main application class. This is mentioned in the https://docs.spring.io/spring-ai/reference/api/vectordbs/neo4j.html#_auto_configuration[documentation^], but the full code is not provided. An example of how to configure the Neo4j Vector Database is shown below (note that you will need to alter the `vectorStore` bean to match your specific configuration): - -[source,java,tabsize=2] ----- -include::https://github.com/neo4j-examples/spring-ai-starter-kit/raw/main/src/main/java/com/neo4j/springaistarterkit/SpringAiStarterKitApplication.java[lines=21..42,indent=0] ----- - -Now that we have the vector store configured, we can use Spring AI for retrieval augmented generation (RAG) via a three-step process. - -1. Call the vector similarity search method to retrieve the most similar documents. -2. Use the similar documents as input to a retrieval query that pulls related entities from the graph. -3. Provide the similar documents (with their related graph entities) as input to a prompt that the LLM will use to generate a response. - -The code snippet below demonstrates how to use Spring AI for RAG with Neo4j Vector Store: - -[source,java,tabsize=2] ----- -include::https://github.com/neo4j-examples/spring-ai-starter-kit/raw/main/src/main/java/com/neo4j/springaistarterkit/DocumentController.java[lines=30..57,indent=0] ----- - -== Functionality Includes - -* Create vector index -* Populate nodes and vector index from documents -* Query vector index - -== Documentation - -The Neo4j Vector integration documentation is avalable in the https://docs.spring.io/spring-ai/reference/api/vectordbs/neo4j.html[Spring AI Reference Guide^]. - -== Starter Kit - -Getting started in any new technology space can feel intimidating. Neo4j has been working on some pre-packaged solutions for GenAI and Neo4j to hopefully make the process easier by providing starter kit projects with a few key technologies, including Spring AI. You can find the https://github.com/neo4j-examples/spring-ai-starter-kit/[Spring AI starter kit code^] on Github, as well as a [https://neo4j.com/developer-blog/genai-starter-kit-spring-java/[blog post with more information^]. - -== Relevant Links -[cols="1,4"] -|=== -| icon:user[] Authors | https://github.com/meistermeier[Gerrit Meier^], https://github.com/rotnroll666[Michael Simons^], https://github.com/JMHReif[Jennifer Reif^] -| icon:comments[] Community Support | https://community.neo4j.com/[Neo4j Online Community^] -| icon:github[] Data Repository | https://github.com/spring-projects/spring-ai[GitHub] -| icon:github[] Issues | https://github.com/spring-projects/spring-ai/issues -| icon:book[] Documentation | https://docs.spring.io/spring-ai/reference/api/vectordbs/neo4j.html -| icon:github[] Starter Kit | https://github.com/neo4j-examples/spring-ai-starter-kit/[Spring AI Starter Kit^] -|=== - -//// - -== Videos & Tutorials - -Installation: -++++ - -++++ - -//// - -== Highlighted Articles - -* https://meistermeier.com/2024/02/23/spring-ai-neo4j.html[Spring AI with Neo4j Vector Index (Gerrit Meier)^] diff --git a/modules/genai-ecosystem/pages/vector-search.adoc b/modules/genai-ecosystem/pages/vector-search.adoc index c5007e19..bdd2eb60 100644 --- a/modules/genai-ecosystem/pages/vector-search.adoc +++ b/modules/genai-ecosystem/pages/vector-search.adoc @@ -1,5 +1,6 @@ = Neo4j Vector Index and Search include::_graphacademy_llm.adoc[] +include::_developer_survey.adoc[] :slug: vector-search :author: :category: genai-ecosystem @@ -8,6 +9,7 @@ include::_graphacademy_llm.adoc[] :page-pagination: :page-product: neo4j + image::https://dist.neo4j.com/wp-content/uploads/20230821135317/Grounding-LLM-Responses-with-Implicit-and-Explicit-Search-Through-Neo4js-Knowledge-Graph-2048x1152.png[width=800] The Neo4j Vector index implements HNSW (Hierarchical Navigatable Small World) for creating layers of k-nearest neighbors to enable efficient and robust approximate nearest neighbor search.