MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / probs_vector_to_json

Method probs_vector_to_json

tools/server/server-task.cpp:684–704  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

682}
683
684json completion_token_output::probs_vector_to_json(const std::vector<completion_token_output> & probs, bool post_sampling_probs) {
685 json out = json::array();
686 for (const auto & p : probs) {
687 std::string txt(p.text_to_send);
688 txt.resize(validate_utf8(txt));
689 out.push_back(json {
690 {"id", p.tok},
691 {"token", txt},
692 {"bytes", str_to_bytes(p.text_to_send)},
693 {
694 post_sampling_probs ? "prob" : "logprob",
695 post_sampling_probs ? p.prob : logarithm(p.prob)
696 },
697 {
698 post_sampling_probs ? "top_probs" : "top_logprobs",
699 p.to_json(post_sampling_probs)
700 },
701 });
702 }
703 return out;
704}
705
706float completion_token_output::logarithm(float x) {
707 // nlohmann::json converts -inf to null, so we need to prevent that

Callers

nothing calls this directly

Calls 4

validate_utf8Function · 0.85
resizeMethod · 0.45
push_backMethod · 0.45
to_jsonMethod · 0.45

Tested by

no test coverage detected