@@ -121,9 +121,6 @@ import torch
121121from transformers import AutoModelForCausalLM, AutoTokenizer
122122
123123device = torch.device(' cuda:0' )
124- # CodeShell-7B-Chat量化版本,占用显存更小
125- # model = AutoModelForCausalLM.from_pretrained('WisdomShell/CodeShell-7B-Chat-int4', trust_remote_code=True).to(device)
126- # tokenizer = AutoTokenizer.from_pretrained('WisdomShell/CodeShell-7B-Chat-int4')
127124model = AutoModelForCausalLM.from_pretrained(' WisdomShell/CodeShell-7B-Chat' , trust_remote_code = True ).to(device)
128125tokenizer = AutoTokenizer.from_pretrained(' WisdomShell/CodeShell-7B-Chat' )
129126
@@ -139,7 +136,6 @@ print(response)
139136history.append((query, response))
140137```
141138
142-
143139开发者也可以通过VS Code与JetBrains插件与CodeShell- 7B - Chat交互,详情请参[VSCode插件仓库](https:// github.com/ WisdomShell/ codeshell- vscode)与[IntelliJ插件仓库](https:// github.com/ WisdomShell/ codeshell- intellij)。
144140
145141
@@ -148,22 +144,18 @@ history.append((query, response))
148144CodeShell 支持4 bit/ 8 bit量化,4 bit量化后,占用显存大小约6G ,用户可以在显存较小的GPU 上使用CodeShell。
149145
150146```python
151- from transformers import AutoModelForCausalLM, AutoTokenizer
152- tokenizer = AutoTokenizer.from_pretrained(" WisdomShell/
153- CodeShell- Chat" , trust_remote_code=True)
154- model = AutoModelForCausalLM.from_pretrained(" WisdomShell/
155- CodeShell- Chat" , trust_remote_code=True)
156- model = model.quantize(4 ).cuda()
157-
158- inputs = tokenizer(' def print_hello_world():' , return_tensors = ' pt' ).cuda()
159- outputs = model.generate(inputs)
160- print (tokenizer.decode(outputs[0 ]))
147+ model = AutoModelForCausalLM.from_pretrained(' WisdomShell/CodeShell-7B-Chat-int4' , trust_remote_code = True ).to(device)
148+ tokenizer = AutoTokenizer.from_pretrained(' WisdomShell/CodeShell-7B-Chat-int4' )
161149```
162150
163151- CodeShell in c/ c++
164152
165153由于大部分个人电脑没有GPU ,CodeShell提供了C/ C++ 版本的推理支持,开发者可以根据本地环境进行编译,详见[CodeShell C/ C++ 本地化版](https:// github.com/ WisdomShell/ llama_cpp_for_codeshell)。编译完成后,可以通过下列命令启动Web API 服务。
166154
155+ ```
156+ ./ server - m {gguf_path} - c 2048
157+ ```
158+
167159# # Demo
168160
169161我们提供了Web- UI 、命令行、API 、IDE 四种形式的Demo。
0 commit comments