]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
perplexity : fix ETA by warming up the model with an empty run
authorGeorgi Gerganov <redacted>
Sun, 3 Sep 2023 10:42:56 +0000 (13:42 +0300)
committerGeorgi Gerganov <redacted>
Sun, 3 Sep 2023 10:43:17 +0000 (13:43 +0300)
common/common.cpp
examples/main/main.cpp

index 41fc59ced5b57a17326fb92dd59bedae66e90f4a..a1c3dc7805361a6fae3d359b50e8642e8bfde8be 100644 (file)
@@ -752,6 +752,14 @@ std::tuple<struct llama_model *, struct llama_context *> llama_init_from_gpt_par
         params.logit_bias[llama_token_eos(lctx)] = -INFINITY;
     }
 
+    {
+        LOG("warming up the model with an empty run\n");
+
+        const std::vector<llama_token> tmp = { llama_token_bos(lctx), };
+        llama_eval(lctx, tmp.data(), tmp.size(), 0, params.n_threads);
+        llama_reset_timings(lctx);
+    }
+
     return std::make_tuple(model, lctx);
 }
 
index 7117db4b091f182b369ecf749fdef0159135a119..db98312ca1abac2cd3ac1d43e47237d7d680760e 100644 (file)
@@ -492,14 +492,6 @@ int main(int argc, char ** argv) {
     std::vector<llama_token> embd;
     std::vector<llama_token> embd_guidance;
 
-    {
-        LOG("warming up the model with an empty run\n");
-
-        const std::vector<llama_token> tmp = { llama_token_bos(ctx), };
-        llama_eval(ctx, tmp.data(), tmp.size(), 0, params.n_threads);
-        llama_reset_timings(ctx);
-    }
-
     while ((n_remain != 0 && !is_antiprompt) || params.interactive) {
         // predict
         if (embd.size() > 0) {