Cypher के लिए few-shot प्रॉम्प्ट बनाना
जनरेट हुए Cypher की विश्वसनीयता बढ़ाने के लिए आप जो अंतिम तकनीक इस्तेमाल करेंगे, वह है एक few-shot प्रॉम्प्ट देना। Few-shot प्रॉम्प्ट किसी बड़े उदाहरण-डेटासेट पर फाइन-ट्यून किए बिना ही मॉडल को वांछित आउटपुट की दिशा में ले जाने का बेहतरीन तरीका है।
इस विशेष उपयोग-केस के लिए बनाए गए उदाहरणों का एक सेट examples के रूप में उपलब्ध है; इसकी सामग्री देखने के लिए आप चाहें तो शेल में इसे प्रिंट कर सकते हैं। इन्हीं का उपयोग करके आप Cypher जनरेशन प्रक्रिया के लिए few-shot प्रॉम्प्ट बनाएँगे। आपने पहले जो ग्राफ बनाया था, वह graph के रूप में अब भी उपलब्ध है।
यह अभ्यास पाठ्यक्रम का हिस्सा है
LangChain के साथ Retrieval Augmented Generation (RAG)
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# 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=["____"]
)