Candle
类别: Candle LLM 标签: Candle Rust LLM Phi2 MPS目录
克隆
git clone https://github.com/huggingface/candle
cd candle
Phi-2
- CPU
$ 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?"
Finished release [optimized] target(s) in 0.22s
Running `target/release/examples/phi --model 2 --prompt 'A skier slides down a frictionless slope of height 40m and length 80m. What'\''s the skier speed at the bottom?'`
avx: false, neon: true, simd128: false, f16c: false
temp: 0.00 repeat-penalty: 1.10 repeat-last-n: 64
retrieved the files in 25.53875ms
Running on CPU, to run on GPU(metal), build this example with `--features metal`
loaded the model in 2.1345985s
starting the inference loop
A skier slides down a frictionless slope of height 40m and length 80m. What's the skier speed at the bottom?
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.
188 tokens generated (3.28 token/s)
- MPS
cargo run --example phi --release --features metal -- --model 2 \
--prompt "A skier slides down a frictionless slope of height 40m and length 80m. What's the skier speed at the bottom?"
Finished release [optimized] target(s) in 0.14s
Running `target/release/examples/phi --model 2 --prompt 'A skier slides down a frictionless slope of height 40m and length 80m. What'\''s the skier speed at the bottom?'`
avx: false, neon: true, simd128: false, f16c: false
temp: 0.00 repeat-penalty: 1.10 repeat-last-n: 64
retrieved the files in 23.022458ms
loaded the model in 1.317503208s
starting the inference loop
A skier slides down a frictionless slope of height 40m and length 80m. What's the skier speed at the bottom?
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.
188 tokens generated (21.20 token/s)
MPS 比 CPU 快了 6.5 倍。