知识卡片
回答界面要处理空结果与来源
界面显示问题、答案和对应上下文,帮助用户检查依据。代码不能无条件取answers[0],应处理空候选、无答案和模型失败;保留原问题与规范化后的检索输入,也有助解释预处理造成的差异。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- · 查看原书依据
Finally, you can prepare your app to answer questions! Let’s make it return the context of the answer too, not just the answer itself: >>> if question: ... res = pipe.run(query=question, params={ "Reader": {"top_k": 1}, "Retriever": {"top_k": 10}}) ... st.write(f"Answer: {res['answers'][0].answer}") ... st.write(f"Context: {res['answers'][0].context}") And your QA app is ready! Let’s give it a try. When you ask your retrieval-augmented LLM the question, “Who invented
参考来源
- 位置:《Natural Language Processing in Action, Second Edition》第10章《真实世界中的大语言模型》(来源项目:a19c7933-4eda-4176-aebd-30fe7e1ad292;源文件:extracted/Natural Language Processing in Action, Second Edition/_epub-src/OEBPS/Text/chapter-10.html)
- 结论依据:摘录中关于回答界面要处理空结果与来源的定义、比较或条件支撑卡片;原书表述不严谨的范围已在覆盖记录逐项限定,不把案例结果外推为普遍结论。
- 原始内容:Finally, you can prepare your app to answer questions! Let’s make it return the context of the answer too, not just the answer itself: >>> if question: ... res = pipe.run(query=question, params={ "Reader": {"top_k": 1}, "Retriever": {"top_k": 10}}) ... st.write(f"Answer: {res['answers'][0].answer}") ... st.write(f"Context: {res['answers'][0].context}") And your QA app is ready! Let’s give it a try. When you ask your retrieval-augmented LLM the question, “Who invented