Closed Lin-jun-xiang closed 4 months ago
not able to recreate with this
from langchain.chains import RetrievalQA
from langchain.llms import OpenAI
from langchain.vectorstores import FAISS
from langchain.embeddings import OpenAIEmbeddings
db = FAISS.from_texts(["foo"], OpenAIEmbeddings())
qa_cahin = RetrievalQA.from_chain_type(
llm=OpenAI(temperature=0.2),
chain_type='map_rerank',
retriever=db.as_retriever(),
chain_type_kwargs={}
)
off master, py3.11. anything im missing? what's in chain_type_kwargs?
I've update the code.
map_rerank not work.
Same Error here.
使用RetrievalQA.from_chain_type会出现Output parser of llm_chain should be a RegexParser, got None (type=value_error)的问题。但是我按照文档使用load_qa_chain加载就没有问题了
Hi, @Lin-jun-xiang,
I'm helping the LangChain team manage our backlog and am marking this issue as stale. It looks like you raised an issue regarding a validation error for the MapRerankDocumentsChain in the Langchain system. Several users have attempted to recreate the issue and encountered the same error, with one user providing a screenshot of the error message. The issue is still ongoing and has not been resolved.
Could you please confirm if this issue is still relevant to the latest version of the LangChain repository? If it is, please let the LangChain team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or the issue will be automatically closed in 7 days.
I appreciate your attention to this matter.
Best, Dosu
I encountered this same error today. Python is 3.10.9。it is ok if change chain_type to "stuff".
@baskaryan, could you please assist with the validation error for the MapRerankDocumentsChain in the Langchain system? The user encountered the same error today with Python 3.10.9 and provided a screenshot of the error message. Changing the chain_type to "stuff" resolved the issue. Thank you!
langchain:0.0.352
ValidationError: 1 validation error for StuffDocumentsChain
🤖
Based on the error message you're encountering, it seems that the output_parser
of the llm_chain
is not an instance of RegexParser
or it is None
. In the MapRerankDocumentsChain
class, there is a root validator method validate_llm_output
that checks if the output_parser
of the llm_chain
is an instance of RegexParser
. If it is not, it raises a ValueError
.
To resolve this error, you need to ensure that the output_parser
of the llm_chain
is an instance of RegexParser
. Here is an example of how to do this:
from langchain.chains import LLMChain
from langchain.output_parsers.regex import RegexParser
output_parser = RegexParser(
regex=r"(.*?)\nScore: (.*)",
output_keys=["answer", "score"],
)
llm_chain = LLMChain(llm=llm, prompt=prompt, output_parser=output_parser)
In this example, output_parser
is an instance of RegexParser
, and it is used when creating an instance of LLMChain
. This should prevent the validation error from being raised. You can find more details about this in the MapRerankDocumentsChain source code.
Regarding the chain_type
issue, it seems that different chain types require different keywords in their prompt templates. For example, in the Refine chain, the input variables are question_prompt
and refine_prompt
. You can find more details about this in the issue #6590.
I hope this helps! If you have any other questions or need further clarification, feel free to ask.
System Info
Who can help?
@hwchase17
Information
Related Components
Reproduction
The chain type in
RetrievalQA.from_chain_type()
:stuff
: work successfullyrefine
: not work unless uses correctly naming or parameter. #6912map_rerank
: not workmap_reduce
: not workAll the error of each type like:
code:
result:
Expected behavior
Does not crash, when i try to run it.