Compare commits

..

1 Commits

Author SHA1 Message Date
copybara-service[bot] 4ecebfd5d9
Merge c4107cc9e7 into a8ceb75f43 2024-04-18 13:55:07 +00:00
1 changed files with 7 additions and 7 deletions

View File

@ -550,13 +550,6 @@ struct GemmaImpl : public GemmaInterface {
hwy::AlignedUniquePtr<Activations<Config, 1>> state;
};
template <class TConfig>
std::string TokenString(GemmaImpl<TConfig>& gemma, int token) {
std::string token_str;
gemma.Tokenizer()->Decode({token}, &token_str);
return "'" + std::regex_replace(token_str, std::regex("\n"), "\\n") + "'";
}
} // namespace gcpp
#endif // GEMMA_ONCE
@ -1130,6 +1123,13 @@ void GenerateImpl(GemmaImpl<TConfig>& gemma, size_t max_tokens,
}
}
template <class TConfig>
std::string TokenString(GemmaImpl<TConfig>& gemma, int token) {
std::string token_str;
gemma.Tokenizer()->Decode({token}, &token_str);
return "'" + std::regex_replace(token_str, std::regex("\n"), "\\n") + "'";
}
#define TOKEN(token_id) TokenString(gemma, token_id).c_str()
template <class TConfig>