LangChain学习文档
概述
就是打印更详细的Chain信息(如:内部信息),以知道它是如何工作的。
仅从 Chain
对象的输出中调试 Chain
对象可能很困难,因为大多数 Chain
对象都涉及大量的输入提示预处理和 LLM
输出后处理。
将 verbose
设置为 True
将在运行时打印 Chain
对象的一些内部状态。
conversation = ConversationChain(
llm=chat,
memory=ConversationBufferMemory(),
verbose=True
)
conversation.run("What is ChatGPT?")
结果:
> Entering new ConversationChain chain...
Prompt after formatting:
The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.
Current conversation:
Human: What is ChatGPT?
AI:
> Finished chain.
'ChatGPT is an AI language model developed by OpenAI. It is based on the GPT-3 architecture and is capable of generating human-like responses to text prompts. ChatGPT has been trained on a massive amount of text data and can understand and respond to a wide range of topics. It is often used for chatbots, virtual assistants, and other conversational AI applications.'
进入新的 ConversationChain 链...
格式化后提示:
以下是一段人类与人工智能之间的友好对话。人工智能很健谈,并根据上下文提供了许多具体细节。如果人工智能不知道问题的答案,它就会如实说它不知道。
当前对话:
人类:ChatGPT 是什么?
人工智能:
> 结束 chain。
'ChatGPT是OpenAI开发的AI语言模型。它基于 GPT-3 架构,能够对文本提示生成类似人类的响应。 ChatGPT 经过大量文本数据的训练,可以理解并响应广泛的主题。它通常用于聊天机器人、虚拟助理和其他对话式人工智能应用程序。
总结
当我们想查看chain内部是如何工作的,可以使用:verbose=True
。
参考地址: