MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / send_rerank

Method send_rerank

smallthinker/tools/server/server.cpp:2585–2614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2583 }
2584
2585 void send_rerank(const server_slot & slot, const llama_batch & batch) {
2586 auto res = std::make_unique<server_task_result_rerank>();
2587 res->id = slot.id_task;
2588 res->index = slot.index;
2589 res->n_tokens = slot.n_prompt_tokens;
2590
2591 for (int i = 0; i < batch.n_tokens; ++i) {
2592 if (!batch.logits[i] || batch.seq_id[i][0] != slot.id) {
2593 continue;
2594 }
2595
2596 const float * embd = llama_get_embeddings_seq(ctx, batch.seq_id[i][0]);
2597 if (embd == NULL) {
2598 embd = llama_get_embeddings_ith(ctx, i);
2599 }
2600
2601 if (embd == NULL) {
2602 SLT_ERR(slot, "failed to get embeddings, token = %d, seq_id = %d\n", batch.token[i], batch.seq_id[i][0]);
2603
2604 res->score = -1e6;
2605 continue;
2606 }
2607
2608 res->score = embd[0];
2609 }
2610
2611 SLT_DBG(slot, "sending rerank result, res.score = %f\n", res->score);
2612
2613 queue_results.send(std::move(res));
2614 }
2615
2616 //
2617 // Functions to create new task(s) and receive result(s)

Callers

nothing calls this directly

Calls 3

llama_get_embeddings_seqFunction · 0.85
llama_get_embeddings_ithFunction · 0.85
sendMethod · 0.45

Tested by

no test coverage detected