Update README.md
Browse files
README.md
CHANGED
@@ -101,19 +101,14 @@ The XVERSE-13B-256K model can be loaded for chat using the following code:
|
|
101 |
```python
|
102 |
import torch
|
103 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
104 |
-
|
105 |
-
|
106 |
-
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
107 |
-
model = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True, torch_dtype=torch.bfloat16, device_map='auto')
|
108 |
-
model.generation_config = GenerationConfig.from_pretrained(model_path)
|
109 |
model = model.eval()
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
response = model.chat(tokenizer, history)
|
116 |
-
print(response)
|
117 |
```
|
118 |
|
119 |
更多细节,包括对话 demo 、模型微调及量化等,请参考我们的[Github](https://github.com/xverse-ai/XVERSE-13B)。
|
|
|
101 |
```python
|
102 |
import torch
|
103 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
104 |
+
tokenizer = AutoTokenizer.from_pretrained("xverse/XVERSE-13B-256K")
|
105 |
+
model = AutoModelForCausalLM.from_pretrained("xverse/XVERSE-13B-256K", trust_remote_code=True, torch_dtype=torch.bfloat16, device_map='auto')
|
|
|
|
|
|
|
106 |
model = model.eval()
|
107 |
+
inputs = tokenizer('北京的景点:故宫、天坛、万里长城等。\n深圳的景点:', return_tensors='pt').input_ids
|
108 |
+
inputs = inputs.cuda()
|
109 |
+
generated_ids = model.generate(inputs, max_new_tokens=64, eos_token_id=tokenizer.eos_token_id, repetition_penalty=1.1)
|
110 |
+
print(tokenizer.batch_decode(generated_ids, skip_special_tokens=True))
|
111 |
+
|
|
|
|
|
112 |
```
|
113 |
|
114 |
更多细节,包括对话 demo 、模型微调及量化等,请参考我们的[Github](https://github.com/xverse-ai/XVERSE-13B)。
|