Update README.md
Browse files
README.md
CHANGED
|
@@ -115,6 +115,47 @@ Edge-deployed DMind-2 can monitor market dynamics 24/7, promptly alerting users
|
|
| 115 |
|
| 116 |
## Usage Example
|
| 117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
## Privacy & Security
|
| 120 |
|
|
|
|
| 115 |
|
| 116 |
## Usage Example
|
| 117 |
|
| 118 |
+
```python
|
| 119 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 120 |
+
import torch
|
| 121 |
+
|
| 122 |
+
# 加载模型和分词器
|
| 123 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 124 |
+
"zai-org/GLM-4.5-Air",
|
| 125 |
+
torch_dtype=torch.float16,
|
| 126 |
+
device_map="auto",
|
| 127 |
+
trust_remote_code=True
|
| 128 |
+
)
|
| 129 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 130 |
+
"zai-org/GLM-4.5-Air",
|
| 131 |
+
trust_remote_code=True
|
| 132 |
+
)
|
| 133 |
+
|
| 134 |
+
# 示例对话
|
| 135 |
+
prompt = """<|im_start|>user
|
| 136 |
+
Please analyze the following investment opportunity:
|
| 137 |
+
1. Project: Emerging Layer2 DEX Protocol
|
| 138 |
+
2. TVL: $50M, growth rate 200%/month
|
| 139 |
+
3. Token Economics: 70% circulating, 30% team locked for 2 years
|
| 140 |
+
4. My risk tolerance: Medium
|
| 141 |
+
Please provide investment advice and risk analysis.
|
| 142 |
+
<|im_end|>
|
| 143 |
+
<|im_start|>assistant
|
| 144 |
+
"""
|
| 145 |
+
|
| 146 |
+
# 生成回复
|
| 147 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
| 148 |
+
outputs = model.generate(
|
| 149 |
+
**inputs,
|
| 150 |
+
max_length=2048,
|
| 151 |
+
temperature=0.7,
|
| 152 |
+
do_sample=True,
|
| 153 |
+
pad_token_id=tokenizer.eos_token_id
|
| 154 |
+
)
|
| 155 |
+
|
| 156 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 157 |
+
print(response)
|
| 158 |
+
```
|
| 159 |
|
| 160 |
## Privacy & Security
|
| 161 |
|