File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -14726,12 +14726,15 @@ static int llama_decode_internal(
14726
14726
res = nullptr;
14727
14727
embd = nullptr;
14728
14728
} else if (cparams.embeddings) {
14729
- res = nullptr; // do not extract logits for embedding case
14730
- embd = gf->nodes[gf->n_nodes - 1];
14731
- if (strcmp(embd->name, "result_embd_pooled") != 0) {
14732
- embd = gf->nodes[gf->n_nodes - 2];
14729
+ res = nullptr; // do not extract logits for embedding case
14730
+ embd = nullptr;
14731
+ for (int i = gf->n_nodes - 1; i >= 0; --i) {
14732
+ if (strcmp(gf->nodes[i]->name, "result_embd_pooled") == 0) {
14733
+ embd = gf->nodes[i];
14734
+ break;
14735
+ }
14733
14736
}
14734
- GGML_ASSERT(strcmp( embd->name, "result_embd_pooled") == 0 && "missing embeddings tensor");
14737
+ GGML_ASSERT(embd != nullptr && "missing embeddings tensor");
14735
14738
} else {
14736
14739
embd = nullptr; // do not extract embeddings when not needed
14737
14740
GGML_ASSERT(strcmp(res->name, "result_output") == 0 && "missing result_output tensor");
You can’t perform that action at this time.
0 commit comments