donjuanplatinum 1 год назад
Родитель
Сommit
87d9c3de10
3 измененных файлов с 97 добавлено и 101 удалено
  1. 0 47
      candle_demo/README.md
  2. 97 0
      candle_demo/README.org
  3. 0 54
      candle_demo/README_zh.md

+ 0 - 47
candle_demo/README.md

@@ -1,47 +0,0 @@
-![](../resources/candle_example.png)
-[English](./README.md) | [中文](./README_zh.md)
-# CPU Runing
-```
-cargo run --release -- --prompt your prompt
-```
-
-# Use
-``` shell
-Codegeex4
-
-Usage: codegeex4-candle [OPTIONS] --prompt <PROMPT>
-
-Options:
-  -c, --cache <cache>
-          Run on CPU rather than on GPU [default: .]
-      --cpu
-          
-      --verbose-prompt
-          Display the token for the specified prompt
-      --prompt <PROMPT>
-          
-      --temperature <TEMPERATURE>
-          The temperature used to generate samples
-      --top-p <TOP_P>
-          Nucleus sampling probability cutoff
-      --seed <SEED>
-          The seed to use when generating random samples [default: 299792458]
-  -n, --sample-len <SAMPLE_LEN>
-          The length of the sample to generate (in tokens) [default: 5000]
-      --model-id <MODEL_ID>
-          
-      --revision <REVISION>
-          
-      --weight-file <WEIGHT_FILE>
-          
-      --tokenizer <TOKENIZER>
-          
-      --repeat-penalty <REPEAT_PENALTY>
-          Penalty to be applied for repeating tokens, 1. means no penalty [default: 1.1]
-      --repeat-last-n <REPEAT_LAST_N>
-          The context size to consider for the repeat penalty [default: 64]
-  -h, --help
-          Print help
-  -V, --version
-          Print version
-```

+ 97 - 0
candle_demo/README.org

@@ -0,0 +1,97 @@
+* candle-codegeex4_9b
+THUDM/CodeGeeX4 is a versatile model for all AI software development scenarios, including code completion, code interpreter, web search, function calling, repository-level Q&A and much more.
+[[../resources/candle_example.png][file:../resources/candle_example.png]]
+
+- [[https://github.com/THUDM/CodeGeeX4][Github]]
+- [[https://codegeex.cn/][HomePage]]
+- [[https://huggingface.co/THUDM/codegeex4-all-9b][huggingface]]  
+- [[https://github.com/huggingface/candle/blob/main/candle-examples/examples/codegeex4-9b/README.org][Candle]]
+** Running with ~cuda~
+
+#+begin_src shell
+  cargo run --example codegeex4-9b --release --features cuda   --  --sample-len 300
+#+end_src
+
+** Running with ~cpu~
+#+begin_src shell
+  cargo run --example codegeex4-9b --release --cpu   --  --sample-len 300
+#+end_src
+
+** Output_Example
+*** Input
+#+begin_src shell
+  cargo run  --release --features cuda --  --sample-len 500 
+#+end_src
+
+*** Output
+#+begin_src shell
+  avx: false, neon: false, simd128: false, f16c: false
+  temp: 0.95 repeat-penalty: 1.10 repeat-last-n: 64
+  cache path /root/autodl-tmp
+  Prompt: [please write a FFT in rust]
+  Using Seed 11511762269791786684
+  DType is BF16
+  transofrmer layers create
+  模型加载完毕 4
+  starting the inference loop
+
+   开始生成
+  samplelen 500
+
+  500 tokens generated (34.60 token/s)
+  Result:
+
+  Sure, I can help you with that. Here's an example of a Fast Fourier Transform (FFT) implementation in Rust:
+
+  ```rust
+  use num_complex::Complex;
+
+  fn fft(input: &[Complex<f64> > ] ) -> Vec<Complex<f64> > > {
+      let n = input.len();
+    
+      if n == 1 {
+	  return vec![input[0]]];
+      }
+    
+      let mut even = vec![];
+      let mut odd = vec![];
+    
+      for i in 0..n {
+
+	      if i % 2 == 0 {
+	      even.push(input[i]);
+	  } else {
+	      odd.push(input[i]);
+	  }
+      }
+    
+      let even_fft = fft(&even);
+      let odd_fft = fft(&odd);
+    
+      let mut output = vec![];
+    
+      for k in 0..n/2 {
+	  let t = Complex::new(0.0, -2.0 * std::f64::consts::PI * (k as f64) / (n as f64))) ).exp();
+        
+	  output.push(even_fft[k] + odd_fft[k] * t]);
+	  output.push(even_fft[k] - odd_fft[k] * t]);
+      }
+    
+      return output;
+  }
+  ```
+
+  This implementation uses the Cooley-Tukey algorithm to perform the FFT. The function takes an array of complex numbers and returns an array of complex numbers which is the result of the FFT.
+#+end_src
+
+
+*  Citation
+#+begin_src
+  @inproceedings{zheng2023codegeex,
+  title={CodeGeeX: A Pre-Trained Model for Code Generation with Multilingual Benchmarking on HumanEval-X},
+  author={Qinkai Zheng and Xiao Xia and Xu Zou and Yuxiao Dong and Shan Wang and Yufei Xue and Zihan Wang and Lei Shen and Andi Wang and Yang Li and Teng Su and Zhilin Yang and Jie Tang},
+  booktitle={Proceedings of the 29th ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
+  pages={5673--5684},
+  year={2023}
+}
+#+end_src

+ 0 - 54
candle_demo/README_zh.md

@@ -1,54 +0,0 @@
-![](../resources/candle_example.png)
-[English](./README.md) | [中文](./README_zh.md)
-# CPU运行
-```
-cargo run --release -- --prompt your prompt
-```
-
-# 使用
-``` shell
-Codegeex4
-
-Usage: codegeex4-candle [OPTIONS] --prompt <PROMPT>
-
-Options:
-  -c, --cache <cache>
-          Run on CPU rather than on GPU [default: .]
-      --cpu
-          
-      --verbose-prompt
-          Display the token for the specified prompt
-      --prompt <PROMPT>
-          
-      --temperature <TEMPERATURE>
-          The temperature used to generate samples
-      --top-p <TOP_P>
-          Nucleus sampling probability cutoff
-      --seed <SEED>
-          The seed to use when generating random samples [default: 299792458]
-  -n, --sample-len <SAMPLE_LEN>
-          The length of the sample to generate (in tokens) [default: 5000]
-      --model-id <MODEL_ID>
-          
-      --revision <REVISION>
-          
-      --weight-file <WEIGHT_FILE>
-          
-      --tokenizer <TOKENIZER>
-          
-      --repeat-penalty <REPEAT_PENALTY>
-          Penalty to be applied for repeating tokens, 1. means no penalty [default: 1.1]
-      --repeat-last-n <REPEAT_LAST_N>
-          The context size to consider for the repeat penalty [default: 64]
-  -h, --help
-          Print help
-  -V, --version
-          Print version
-```
-# Cuda运行
-- 注意 需要cuda为>=12.4以上的版本
-```
-cargo build --release --features cuda
-./target/release/codegeex4-candle --prompt your prompt
-```
-