| 125 | } |
| 126 | |
| 127 | std::string decode_sentencepiece( |
| 128 | const std::vector<SentencePiecePiece> & pieces, |
| 129 | const std::vector<int32_t> & token_ids) { |
| 130 | const auto processor = lookup_processor_for_pieces(pieces); |
| 131 | std::vector<int> ids; |
| 132 | ids.reserve(token_ids.size()); |
| 133 | for (const int32_t id : token_ids) { |
| 134 | ids.push_back(static_cast<int>(id)); |
| 135 | } |
| 136 | std::string output; |
| 137 | require_status(processor->Decode(ids, &output), "failed to decode with SentencePiece"); |
| 138 | return output; |
| 139 | } |
| 140 | |
| 141 | SentencePieceTokenizer::SentencePieceTokenizer(std::vector<SentencePiecePiece> pieces) |
| 142 | : pieces_(std::move(pieces)) {} |
nothing calls this directly
no test coverage detected