Add support for GritLM#5959
Merged
ggerganov merged 16 commits intoggml-org:masterfrom Mar 10, 2024
Merged
Conversation
ggerganov
reviewed
Mar 9, 2024
ggerganov
reviewed
Mar 9, 2024
iamlemec
approved these changes
Mar 9, 2024
ggerganov
reviewed
Mar 9, 2024
Comment on lines
+644
to
+646
| // Set whether to use causal attention or not | ||
| // If set to true, the model will only attend to the past tokens | ||
| LLAMA_API void llama_set_embeddings(struct llama_context * ctx, bool embeddings); |
Member
There was a problem hiding this comment.
This should be improved - the comment is about causal attention, but the function is called llama_set_embeddings. It's not clear enough
I think we need to introduce bool causal_attn in llama_cparams. It will be initialized by default with llama_hparams.causal_attn, but it would be possible to override it via llama_set_causal_attn(struct llama_context * ctx, bool causal_attn);
The if in llama_set_inputs() should be checking cparams.causal_attn. It would make more sense, because the if is about whether we build a causal mask or not. But the proposed change if (!cparams.embeddings) { is confusing
Collaborator
There was a problem hiding this comment.
Agreed, that is confusing. Pushing proposed changes now.
ggerganov
approved these changes
Mar 10, 2024
NeoZhangJianyu
pushed a commit
to NeoZhangJianyu/llama.cpp
that referenced
this pull request
Mar 12, 2024
* add gritlm example * gritlm results match * tabs to spaces * comment out debug printing * rebase to new embed * gritlm embeddings are back babeee * add to gitignore * allow to toggle embedding mode * Clean-up GritLM sample code. * Fix types. * Flush stdout and output ending newline if streaming. * mostly style fixes; correct KQ_mask comment * add causal_attn flag to llama_cparams * gritml : minor * llama : minor --------- Co-authored-by: Douglas Hanley <thesecretaryofwar@gmail.com> Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
Seunghhon
pushed a commit
to Seunghhon/llama.cpp
that referenced
this pull request
Apr 26, 2026
* add gritlm example * gritlm results match * tabs to spaces * comment out debug printing * rebase to new embed * gritlm embeddings are back babeee * add to gitignore * allow to toggle embedding mode * Clean-up GritLM sample code. * Fix types. * Flush stdout and output ending newline if streaming. * mostly style fixes; correct KQ_mask comment * add causal_attn flag to llama_cparams * gritml : minor * llama : minor --------- Co-authored-by: Douglas Hanley <thesecretaryofwar@gmail.com> Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
phuongncn
pushed a commit
to phuongncn/llama.cpp-gx10-dgx-sparks-deepseekv4
that referenced
this pull request
Apr 28, 2026
* add gritlm example * gritlm results match * tabs to spaces * comment out debug printing * rebase to new embed * gritlm embeddings are back babeee * add to gitignore * allow to toggle embedding mode * Clean-up GritLM sample code. * Fix types. * Flush stdout and output ending newline if streaming. * mostly style fixes; correct KQ_mask comment * add causal_attn flag to llama_cparams * gritml : minor * llama : minor --------- Co-authored-by: Douglas Hanley <thesecretaryofwar@gmail.com> Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5783
This PR adds support for GritLM (thanks to @iamlemec). I also added sample code to reproduce their example from here. The sample demonstrates how to use both embeddings and text generation using the same model.
I uploaded some model files here.