ComenzarEmpieza gratis

Creating a Cypher few-shot prompt

The final technique you'll utilize to improve the reliability of the generated Cypher is providing a few-shot prompt. Few-shot prompts are a great way of steering a model toward a desired output without needing to fine-tune it on a large dataset of examples.

A set of examples tailored to this particular use case is available as examples; feel free to print it in the shell to view its contents. You'll use these to create a few-shot prompt for the Cypher generation process. The graph you created before is still available as graph.

Este ejercicio forma parte del curso

Retrieval Augmented Generation (RAG) with LangChain

Ver curso

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# Create an example prompt template
example_prompt = ____(
    "User input: {question}\nCypher query: {query}"
)

# Create the few-shot prompt template
cypher_prompt = ____(
    examples=____,
    example_prompt=____,
    prefix="You are a Neo4j expert. Given an input question, create a syntactically correct Cypher query to run.\n\nHere is the schema information\n{schema}.\n\nBelow are a number of examples of questions and their corresponding Cypher queries.",
    suffix="User input: {question}\nCypher query: ",
    input_variables=["____"]
)
Editar y ejecutar código