Update README.md
Browse files
README.md
CHANGED
|
@@ -32,33 +32,35 @@ CodeShell is a multi-language code LLM developed by the [Knowledge Computing Lab
|
|
| 32 |
|
| 33 |
## Quickstart
|
| 34 |
|
| 35 |
-
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
Codeshell offers a model in the Hugging Face format. Developers can load and use it with the following code.
|
| 40 |
|
| 41 |
```python
|
|
|
|
| 42 |
import torch
|
| 43 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 44 |
-
tokenizer = AutoTokenizer.from_pretrained("codeshell", trust_remote_code=True)
|
| 45 |
-
model = AutoModelForCausalLM.from_pretrained("codeshell", trust_remote_code=True).cuda()
|
| 46 |
-
inputs = tokenizer('def print_hello_world():', return_tensors='pt').cuda()
|
| 47 |
-
outputs = model.generate(inputs)
|
| 48 |
-
print(tokenizer.decode(outputs[0]))
|
| 49 |
-
```
|
| 50 |
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
-
CodeShell
|
|
|
|
|
|
|
| 56 |
|
| 57 |
-
```python
|
| 58 |
-
input_text = "<fim_prefix>def print_hello_world():\n <fim_suffix>\n print('Hello world!')<fim_middle>"
|
| 59 |
-
inputs = tokenizer(input_text, return_tensors='pt').cuda()
|
| 60 |
-
outputs = model.generate(inputs)
|
| 61 |
-
print(tokenizer.decode(outputs[0]))
|
| 62 |
```
|
| 63 |
|
| 64 |
## Model Details
|
|
|
|
| 32 |
|
| 33 |
## Quickstart
|
| 34 |
|
| 35 |
+
CodeShell-7B-Chat量化版本 提供了Hugging Face格式的模型,开发者可以通过下列代码加载并使用。
|
| 36 |
|
| 37 |
+
CodeShell-7B-Chat-int4 offers a model in the Hugging Face format. Developers can load and use it with the following code.
|
|
|
|
|
|
|
| 38 |
|
| 39 |
```python
|
| 40 |
+
import time
|
| 41 |
import torch
|
| 42 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
+
device = torch.device('cuda:0')
|
| 45 |
+
model = AutoModelForCausalLM.from_pretrained('WisdomShell/CodeShell-7B-Chat-int4', trust_remote_code=True).to(device)
|
| 46 |
+
tokenizer = AutoTokenizer.from_pretrained('WisdomShell/CodeShell-7B-Chat-int4')
|
| 47 |
+
|
| 48 |
+
history = []
|
| 49 |
+
query = '你是谁?'
|
| 50 |
+
response = model.chat(query, history, tokenizer)
|
| 51 |
+
print(response)
|
| 52 |
+
history.append((query, response))
|
| 53 |
|
| 54 |
+
query = '用Python写一个HTTP server'
|
| 55 |
+
response = model.chat(query, history, tokenizer)
|
| 56 |
+
print(response)
|
| 57 |
+
history.append((query, response))
|
| 58 |
+
```
|
| 59 |
|
| 60 |
+
开发者也可以通过VS Code与JetBrains插件与CodeShell-7B-Chat量化版本交互,详情请参[VSCode插件仓库](https://github.com/WisdomShell/codeshell-vscode)与[IntelliJ插件仓库](https://github.com/WisdomShell/codeshell-intellij)。
|
| 61 |
+
|
| 62 |
+
Developers can also interact with CodeShell-7B-Chat-int4 through VS Code and JetBrains plugins. For details, please refer to the [VSCode Plugin Repository](https://github.com/WisdomShell/codeshell-vscode) and [IntelliJ Plugin Repository](https://github.com/WisdomShell/codeshell-intellij).
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
```
|
| 65 |
|
| 66 |
## Model Details
|