使用LLMs回答封闭域问题
背景
以下提示测试LLM回答封闭域问题的能 力,这涉及回答属于特定主题或领域的问题。
注意
注意,由于任务的挑战性,当LLM对问题没有相关知识时,可能会产生幻觉。
提示
患者情况:
- 20岁女性
- 有厌食症和抑郁症史
- 血压100/50,脉搏50,身高5'5''
- 由营养师推荐,但她否认自己有病
- 报告饮食正常,但体重严重偏低
请将上述数据重新写成医疗记录,仅使用上述信息。
代码 / API
- GPT-4 (OpenAI)
- Mixtral MoE 8x7B Instruct (Fireworks)
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-4",
messages=[
{
"role": "user",
"content": "Patient’s facts:\n- 20 year old female\n- with a history of anerxia nervosa and depression\n- blood pressure 100/50, pulse 50, height 5’5’’\n- referred by her nutrionist but is in denial of her illness\n- reports eating fine but is severely underweight\n\nPlease rewrite the data above into a medical note, using exclusively the information above."
}
],
temperature=1,
max_tokens=500,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
import fireworks.client
fireworks.client.api_key = "<FIREWORKS_API_KEY>"
completion = fireworks.client.ChatCompletion.create(
model="accounts/fireworks/models/mixtral-8x7b-instruct",
messages=[
{
"role": "user",
"content": "Patient’s facts:\n- 20 year old female\n- with a history of anerxia nervosa and depression\n- blood pressure 100/50, pulse 50, height 5’5’’\n- referred by her nutrionist but is in denial of her illness\n- reports eating fine but is severely underweight\n\nPlease rewrite the data above into a medical note, using exclusively the information above.",
}
],
stop=["<|im_start|>","<|im_end|>","<|endoftext|>"],
stream=True,
n=1,
top_p=1,
top_k=40,
presence_penalty=0,
frequency_penalty=0,
prompt_truncate_len=1024,
context_length_exceeded_behavior="truncate",
temperature=0.9,
max_tokens=4000
)
参考
- 人工通用智能的火花:GPT-4的早期实验 (2023年4月13日)