Skip to content

Commit 7977320

Browse files
Update server-mmojo.cpp
Signed-off-by: Brad Hutchings <[email protected]>
1 parent 5b8143b commit 7977320

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

tools/server/server-mmojo.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2589,25 +2589,27 @@ struct server_context {
25892589
continue;
25902590
}
25912591

2592-
const float * embd = llama_get_embeddings_seq(ctx, batch.seq_id[i][0]);
2593-
if (embd == NULL) {
2592+
const float * embd = nullptr;
2593+
if (llama_pooling_type(slot.ctx) == LLAMA_POOLING_TYPE_NONE) {
25942594
embd = llama_get_embeddings_ith(ctx, i);
2595+
} else {
2596+
embd = llama_get_embeddings_seq(ctx, batch.seq_id[i][0]);
25952597
}
25962598

2597-
if (embd == NULL) {
2599+
if (embd == nullptr) {
25982600
SLT_ERR(slot, "failed to get embeddings, token = %d, seq_id = %d\n", batch.token[i], batch.seq_id[i][0]);
25992601

26002602
res->embedding.push_back(std::vector<float>(n_embd, 0.0f));
26012603
continue;
26022604
}
26032605

26042606
// normalize only when there is pooling
2605-
// TODO: configurable
26062607
if (llama_pooling_type(slot.ctx) != LLAMA_POOLING_TYPE_NONE) {
26072608
common_embd_normalize(embd, embd_res.data(), n_embd, 2);
26082609
res->embedding.push_back(embd_res);
2610+
break;
26092611
} else {
2610-
res->embedding.push_back({ embd, embd + n_embd });
2612+
res->embedding.emplace_back(embd, embd + n_embd);
26112613
}
26122614
}
26132615

@@ -3686,6 +3688,7 @@ struct server_context {
36863688
};
36873689
}
36883690
// mmojo-server END
3691+
36893692
};
36903693

36913694
static void log_server_request(const httplib::Request & req, const httplib::Response & res) {

0 commit comments

Comments
 (0)