| 139 | } |
| 140 | |
| 141 | std::string replace(const std::string & s, const std::string & from, const std::string & to) { |
| 142 | std::string result = s; |
| 143 | size_t pos = 0; |
| 144 | while ((pos = result.find(from, pos)) != std::string::npos) { |
| 145 | result.replace(pos, from.length(), to); |
| 146 | pos += to.length(); |
| 147 | } |
| 148 | return result; |
| 149 | } |
| 150 | |
| 151 | void gpt_vocab::add_special_token(const std::string & token) { |
| 152 | special_tokens.push_back(token); |
no test coverage detected