Skip to content

examples : allow extracting embeddings from decoder contexts #13797

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

Merged
merged 1 commit into from
May 26, 2025

Conversation

ggerganov
Copy link
Member

fix #13795
cont #13108
ref #13108 (comment)

Sometimes it might be necessary to extract embeddings from a decoder-only model. To support this, update the examples to call llama_decode() instead of llama_encode() when computing embeddings. The call will internally fallback to llama_encode() if the model is encoder-only.

@aviallon
Copy link
Contributor

@ggerganov does this mean that models that benefited from cache-less embeddings will still benefit from the feature introduced in #13108

@ggerganov
Copy link
Member Author

ggerganov commented May 26, 2025

@aviallon Yes, this change should not modify the behavior for encoder-only (a.k.a. cache-less) models like BERT.

@aviallon
Copy link
Contributor

aviallon commented May 26, 2025

@ggerganov @ngxson you just earned a new sponsor.

@ggerganov ggerganov merged commit 79c137f into master May 26, 2025
50 of 53 checks passed
@ggerganov ggerganov deleted the gg/embedding-fix-non-embd-use branch May 26, 2025 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Eval bug: Output NAN when use Qwen3 embedding models with FP16
3 participants