impl::load change map bpe_ranks to onordered map for reduce time of impl::load on 30%
This commit is contained in:
parent
acd38efee3
commit
5144a18e67
1 changed files with 7 additions and 2 deletions
|
@ -1245,8 +1245,13 @@ struct llama_vocab::impl {
|
||||||
|
|
||||||
std::vector<llama_token> cache_special_tokens;
|
std::vector<llama_token> cache_special_tokens;
|
||||||
std::vector<std::string> cache_token_to_piece; // llama_token_to_piece(special = true);
|
std::vector<std::string> cache_token_to_piece; // llama_token_to_piece(special = true);
|
||||||
|
struct PairHash {
|
||||||
std::map<std::pair<std::string, std::string>, int> bpe_ranks;
|
size_t operator()(const std::pair<std::string, std::string>& p) const {
|
||||||
|
return std::hash<std::string>{}(p.first) ^ //create some hash for pair
|
||||||
|
(std::hash<std::string>{}(p.second) << 1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
std::unordered_map<std::pair<std::string, std::string>, int, PairHash> bpe_ranks;
|
||||||
|
|
||||||
// set of all tokens that cause "end of generation"
|
// set of all tokens that cause "end of generation"
|
||||||
std::set<llama_token> special_eog_ids;
|
std::set<llama_token> special_eog_ids;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue