langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
93.15k stars 14.98k forks source link

found checker for RAG chain #15667

Closed mhyeonsoo closed 2 months ago

mhyeonsoo commented 9 months ago

Feature request

It would be helpful if I can make a RAG chain to output whether it could find the answer from the reference or not as a boolean value.

Motivation

From personal ideation.

Your contribution

N/A

dosubot[bot] commented 9 months ago

🤖

Hello @mhyeonsoo! I'm Dosu, an assistant here to help you with LangChain. Just a heads up, I'm a bot, but I'm here to assist you while we wait for a human maintainer to join us. Looking forward to helping you solve bugs, answer your questions, and guide you on your journey as a contributor. Let's get started!

Based on the current information available in the LangChain repository, it appears that the RAG (Retrieval-Augmented Generation) chains do not inherently provide a mechanism to output a boolean value indicating whether the answer was found in the reference or not.

The RAG chain in LangChain is designed to generate a response based on the input question and context. However, it does not seem to have a built-in feature to determine and output whether the generated response was found in the reference or not.

Here is the current implementation of the RAG chain:

# RAG
chain = (
    RunnableParallel({"context": retriever, "question": RunnablePassthrough()})
    | prompt
    | model
    | StrOutputParser()
)

As you can see, the chain is designed to run the retriever and the question in parallel, format the question and context, generate a response, and parse the output. There is no step in this chain that checks whether the answer was found in the reference or not.

However, it's important to note that this is based on the current version of LangChain (v0.1.0) and the information available in the repository. It's possible that this feature could be added in a future update or that there's a way to implement this feature that I'm not aware of.

If you have any additional information or context that could help me provide a more accurate answer, please let me know.

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

casperdcl commented 6 months ago

You can use BooleanOutputParser