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

Function common_sampler_get_candidates

common/sampling.cpp:655–680  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

653// helpers
654
655llama_token_data_array * common_sampler_get_candidates(struct common_sampler * gsmpl, bool do_sort) {
656 const auto tm = gsmpl->tm();
657
658 auto * res = &gsmpl->cur_p;
659
660 if (do_sort && !res->sorted) {
661 // remember the selected token before sorting
662 const llama_token id = res->data[res->selected].id;
663
664 std::sort(res->data, res->data + res->size, [](const llama_token_data & a, const llama_token_data & b) {
665 return a.p > b.p;
666 });
667
668 // restore the selected token after sorting
669 for (size_t i = 0; i < res->size; ++i) {
670 if (res->data[i].id == id) {
671 res->selected = i;
672 break;
673 }
674 }
675
676 res->sorted = true;
677 }
678
679 return res;
680}
681
682llama_token common_sampler_last(const struct common_sampler * gsmpl) {
683 return gsmpl->prev.rat(0);

Callers 4

mainFunction · 0.85
populate_token_probsMethod · 0.85
draftMethod · 0.85
mainFunction · 0.85

Calls 1

tmMethod · 0.80

Tested by 2

draftMethod · 0.68
mainFunction · 0.68