Cypher few-shot 프롬프트 만들기
생성되는 Cypher의 신뢰성을 높이기 위해 마지막으로 활용할 기법은 바로 few-shot 프롬프트입니다. Few-shot 프롬프트는 많은 예시 데이터로 모델을 미세 조정하지 않아도, 원하는 출력 방향으로 모델을 유도하는 훌륭한 방법이에요.
이 사용 사례에 맞게 준비된 예시 세트는 examples로 제공됩니다. 셸에서 출력해 내용을 확인해 보셔도 좋아요. 이제 이를 활용해 Cypher 생성 과정에 사용할 few-shot 프롬프트를 만드시게 됩니다. 앞에서 생성한 그래프는 graph로 계속 사용할 수 있어요.
이 연습은 강의의 일부입니다
LangChain을 활용한 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=["____"]
)