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

Use correct type of pooling for embedding models #5500

Merged
merged 3 commits into from
Feb 15, 2024

Conversation

iamlemec
Copy link
Collaborator

We had previously been doing sum pooling to approximate mean pooling in all cases. This changes to:

  • On conversion, read pooling configuration (MEAN, CLS, NONE)
  • Actually do MEAN pooling by precomputing sequence lengths
  • Use ggml_get_rows to speed up CLS pooling (just first token)

Testing with a couple of different types of models, numbers look very close to SentenceTransformers. Remaining differentials are due to the various tokenization issues discussed.

convert-hf-to-gguf.py Outdated Show resolved Hide resolved
convert-hf-to-gguf.py Outdated Show resolved Hide resolved
gguf-py/gguf/constants.py Outdated Show resolved Hide resolved
llama.cpp Show resolved Hide resolved
@iamlemec
Copy link
Collaborator Author

@ggerganov Should I merge this? Don't know what the proper etiquette is around here.

@ggerganov
Copy link
Owner

Yes, squash merge. I'm not at PC atm

@iamlemec iamlemec merged commit 4524290 into ggerganov:master Feb 15, 2024
44 of 54 checks passed
jordankanter pushed a commit to jordankanter/llama.cpp that referenced this pull request Mar 13, 2024
Use correct type of pooling for embedding models
hodlen pushed a commit to hodlen/llama.cpp that referenced this pull request Apr 1, 2024
Use correct type of pooling for embedding models
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