ComeçarComece de graça

Creating a vector index

The 'text' properties on our Line nodes are perfect for generating embeddings that answer open-ended questions about the play.

Use the vector store provided by langchain-neo4j to create a vector index by embedding the 'text' property of the Line nodes.

Este exercício faz parte do curso

Graph RAG with LangChain and Neo4j

Ver curso

Instruções do exercício

  • Use the correct class to create a vector index from an existing graph of nodes and relationships.
  • Instruct the class to store the embeddings in the 'embedding' node property.
  • Instruct the class to create embeddings in the 'text' node property.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

from langchain_neo4j import Neo4jVector

# Create a vector store from the existing graph
line_retriever = ____.from_existing_graph(
    embedding=embeddings,
    url=NEO4J_URL, username=NEO4J_USERNAME, password=NEO4J_PASSWORD,
    index_name="lines_index",
    node_label="Line",
    # Set the embedding and text node properties
    ____="embedding",
    ____=["text"],
)

results = line_retriever.similarity_search_with_score("Biting a finger", k=3)

for result in results:
    print(result[0].page_content)
Editar e executar o código