Skip to content

Commit 7c37ae9

Browse files
committed
only use embd output for pooling_type NONE
1 parent 1756c4b commit 7c37ae9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llama.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11779,7 +11779,7 @@ static void llama_set_inputs(llama_context & lctx, const llama_batch & batch) {
1177911779
ggml_backend_tensor_set(lctx.inp_pos, batch.pos, 0, n_tokens*ggml_element_size(lctx.inp_pos));
1178011780
}
1178111781

11782-
if (hparams.causal_attn || cparams.pooling_type == LLAMA_POOLING_TYPE_NONE) {
11782+
if (!cparams.embeddings || cparams.pooling_type == LLAMA_POOLING_TYPE_NONE) {
1178311783
GGML_ASSERT(lctx.inp_out_ids && "every model that can must skip unused outputs");
1178411784
const int64_t n_tokens = batch.n_tokens;
1178511785

@@ -11811,7 +11811,7 @@ static void llama_set_inputs(llama_context & lctx, const llama_batch & batch) {
1181111811
// (!a || b) is a logical implication (a -> b)
1181211812
// !hparams.causal_attn -> !cparams.causal_attn
1181311813
(hparams.causal_attn || !cparams.causal_attn) &&
11814-
"causal attention with embedding models is not supported"
11814+
"causal attention is not supported by this model"
1181511815
);
1181611816

1181711817
if (lctx.inp_KQ_mask) {
@@ -12036,7 +12036,7 @@ static size_t llama_output_reserve(llama_context & lctx, size_t n_outputs) {
1203612036

1203712037
// TODO: use a per-batch flag for logits presence instead
1203812038
const bool has_logits = !cparams.embeddings;
12039-
const bool has_embd = cparams.embeddings;
12039+
const bool has_embd = cparams.embeddings && (cparams.pooling_type == LLAMA_POOLING_TYPE_NONE);
1204012040

1204112041
const size_t logits_size = has_logits ? n_vocab*n_outputs_max : 0;
1204212042
const size_t embd_size = has_embd ? n_embd*n_outputs_max : 0;

0 commit comments

Comments
 (0)