From 0b119e5c89d2685d8d8eee770ae706f858731a1d Mon Sep 17 00:00:00 2001 From: Tomaz Bratanic Date: Sat, 6 Apr 2024 21:14:42 +0200 Subject: [PATCH] Add dspy integration (#72) * Add dspy integration * fix tags --- modules/genai-ecosystem/pages/dspy.adoc | 46 ++++++++++++++++++++++++ modules/genai-ecosystem/pages/index.adoc | 2 ++ 2 files changed, 48 insertions(+) create mode 100644 modules/genai-ecosystem/pages/dspy.adoc diff --git a/modules/genai-ecosystem/pages/dspy.adoc b/modules/genai-ecosystem/pages/dspy.adoc new file mode 100644 index 0000000..0108920 --- /dev/null +++ b/modules/genai-ecosystem/pages/dspy.adoc @@ -0,0 +1,46 @@ += 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/index.adoc b/modules/genai-ecosystem/pages/index.adoc index a093262..85ea819 100644 --- a/modules/genai-ecosystem/pages/index.adoc +++ b/modules/genai-ecosystem/pages/index.adoc @@ -54,6 +54,8 @@ image::https://cdn.graphacademy.neo4j.com/assets/img/courses/banners/llm-fundame * xref:langchain4j.adoc[LangChain4j] * xref:haystack.adoc[Haystack] * xref:semantic-kernel.adoc[Semantic Kernel] +* xref:dspy.adoc[DSPy] + == Highlighted Articles