! * \brief Encode a batch of texts into ids. * \param texts The input texts. * \returns The encoded token ids. */
| 35 | * \returns The encoded token ids. |
| 36 | */ |
| 37 | virtual std::vector<std::vector<int32_t>> EncodeBatch(const std::vector<std::string>& texts) { |
| 38 | // Fall back when the derived class does not implement this function. |
| 39 | std::vector<std::vector<int32_t>> ret; |
| 40 | ret.reserve(texts.size()); |
| 41 | for (const auto& text : texts) { |
| 42 | ret.push_back(Encode(text)); |
| 43 | } |
| 44 | return ret; |
| 45 | } |
| 46 | |
| 47 | /*! |
| 48 | * \brief Decode token ids into text. |