MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / SampleEncode

Method SampleEncode

external/sentencepiece/src/unigram_model.cc:723–739  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

721}
722
723EncodeResult Model::SampleEncode(absl::string_view normalized,
724 float inv_theta) const {
725 if (!status().ok() || normalized.empty()) {
726 return {};
727 }
728
729 Lattice lattice;
730 lattice.SetSentence(normalized);
731 PopulateNodes(&lattice);
732
733 EncodeResult results;
734 for (const auto *node : lattice.Sample(inv_theta)) {
735 results.emplace_back(node->piece, node->id);
736 }
737
738 return results;
739}
740
741NBestEncodeResult Model::SampleEncodeAndScore(absl::string_view normalized,
742 float inv_theta, int samples,

Callers

nothing calls this directly

Calls 4

okMethod · 0.80
SetSentenceMethod · 0.80
SampleMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected