mirror of https://github.com/google/gemma.cpp.git
Compare commits
2 Commits
4ecebfd5d9
...
8aaeb7c868
| Author | SHA1 | Date |
|---|---|---|
|
|
8aaeb7c868 | |
|
|
38f1ea9b80 |
|
|
@ -550,6 +550,13 @@ 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
|
||||
|
||||
|
|
@ -1123,13 +1130,6 @@ 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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue