3

I am getting this error while trying intiliaze FlashrankRerank

PydanticUserError: FlashrankRerank is not fully defined; you should define Ranker, then call FlashrankRerank.model_rebuild()

This is my code

compressor = FlashrankRerank()
compression_retriever = ContextualCompressionRetriever(
    base_compressor=compressor, base_retriever=retriever
)

I tried compressor = FlashrankRerank.model_rebuild() But got this error PydanticUndefinedAnnotation: name 'Ranker' is not defined

1
  • Welcome to Stack Overflow. Please include the full traceback error. Commented Jan 27 at 7:42

1 Answer 1

1

You have to initialize model that you want to use with Ranker function in flashrank, you can define like:

from flashrank import Ranker 

ranker = Ranker(model_name="ms-marco-MiniLM-L-12-v2")

then fill it like:

compressor = FlashrankRerank(model="ms-marco-MiniLM-L-12-v2", top_n=3)

compression_retriever = ContextualCompressionRetriever(
base_compressor=compressor, base_retriever=retriever)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.