From c4cfcf15398578a016618d408f492295a914ce6a Mon Sep 17 00:00:00 2001 From: Laurent Mazare Date: Sat, 16 Dec 2023 18:11:36 -0600 Subject: [PATCH] Tweak the readme for phi and the default sample length. (#1450) --- candle-examples/examples/phi/README.md | 25 +++++++++++-------------- candle-examples/examples/phi/main.rs | 2 +- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/candle-examples/examples/phi/README.md b/candle-examples/examples/phi/README.md index 33665dba..70af6650 100644 --- a/candle-examples/examples/phi/README.md +++ b/candle-examples/examples/phi/README.md @@ -12,22 +12,19 @@ quantized variant. For the v2 version. ```bash -$ cargo run --example phi --release -- --prompt "def print_prime(n): " --model 2 -def print_prime(n): - if n <= 1: - print("Not a prime number") - else: - for i in range(2, int(n**0.5)+1): - if (n % i) == 0: - print("Not a prime number") - break - else: - print("Prime number") +$ cargo run --example phi --release -- --model 2 \ + --prompt "A skier slides down a frictionless slope of height 40m and length 80m. What's the skier speed at the bottom?" +A skier slides down a frictionless slope of height 40m and length 80m. What's the skier speed at the bottom? -# Driver code -n = 17 -print_prime(n) +Solution: +The potential energy of the skier is converted into kinetic energy as it slides down the slope. The formula for potential energy is mgh, where m is mass, g is acceleration due to gravity (9.8 m/s^2), and h is height. Since there's no friction, all the potential energy is converted into kinetic energy at the bottom of the slope. The formula for kinetic energy is 1/2mv^2, where v is velocity. We can equate these two formulas: +mgh = 1/2mv^2 +Solving for v, we get: +v = sqrt(2gh) +Substituting the given values, we get: +v = sqrt(2*9.8*40) = 28 m/s +Therefore, the skier speed at the bottom of the slope is 28 m/s. ``` For the v1.5 version. diff --git a/candle-examples/examples/phi/main.rs b/candle-examples/examples/phi/main.rs index 321ea5de..52d453b5 100644 --- a/candle-examples/examples/phi/main.rs +++ b/candle-examples/examples/phi/main.rs @@ -160,7 +160,7 @@ struct Args { seed: u64, /// The length of the sample to generate (in tokens). - #[arg(long, short = 'n', default_value_t = 100)] + #[arg(long, short = 'n', default_value_t = 5000)] sample_len: usize, #[arg(long)]