• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree.
7  */
8 
9 #include <gflags/gflags.h>
10 
11 #include <executorch/examples/models/phi-3-mini/runner.h>
12 
13 DEFINE_string(
14     model_path,
15     "phi-3-mini.pte",
16     "File path for model serialized in flatbuffer format.");
17 
18 DEFINE_string(tokenizer_path, "tokenizer.bin", "File path for tokenizer.");
19 
20 DEFINE_string(prompt, "Tell me a story", "Prompt.");
21 
22 DEFINE_double(
23     temperature,
24     0.8f,
25     "Temperature; Default is 0.8f. 0 = greedy argmax sampling (deterministic). Lower temperature = more deterministic");
26 
27 DEFINE_int32(
28     seq_len,
29     128,
30     "Total number of tokens to generate (prompt + output).");
31 
main(int32_t argc,char ** argv)32 int main(int32_t argc, char** argv) {
33   gflags::ParseCommandLineFlags(&argc, &argv, true);
34 
35   const char* model_path = FLAGS_model_path.c_str();
36 
37   const char* tokenizer_path = FLAGS_tokenizer_path.c_str();
38 
39   const char* prompt = FLAGS_prompt.c_str();
40 
41   double temperature = FLAGS_temperature;
42 
43   int32_t seq_len = FLAGS_seq_len;
44 
45   example::Runner runner(model_path, tokenizer_path, temperature);
46 
47   runner.generate(prompt, seq_len);
48 
49   return 0;
50 }
51