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 @@ -14722,12 +14722,15 @@ static int llama_decode_internal(
14722
14722
res = nullptr;
14723
14723
embd = nullptr;
14724
14724
} else if (cparams.embeddings) {
14725
- res = nullptr; // do not extract logits for embedding case
14726
- embd = gf->nodes[gf->n_nodes - 1];
14727
- if (strcmp(embd->name, "result_embd_pooled") != 0) {
14728
- embd = gf->nodes[gf->n_nodes - 2];
14725
+ res = nullptr; // do not extract logits for embedding case
14726
+ embd = nullptr;
14727
+ for (int i = gf->n_nodes - 1; i >= 0; --i) {
14728
+ if (strcmp(gf->nodes[i]->name, "result_embd_pooled") == 0) {
14729
+ embd = gf->nodes[i];
14730
+ break;
14731
+ }
14729
14732
}
14730
- GGML_ASSERT(strcmp( embd->name, "result_embd_pooled") == 0 && "missing embeddings tensor");
14733
+ GGML_ASSERT(embd != nullptr && "missing embeddings tensor");
14731
14734
} else {
14732
14735
embd = nullptr; // do not extract embeddings when not needed
14733
14736
GGML_ASSERT(strcmp(res->name, "result_output") == 0 && "missing result_output tensor");
You can’t perform that action at this time.
0 commit comments