xiaotinghe commited on
Commit
4f5cf55
1 Parent(s): 4377b20

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +69 -0
README.md CHANGED
@@ -9,6 +9,75 @@ tasks:
9
 
10
  <!-- markdownlint-disable first-line-h1 -->
11
  <!-- markdownlint-disable html -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  <div align="center">
13
  <h1>
14
  Baichuan 2
 
9
 
10
  <!-- markdownlint-disable first-line-h1 -->
11
  <!-- markdownlint-disable html -->
12
+
13
+ # Baichuan 2 7B Chat - Int4
14
+ <!-- description start -->
15
+ ## 描述
16
+
17
+ 该repo包含[Baichuan 2 7B Chat](https://huggingface.co/baichuan-inc/Baichuan2-7B-Chat)的Int4 GPTQ模型文件。
18
+
19
+ <!-- description end -->
20
+
21
+
22
+ <!-- README_GPTQ.md-provided-files start -->
23
+ ## GPTQ参数
24
+ 该GPTQ文件都是用AutoGPTQ生成的。
25
+
26
+ - Bits: 4
27
+ - GS: 128
28
+ - Act Order: True
29
+ - Damp %: 0.01
30
+ - GPTQ dataset: 中文、英文混合数据集
31
+ - Sequence Length: 4096
32
+
33
+ <!-- README_GPTQ.md-provided-files end -->
34
+ ## 如何在Python代码中使用此GPTQ模型
35
+
36
+ ### 安装必要的依赖
37
+
38
+ 必须: Transformers 4.32.0以上、Optimum 1.12.0以上、AutoGPTQ 0.4.2以上
39
+
40
+ ```shell
41
+ pip3 install transformers>=4.32.0 optimum>=1.12.0
42
+ pip3 install auto-gptq --extra-index-url https://huggingface.github.io/autogptq-index/whl/cu118/ # Use cu117 if on CUDA 11.7
43
+ ```
44
+
45
+ 如果您在使用预构建的pip包安装AutoGPTQ时遇到问题,请改为从源代码安装:
46
+
47
+ ```shell
48
+ pip3 uninstall -y auto-gptq
49
+ git clone https://github.com/PanQiWei/AutoGPTQ
50
+ cd AutoGPTQ
51
+ pip3 install .
52
+ ```
53
+
54
+ ### 然后可以使用以下代码
55
+
56
+ ```python
57
+ from transformers import AutoModelForCausalLM, AutoTokenizer
58
+ from transformers.generation.utils import GenerationConfig
59
+
60
+ model_name_or_path = "csdc-atl/Baichuan2-7B-Chat-Int4"
61
+ model = AutoModelForCausalLM.from_pretrained(model_name_or_path,
62
+ torch_dtype=torch.float16,
63
+ device_map="auto",
64
+ trust_remote_code=True)
65
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True, trust_remote_code=True)
66
+
67
+ model.generation_config = GenerationConfig.from_pretrained("baichuan-inc/Baichuan2-7B-Chat")
68
+ messages = []
69
+ messages.append({"role": "user", "content": "解释一下“温故而知新”"})
70
+ response = model.chat(tokenizer, messages)
71
+ print(response)
72
+ "温故而知新"是一句中国古代的成语,出自《论语·为政》篇。这句话的意思是:通过回顾过去,我们可以发现新的知识和理解。换句话说,学习历史和经验可以让我们更好地理解现在和未来。
73
+
74
+ 这句话鼓励我们在学习和生活中不断地回顾和反思过去的经验,从而获得新的启示和成长。通过重温旧的知识和经历,我们可以发现新的观点和理解,从而更好地应对不断变化的世界和挑战。
75
+ ```
76
+ <!-- README_GPTQ.md-use-from-python end -->
77
+ <!-- README_GPTQ.md-compatibility start -->
78
+
79
+ ---
80
+
81
  <div align="center">
82
  <h1>
83
  Baichuan 2