Update README.md
Browse files
README.md
CHANGED
@@ -67,7 +67,26 @@ Based on the original functions of Chatyuan-large-v1, we optimized the model as
|
|
67 |
|
68 |
## 期望模型使用方式及适用范围
|
69 |
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
#### 代码范例
|
73 |
|
|
|
67 |
|
68 |
## 期望模型使用方式及适用范围
|
69 |
|
70 |
+
### 对话运行方式
|
71 |
+
```python
|
72 |
+
from transformers import AutoTokenizer, AutoModel
|
73 |
+
import os
|
74 |
+
model_dir='ClueAI/ChatYuan-large-v2'
|
75 |
+
tokenizer = AutoTokenizer.from_pretrained(model_dir)
|
76 |
+
model = AutoModel.from_pretrained(model_dir, trust_remote_code=True)
|
77 |
+
history = []
|
78 |
+
print("starting")
|
79 |
+
while True:
|
80 |
+
query = input("\n用户:")
|
81 |
+
if query == "stop":
|
82 |
+
break
|
83 |
+
if query == "clear":
|
84 |
+
history = []
|
85 |
+
os.system('clear')
|
86 |
+
continue
|
87 |
+
response, history = model.chat(tokenizer, query, history=history)
|
88 |
+
print(f"小元:{response}")
|
89 |
+
```
|
90 |
|
91 |
#### 代码范例
|
92 |
|