如何检索LangChain中ChatGPT使用的输入文档列表?

huangapple go评论93阅读模式
英文:

How can I retrieve the list of input documents used by ChatGPT in LangChain?

问题

I'm utilizing OpenAI's ChatGPT model within the LangChain framework, where I pass input_documents to provide context for generating responses. However, I would like to know if there is a way to extract the specific list of input documents that were utilized by ChatGPT during the response generation process in LangChain. Either by a specific prompt to ChatGPT or using some attribute in load_qa_chain I'm not aware of. Meaning, if I passed 4 input documents and ChatGPT only used 2 of them to generate a result - which 2 did ChatGPT use?

Thank you for your assistance and any insights you can provide!

英文:

I'm utilizing OpenAI's ChatGPT model within the LangChain framework, where I pass input_documents to provide context for generating responses. However, I would like to know if there is a way to extract the specific list of input documents that were utilized by ChatGPT during the response generation process in LangChain.
Either by a specific prompt to ChatGPT or using some attribute in load_qa_chain I'm not aware of.
Meaning, if I passed 4 input documents and ChatGPT only used 2 of them to generate a result - which 2 did ChatGPT used?

Thank you for your assistance and any insights you can provide!

答案1

得分: 1

你是否查看了链条 RetrievalQAWithSourcesChain(https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_qa_with_sources.html),或者 Question Answering with Sources(https://python.langchain.com/en/latest/modules/chains/index_examples/qa_with_sources.html),或者通过使用 load_qa_with_sources_chain(https://python.langchain.com/en/latest/use_cases/question_answering.html)?

如果你想获得更多反馈,还可以添加 StdOutCallbackHandler(https://python.langchain.com/en/latest/modules/callbacks/getting_started.html)

handler = StdOutCallbackHandler()
chain.run(input_documents=docs, question=query, callbacks=[handler])

或者设置 verbose=True(https://python.langchain.com/en/latest/modules/memory/getting_started.html)

英文:

Have you looked at the chain RetrievalQAWithSourcesChain (https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_qa_with_sources.html), or the Question Answering with Sources (https://python.langchain.com/en/latest/modules/chains/index_examples/qa_with_sources.html), or by using the load_qa_with_sources_chain (https://python.langchain.com/en/latest/use_cases/question_answering.html)

If you want to more feedback you can also add the StdOutCallbackHandler (https://python.langchain.com/en/latest/modules/callbacks/getting_started.html)

handler = StdOutCallbackHandler()
chain.run((input_documents=docs, question=query, callbacks=[handler])

or set verbose=True (https://python.langchain.com/en/latest/modules/memory/getting_started.html)

huangapple
  • 本文由 发表于 2023年5月21日 21:51:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76300233.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定