From 1ce7fe25436db6afc1076e5e2a678ec6e129d95f Mon Sep 17 00:00:00 2001 From: Laurent Mazare Date: Sun, 24 Sep 2023 18:19:05 +0100 Subject: [PATCH] Add more examples to the phi readme. (#956) --- candle-examples/examples/phi/README.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/candle-examples/examples/phi/README.md b/candle-examples/examples/phi/README.md index cdd32404..bbc252d6 100644 --- a/candle-examples/examples/phi/README.md +++ b/candle-examples/examples/phi/README.md @@ -1,6 +1,11 @@ # candle-phi: 1.3b LLM with state of the art performance for <10b models. -[phi-1.5](https://huggingface.co/microsoft/phi-1_5). +[Phi-1.5](https://huggingface.co/microsoft/phi-1_5) is a language model using +only 1.3 billion parameters but with state of the art performance compared to +models with up to 10 billion parameters. + +The candle implementation provides both the standard version as well as a +quantized variant. ## Running some example @@ -20,4 +25,19 @@ def is_prime(n): if n % i == 0: return False return True + +$ cargo run --example phi --release -- \ + --prompt "Explain how to find the median of an array and write the corresponding python function.\nAnswer:" \ + --quantized --sample-len 200 + +Explain how to find the median of an array and write the corresponding python function. +Answer: The median is the middle value in an array. If the array has an even number of elements, the median is the average of the two middle values. + +def median(arr): + arr.sort() + n = len(arr) + if n % 2 == 0: + return (arr[n//2 - 1] + arr[n//2]) / 2 + else: + return arr[n//2] ```