Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support reranker #1532

Closed
wants to merge 11 commits into from
Closed

Conversation

Anhui-tqhuang
Copy link
Contributor

@Anhui-tqhuang Anhui-tqhuang commented Jan 23, 2024

@imartinez hey review appreciated

i want to add the support for reranker as a postnodeprocesser

The functionality of the Reranker is as follows:

  1. It evaluates the similarity between a query and documents retrieved by the retriever.
  2. If the similarity score is less than cut_off, the document is excluded from the results.
  3. In scenarios where the filtered documents are fewer than top_n, the system defaults to providing the top top_n documents ignoring the cut_off score.
  4. The hf_model_name parameter allows users to specify the particular FlagReranker model from Hugging Face for the reranking process.

Use the enabled flag to toggle the Reranker as per requirement for optimized results.

@imartinez
Copy link
Collaborator

@Anhui-tqhuang I think the idea is great! I have a general question though: those reranker models can be used through FlagEmebedding (as you proposed) or through SentenceTransformers. The benefit of the latter is that LlamaIndex already contains a SentenceTransformerRerank class. That way we could add the benefits you are proposing without:

  • depending on an extra library (flagembedding)
  • having to write a custom reranker class

I'd love to know your opinion. Maybe you want to give a try to the SentenceTransformer reranker using the same model. The rest of the PR looks like an amazing addition to the project. I'd ask you to update the documentation to reflect it (fern/docs/pages...)

Thanks!

@Anhui-tqhuang
Copy link
Contributor Author

Hey thanks for your suggestion! I would try to use the sentence transformer as well as updating the documentation when i back from the spring festival!

@Anhui-tqhuang
Copy link
Contributor Author

Anhui-tqhuang commented Feb 9, 2024

btw though llamax index has already supported the llm reranker. But it is not that stable since the output of llm is not expectable, as a result
, private gpt might meet errors when the response from the llm cannot be parsed

For example i have one parser when want to read the output of the llm in the following format

  • doc 1: relevances 10
  • doc 3: relevances 8
  • doc 2: relevances 6

Sometime it gives

  • doc 1 relevances 10
  • doc 3 relevances 8
  • doc 2 relevances 6

Someone it gives

  • doc 1: relevances 10 (this is the most relevant doc)
  • doc 3: relevances 8 this doc has mentioned the xxxx
  • doc 2: relevances 6

Even it could give some summaries which is not expected

No matter what kind of of prompts i make for llm reranker, it could not pass all the cases

That's the reason i want to use a dedicated model which is used for reranker as its result will contains the similarity only

I might need some time on the investigation could we use the sentences transformer to run that dedicated model directly

@Anhui-tqhuang
Copy link
Contributor Author

Anhui-tqhuang commented Feb 18, 2024

@imartinez hey i give another pass to the model card again: https://huggingface.co/BAAI/bge-reranker-large#usage-for-reranker

it cannot be used with the sentence transformer

moreover with my previous comments, i still try to avoid using llm for reranker purpose as the result is not stable for parser, a dedicated model with float result would be more stable, this is also the reason that i want to have a customized component instead of using LLMReranker

Copy link
Contributor

Copy link
Contributor

Copy link
Contributor

Copy link
Contributor

Copy link
Contributor

Copy link
Contributor

Copy link
Contributor

@Anhui-tqhuang
Copy link
Contributor Author

@imartinez hey, could you plz have a pass? it will be appreciated

@cloudrage999
Copy link

cloudrage999 commented Feb 28, 2024

hi anhui
im using your PR in my pg instance
im using bge-reranker as well
when you think this PR would be approved ?

also is bge-reranker the best local reranker we can have ?

another thing,i made a PR about query search results , in order be able to do both semantic search and classic keyword-based search to retrieve more relevant context for user query

can you please take a look at it and tell me your opinion on it,its bugs and etc
thanks man

@Anhui-tqhuang
Copy link
Contributor Author

Anhui-tqhuang commented Feb 29, 2024

@cloudrage999 hey

when you think this PR would be approved ?

i am still waiting for review from @imartinez

also is bge-reranker the best local reranker we can have ?

to be honest, i haven't tried other reranker models, so i cannot tell

@Anhui-tqhuang
Copy link
Contributor Author

@cloudrage999

another thing,i made a PR about query search results , in order be able to do both semantic search and classic keyword-?> > based search to retrieve more relevant context for user query

can you please take a look at it and tell me your opinion on it,its bugs and etc
thanks man

could you show me the link to the PR plz?

Copy link
Contributor

Copy link
Contributor

Copy link
Contributor

Copy link
Contributor

Copy link
Contributor

Copy link
Contributor

Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants