跳到主要内容

使用LLMs回答开放域问题

背景

以下提示测试LLM回答开放域问题的能力,这涉及在没有提供任何证据的情况下回答事实性问题。

注意

注意,由于任务的挑战性,当LLM对问题没有相关知识时,可能会产生幻觉。

提示

在这段人类与AI的对话中,AI是乐于助人且友好的,当它不知道答案时会说"我不知道"。

AI: 你好,有什么我可以帮忙的吗?
Human: 我能在SeaTac机场买到麦当劳吗?

代码 / 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
)

参考