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

Sentence-BERT support for sentence similarity embeddings #2863

Closed
dranger003 opened this issue Aug 29, 2023 · 5 comments
Closed

Sentence-BERT support for sentence similarity embeddings #2863

dranger003 opened this issue Aug 29, 2023 · 5 comments
Labels
good first issue Good for newcomers model Model specific

Comments

@dranger003
Copy link
Contributor

I have been using bert.cpp for some time and I must admit the cosine similarity results are quite good. How difficult would it be to integrate the code into llama.cpp now that we have gguf?

I can surely invest some time to make this happen but the code is unfortunately somewhat over my skills. I was able to fix the code from skeskinen so that it works with the latest GGML but I have no idea how to update the GGML conversion script nor any idea how to add BERT support into llama.cpp. Anyone else have any interest to help?

https://github.com/skeskinen/bert.cpp/blob/master/bert.cpp

@ggerganov
Copy link
Owner

If there is large interest, we can add it to the roadmap and hopefully get some community support.
I don't think it would be very difficult to integrate it in llama.cpp especially that there is a working version in bert.cpp

@monatis
Copy link
Collaborator

monatis commented Aug 29, 2023

@ggerganov where do you think it will fit in the repository? Maybe implementation in common and usage example in server?

@ggerganov
Copy link
Owner

If I understand correctly, BERT is a model for just computing embeddings - i.e. you cannot use it for text generation, correct?

Why not add it directly in llama.cpp? We already have API for extracting the embeddings and the embedding example can be updated to support this if necessary

@ggerganov ggerganov added good first issue Good for newcomers model Model specific labels Aug 29, 2023
@monatis
Copy link
Collaborator

monatis commented Aug 29, 2023

BERT is a model for just computing embeddings - i.e. you cannot use it for text generation, correct?

Yes, that's true --it's an encoder-only model.

Why not add it directly in llama.cpp? We already have API for extracting the embeddings and the embedding example can be updated to support this if necessary

Great. I was thinking of an embeddings.cpp to support bert and other embedding models such as E5, XLMRoberta etc., but if it's fine to include it directly in llama.cpp I'd be happy to do so.

One common use case with LLMs is to index a collection of documents and retrieve them with embedding similarity in order to feed text relevant documents as context to LLMs. So supporting common embedding models will help with such usage scenarios in the community.

So you can add it to roadmap and assign to me.

@ggerganov
Copy link
Owner

@monatis

Created a new issue and will close this one: #2872

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers model Model specific
Projects
None yet
Development

No branches or pull requests

3 participants