知识图谱操作(四)Neo4j-基于节点和节点集构建知识地图(关键子图)

制作Prompt模板

def create_prompt_template(retrieved_docs, query):
    context = "\n".join([f"Document {i+1}:\n{doc}" for i, doc in enumerate(retrieved_docs)])
    prompt = f"Context:\n{context}\n\nQuery: {query}\n\nAnswer:"
    return prompt

# 创建Prompt Template
prompt_template = create_prompt_template(retrieved_docs, query)
print("Prompt Template:\n", prompt_template)
将知识嵌入模型Prompt中

检索到的文档内容:

  • Document 1: "Paris is the capital and most populous city of France."
  • Document 2: "France, officially the French Republic, is a country primarily located in Western Europe."
  • Document 3: "The capital city of France is Paris, which is known for its art, fashion, and culture."

模型Prompt模板:

You should answer the Query by these contexts

Context:通过用户输入在向量库中检索到的相关文档

Que

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值