DSPy Neo4j Integration

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 DSPy Integrations.

Installation

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.

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")