n1ck-guo commited on
Commit
5277ea1
·
verified ·
1 Parent(s): 82c9fac

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +81 -0
README.md ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model:
3
+ - deepseek-ai/DeepSeek-V3.1
4
+ pipeline_tag: text-generation
5
+ ---
6
+
7
+ ## Model Details
8
+
9
+ This model is a int4 model with group_size 128 and symmetric quantization of [deepseek-ai/DeepSeek-V3.1](https://huggingface.co/deepseek-ai/DeepSeek-V3.1) generated by [intel/auto-round](https://github.com/intel/auto-round).
10
+ Please follow the license of the original model.
11
+
12
+ ## How To Use
13
+
14
+
15
+ ### Generate the model
16
+
17
+ ```python
18
+ import torch
19
+ from transformers import AutoModelForCausalLM, AutoTokenizer
20
+ import transformers
21
+
22
+ model_name = "deepseek-ai/DeepSeek-V3.1"
23
+
24
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
25
+ model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=False, torch_dtype="auto")
26
+
27
+ block = model.model.layers
28
+ device_map = {}
29
+
30
+ for n, m in block.named_modules():
31
+ if isinstance(m, (torch.nn.Linear, transformers.modeling_utils.Conv1D)):
32
+ if "experts" in n and ("shared_experts" not in n) and int(n.split('.')[-2]) < 63:
33
+ device = "cuda:1"
34
+ elif "experts" in n and ("shared_experts" not in n) and int(n.split('.')[-2]) >= 63 and int(
35
+ n.split('.')[-2]) < 128:
36
+ device = "cuda:2"
37
+ elif "experts" in n and ("shared_experts" not in n) and int(n.split('.')[-2]) >= 128 and int(
38
+ n.split('.')[-2]) < 192:
39
+ device = "cuda:3"
40
+ elif "experts" in n and ("shared_experts" not in n) and int(
41
+ n.split('.')[-2]) >= 192:
42
+ device = "cuda:4"
43
+ else:
44
+ device = "cuda:0"
45
+ n = n[2:]
46
+
47
+ device_map.update({n: device})
48
+
49
+
50
+ from auto_round import AutoRound
51
+
52
+ autoround = AutoRound(model=model, tokenizer=tokenizer, device_map=device_map, nsamples=512,
53
+ batch_size=4, low_gpu_mem_usage=True, seqlen=2048,
54
+ )
55
+ autoround.quantize_and_save(format="auto_round", output_dir="tmp_autoround")
56
+ ```
57
+
58
+
59
+ ## Ethical Considerations and Limitations
60
+
61
+ The model can produce factually incorrect output, and should not be relied on to produce factually accurate information. Because of the limitations of the pretrained model and the finetuning datasets, it is possible that this model could generate lewd, biased or otherwise offensive outputs.
62
+
63
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
64
+
65
+ ## Caveats and Recommendations
66
+
67
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
68
+
69
+ Here are a couple of useful links to learn more about Intel's AI software:
70
+
71
+ - Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
72
+
73
+ ## Disclaimer
74
+
75
+ The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model. Please consult an attorney before using this model for commercial purposes.
76
+
77
+ ## Cite
78
+
79
+ @article{cheng2023optimize, title={Optimize weight rounding via signed gradient descent for the quantization of llms}, author={Cheng, Wenhua and Zhang, Weiwei and Shen, Haihao and Cai, Yiyang and He, Xin and Lv, Kaokao and Liu, Yi}, journal={arXiv preprint arXiv:2309.05516}, year={2023} }
80
+
81
+ [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)