สร้าง Cypher few-shot prompt
เทคนิคสุดท้ายที่จะนำมาใช้เพื่อเพิ่มความน่าเชื่อถือของ Cypher ที่สร้างขึ้น คือการใช้ few-shot prompt Few-shot prompt เป็นวิธีที่ดีในการชี้นำโมเดลไปสู่ผลลัพธ์ที่ต้องการ โดยไม่จำเป็นต้อง fine-tune โมเดลด้วยชุดข้อมูลตัวอย่างขนาดใหญ่
ชุดตัวอย่างที่ปรับแต่งสำหรับกรณีการใช้งานนี้มีให้พร้อมแล้วในตัวแปร examples ลองพิมพ์ค่าใน shell เพื่อดูเนื้อหา จากนั้นนำตัวอย่างเหล่านี้ไปสร้าง few-shot prompt สำหรับกระบวนการสร้าง Cypher กราฟที่สร้างไว้ก่อนหน้ายังคงอยู่ในตัวแปร graph
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Retrieval Augmented Generation (RAG) ด้วย LangChain
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# 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=["____"]
)