RankLLMRerank usage throws an error when used GPT (not only) when rank-llm version is > 0.12.8 #29156
Closed
5 tasks done
Labels
🤖:bug
Related to a bug, vulnerability, unexpected error with an existing feature
Checked other resources
Soluton
Issue is resolved with the PR: #29154
Example Code
Code from the tutorial and rank-llm installed with version > 0.12.8:
Error Message and Stack Trace
ModuleNotFoundError Traceback (most recent call last)
File ~/Library/Caches/pypoetry/virtualenvs/nlp-rag-NMztfdt9-py3.10/lib/python3.10/site-packages/langchain_community/document_compressors/rankllm_rerank.py:69, in RankLLMRerank.validate_environment(cls, values)
68 elif model_enum == ModelType.GPT:
---> 69 from rank_llm.rerank.rank_gpt import SafeOpenai
70 from rank_llm.rerank.reranker import Reranker
ModuleNotFoundError: No module named 'rank_llm.rerank.rank_gpt'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
Cell In[4], line 8
3 from core.retrieval import retriever_rank_gpt
5 import rank_llm
7 retrieval_chain = query_translation(prompt_template=multi_query_prompt_template, retriever=
----> 8 retriever_rank_gpt(retriever=retriever)
9 )
11 docs = retrieval_chain.invoke({"question": "What is task decomposition for LLM agents?"})
13 pretty_print_docs(docs)
File ~/.../src/core/retrieval.py:55, in retriever_rank_gpt(retriever)
52 def retriever_rank_gpt(
53 retriever: VectorStoreRetriever,
54 ) -> VectorStoreRetriever:
...
86 "Please install it with
pip install rank_llm
."87 )
89 return values
ImportError: Could not import rank_llm python package. Please install it with
pip install rank_llm
.Description
The RankLLMRerank integration in LangChain, designed to rerank documents, throws an error when used with GPT (or other models) if the rank-llm package version exceeds 0.12.8. This issue arises due to breaking changes introduced in newer versions of the rank-llm package, now all of the files like rank_gpt, vicuna_reranker or zephyr_reranker were moved to the submodule
rank_llm.rerank.listwise
.System Info
System Information
Package Information
Optional packages not installed
Other Dependencies
The text was updated successfully, but these errors were encountered: