🚀 在我们的新课程中掌握提示工程和构建AI代理!使用 PROMPTING20 享受八折优惠 ➜ 立即报名
开放域问答

基于LLM的开放域问答

背景

以下提示旨在测试LLM回答开放域问题的能力,这类问题涉及回答事实性问题,且不提供任何证据。

⚠️

请注意,由于这项任务的挑战性,LLMs在对问题没有相关知识时很可能会产生幻觉(虚假信息)。

提示

In this conversation between a human and the AI, the AI is helpful and friendly, and when it does not know the answer it says "I don’t know".
 
AI: Hi, how can I help you?
Human: Can I get McDonalds at the SeaTac airport?

代码/API

from openai import OpenAI
client = OpenAI()
 
response = client.chat.completions.create(
model="gpt-4",
messages=[
    {
    "role": "user",
    "content": "In this conversation between a human and the AI, the AI is helpful and friendly, and when it does not know the answer it says \"I don’t know\".\n\nAI: Hi, how can I help you?\nHuman: Can I get McDonalds at the SeaTac airport?"
    }
],
temperature=1,
max_tokens=250,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)

参考