【LangChain】调试Chain(Debugging chains)

28 篇文章 12 订阅

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

参考地址:

Debugging chains

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

山鬼谣me

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值