File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -359,8 +359,14 @@ Error Tiktoken::load(const std::string& path) {
359359 _special_token_decoder = _build_decoder (_special_token_encoder);
360360
361361 _regex = _create_regex (_pattern);
362+ // Warmup re2 as it is slow on the first run, void the return value as it's
363+ // not needed Refer to
364+ // https://github.com/google/re2/blob/6dcd83d60f7944926bfd308cc13979fc53dd69ca/re2/fuzzing/re2_fuzzer.cc#L136-L141
365+ (void )_regex->ReverseProgramSize ();
362366
363367 _special_token_regex = _build_special_token_regex (_special_token_encoder);
368+ // Same as above, warm up re2
369+ (void )_special_token_regex->ReverseProgramSize ();
364370
365371 // initialize vocab_size, bos_tok, eos_tok
366372 vocab_size_ = _encoder.size () + _special_token_encoder.size ();
You can’t perform that action at this time.
0 commit comments